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

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

Issue 174213003: PPAPI: Use clang-format on ppapi/shared_impl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove DEPS Created 6 years, 10 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
« no previous file with comments | « ppapi/shared_impl/platform_file.cc ('k') | ppapi/shared_impl/ppapi_nacl_plugin_args.cc » ('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) 2012 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/lazy_instance.h" // For testing purposes only. 7 #include "base/lazy_instance.h" // For testing purposes only.
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/threading/thread_local.h" // For testing purposes only. 10 #include "base/threading/thread_local.h" // For testing purposes only.
(...skipping 18 matching lines...) Expand all
29 PpapiGlobals::PpapiGlobals(PerThreadForTest) { 29 PpapiGlobals::PpapiGlobals(PerThreadForTest) {
30 DCHECK(!ppapi_globals); 30 DCHECK(!ppapi_globals);
31 main_loop_proxy_ = base::MessageLoopProxy::current(); 31 main_loop_proxy_ = base::MessageLoopProxy::current();
32 } 32 }
33 33
34 PpapiGlobals::~PpapiGlobals() { 34 PpapiGlobals::~PpapiGlobals() {
35 DCHECK(ppapi_globals == this || !ppapi_globals); 35 DCHECK(ppapi_globals == this || !ppapi_globals);
36 ppapi_globals = NULL; 36 ppapi_globals = NULL;
37 } 37 }
38 38
39 //Static Getter for the global singleton. 39 // Static Getter for the global singleton.
40 PpapiGlobals* PpapiGlobals::Get() { 40 PpapiGlobals* PpapiGlobals::Get() {
41 if (ppapi_globals) 41 if (ppapi_globals)
42 return ppapi_globals; 42 return ppapi_globals;
43 // In unit tests, the following might be valid (see 43 // In unit tests, the following might be valid (see
44 // SetPpapiGlobalsOnThreadForTest). Normally, this will just return NULL. 44 // SetPpapiGlobalsOnThreadForTest). Normally, this will just return NULL.
45 return GetThreadLocalPointer(); 45 return GetThreadLocalPointer();
46 } 46 }
47 47
48 // static 48 // static
49 void PpapiGlobals::SetPpapiGlobalsOnThreadForTest(PpapiGlobals* ptr) { 49 void PpapiGlobals::SetPpapiGlobalsOnThreadForTest(PpapiGlobals* ptr) {
50 // If we're using a per-thread PpapiGlobals, we should not have a global one. 50 // If we're using a per-thread PpapiGlobals, we should not have a global one.
51 // If we allowed it, it would always over-ride the "test" versions. 51 // If we allowed it, it would always over-ride the "test" versions.
52 DCHECK(!ppapi_globals); 52 DCHECK(!ppapi_globals);
53 tls_ppapi_globals_for_test.Pointer()->Set(ptr); 53 tls_ppapi_globals_for_test.Pointer()->Set(ptr);
54 } 54 }
55 55
56 base::MessageLoopProxy* PpapiGlobals::GetMainThreadMessageLoop() { 56 base::MessageLoopProxy* PpapiGlobals::GetMainThreadMessageLoop() {
57 return main_loop_proxy_.get(); 57 return main_loop_proxy_.get();
58 } 58 }
59 59
60 void PpapiGlobals::ResetMainThreadMessageLoopForTesting() { 60 void PpapiGlobals::ResetMainThreadMessageLoopForTesting() {
61 main_loop_proxy_ = base::MessageLoopProxy::current(); 61 main_loop_proxy_ = base::MessageLoopProxy::current();
62 } 62 }
63 63
64 bool PpapiGlobals::IsHostGlobals() const { 64 bool PpapiGlobals::IsHostGlobals() const { return false; }
65 return false;
66 }
67 65
68 bool PpapiGlobals::IsPluginGlobals() const { 66 bool PpapiGlobals::IsPluginGlobals() const { return false; }
69 return false;
70 }
71 67
72 void PpapiGlobals::MarkPluginIsActive() { 68 void PpapiGlobals::MarkPluginIsActive() {}
73 }
74 69
75 // static 70 // static
76 PpapiGlobals* PpapiGlobals::GetThreadLocalPointer() { 71 PpapiGlobals* PpapiGlobals::GetThreadLocalPointer() {
77 return tls_ppapi_globals_for_test.Pointer()->Get(); 72 return tls_ppapi_globals_for_test.Pointer()->Get();
78 } 73 }
79 74
80 } // namespace ppapi 75 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/platform_file.cc ('k') | ppapi/shared_impl/ppapi_nacl_plugin_args.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698