summaryrefslogtreecommitdiffstats
path: root/chrome/service/cloud_print/cloud_print_token_store.h
blob: 767619b51e7f722a6e1b81d14aa58f3a35389c3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_TOKEN_STORE_H_
#define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_TOKEN_STORE_H_

#include <string>
#include "base/logging.h"
#include "base/macros.h"
#include "base/threading/non_thread_safe.h"

// This class serves as the single repository for cloud print auth tokens. This
// is only used within the CloudPrintProxyCoreThread.

namespace cloud_print {

class CloudPrintTokenStore : public base::NonThreadSafe {
 public:
  // Returns the CloudPrintTokenStore instance for this thread. Will be NULL
  // if no instance was created in this thread before.
  static CloudPrintTokenStore* current();

  CloudPrintTokenStore();
  ~CloudPrintTokenStore();

  void SetToken(const std::string& token);
  std::string token() const {
    DCHECK(CalledOnValidThread());
    return token_;
  }

 private:
  std::string token_;

  DISALLOW_COPY_AND_ASSIGN(CloudPrintTokenStore);
};

}  // namespace cloud_print

#endif  // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_TOKEN_STORE_H_