Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/service/cloud_print/cloud_print_token_store.cc

Issue 11360151: Move common cloud print methods from service/cloud_print to common/cloud_print. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/service/cloud_print/cloud_print_token_store.h" 5 #include "chrome/service/cloud_print/cloud_print_token_store.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h" 8 #include "base/threading/thread_local.h"
9 9
10 namespace cloud_print {
11
10 // Keep the global CloudPrintTokenStore in a TLS slot so it is impossible to 12 // Keep the global CloudPrintTokenStore in a TLS slot so it is impossible to
11 // incorrectly from the wrong thread. 13 // incorrectly from the wrong thread.
12 static base::LazyInstance<base::ThreadLocalPointer<CloudPrintTokenStore> > 14 static base::LazyInstance<base::ThreadLocalPointer<CloudPrintTokenStore> >
13 lazy_tls = LAZY_INSTANCE_INITIALIZER; 15 lazy_tls = LAZY_INSTANCE_INITIALIZER;
14 16
15 CloudPrintTokenStore* CloudPrintTokenStore::current() { 17 CloudPrintTokenStore* CloudPrintTokenStore::current() {
16 return lazy_tls.Pointer()->Get(); 18 return lazy_tls.Pointer()->Get();
17 } 19 }
18 20
19 CloudPrintTokenStore::CloudPrintTokenStore() { 21 CloudPrintTokenStore::CloudPrintTokenStore() {
20 lazy_tls.Pointer()->Set(this); 22 lazy_tls.Pointer()->Set(this);
21 } 23 }
22 24
23 CloudPrintTokenStore::~CloudPrintTokenStore() { 25 CloudPrintTokenStore::~CloudPrintTokenStore() {
24 lazy_tls.Pointer()->Set(NULL); 26 lazy_tls.Pointer()->Set(NULL);
25 } 27 }
26 28
27 void CloudPrintTokenStore::SetToken(const std::string& token) { 29 void CloudPrintTokenStore::SetToken(const std::string& token) {
28 DCHECK(CalledOnValidThread()); 30 DCHECK(CalledOnValidThread());
29 token_ = token; 31 token_ = token;
30 } 32 }
33
34 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_token_store.h ('k') | chrome/service/cloud_print/cloud_print_token_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698