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

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

Issue 2916303002: ThreadChecker instead of SequenceChecker in classes that use TLS. (Closed)
Patch Set: fix compile Created 3 years, 6 months 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
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 { 10 namespace cloud_print {
11 11
12 // 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
13 // incorrectly from the wrong thread. 13 // incorrectly from the wrong thread.
14 static base::LazyInstance< 14 static base::LazyInstance<
15 base::ThreadLocalPointer<CloudPrintTokenStore>>::DestructorAtExit lazy_tls = 15 base::ThreadLocalPointer<CloudPrintTokenStore>>::DestructorAtExit lazy_tls =
16 LAZY_INSTANCE_INITIALIZER; 16 LAZY_INSTANCE_INITIALIZER;
17 17
18 // static
18 CloudPrintTokenStore* CloudPrintTokenStore::current() { 19 CloudPrintTokenStore* CloudPrintTokenStore::current() {
19 return lazy_tls.Pointer()->Get(); 20 return lazy_tls.Pointer()->Get();
20 } 21 }
21 22
22 CloudPrintTokenStore::CloudPrintTokenStore() { 23 CloudPrintTokenStore::CloudPrintTokenStore() {
23 lazy_tls.Pointer()->Set(this); 24 lazy_tls.Pointer()->Set(this);
24 } 25 }
25 26
26 CloudPrintTokenStore::~CloudPrintTokenStore() { 27 CloudPrintTokenStore::~CloudPrintTokenStore() {
27 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 28 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
28 lazy_tls.Pointer()->Set(NULL); 29 lazy_tls.Pointer()->Set(NULL);
29 } 30 }
30 31
31 void CloudPrintTokenStore::SetToken(const std::string& token) { 32 void CloudPrintTokenStore::SetToken(const std::string& token) {
32 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 33 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
33 token_ = token; 34 token_ = token;
34 } 35 }
35 36
36 } // namespace cloud_print 37 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_token_store.h ('k') | content/child/fileapi/webfilesystem_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698