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

Side by Side Diff: ppapi/shared_impl/ppapi_globals.cc

Issue 9139054: Revert 117399 - Make it possible to have 1 PpapiGlobals per thread. Update unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/shared_impl/ppapi_globals.h ('k') | ppapi/shared_impl/proxy_lock.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 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 "ppapi/shared_impl/ppapi_globals.h" 5 #include "ppapi/shared_impl/ppapi_globals.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace ppapi { 9 namespace ppapi {
10 10
11 namespace {
12
13 base::ThreadLocalPointer<PpapiGlobals> tls_ppapi_globals_for_test;
14
15 } // namespace
16
17 PpapiGlobals* PpapiGlobals::ppapi_globals_ = NULL; 11 PpapiGlobals* PpapiGlobals::ppapi_globals_ = NULL;
18 12
19 PpapiGlobals::PpapiGlobals() { 13 PpapiGlobals::PpapiGlobals() {
20 DCHECK(!ppapi_globals_); 14 DCHECK(!ppapi_globals_);
21 ppapi_globals_ = this; 15 ppapi_globals_ = this;
22 } 16 }
23 17
24 PpapiGlobals::PpapiGlobals(ForTest) {
25 DCHECK(!ppapi_globals_);
26 }
27
28 PpapiGlobals::~PpapiGlobals() { 18 PpapiGlobals::~PpapiGlobals() {
29 DCHECK(ppapi_globals_ == this || !ppapi_globals_); 19 DCHECK(ppapi_globals_ == this);
30 ppapi_globals_ = NULL; 20 ppapi_globals_ = NULL;
31 } 21 }
32 22
33 // static
34 void PpapiGlobals::SetPpapiGlobalsOnThreadForTest(PpapiGlobals* ptr) {
35 // If we're using a per-thread PpapiGlobals, we should not have a global one.
36 // If we allowed it, it would always over-ride the "test" versions.
37 DCHECK(!ppapi_globals_);
38 tls_ppapi_globals_for_test.Set(ptr);
39 }
40
41 bool PpapiGlobals::IsHostGlobals() const {
42 return false;
43 }
44
45 bool PpapiGlobals::IsPluginGlobals() const {
46 return false;
47 }
48
49 // static
50 PpapiGlobals* PpapiGlobals::GetThreadLocalPointer() {
51 return tls_ppapi_globals_for_test.Get();
52 }
53
54 } // namespace ppapi 23 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/ppapi_globals.h ('k') | ppapi/shared_impl/proxy_lock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698