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

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

Issue 10702188: Fix unit test to allow repeated successful runs by avoiding a function static variable in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify with a member variable Created 8 years, 5 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
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_proxy.h" 9 #include "base/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 25 matching lines...) Expand all
36 36
37 // static 37 // static
38 void PpapiGlobals::SetPpapiGlobalsOnThreadForTest(PpapiGlobals* ptr) { 38 void PpapiGlobals::SetPpapiGlobalsOnThreadForTest(PpapiGlobals* ptr) {
39 // If we're using a per-thread PpapiGlobals, we should not have a global one. 39 // If we're using a per-thread PpapiGlobals, we should not have a global one.
40 // If we allowed it, it would always over-ride the "test" versions. 40 // If we allowed it, it would always over-ride the "test" versions.
41 DCHECK(!ppapi_globals_); 41 DCHECK(!ppapi_globals_);
42 tls_ppapi_globals_for_test.Pointer()->Set(ptr); 42 tls_ppapi_globals_for_test.Pointer()->Set(ptr);
43 } 43 }
44 44
45 base::MessageLoopProxy* PpapiGlobals::GetMainThreadMessageLoop() { 45 base::MessageLoopProxy* PpapiGlobals::GetMainThreadMessageLoop() {
46 CR_DEFINE_STATIC_LOCAL(scoped_refptr<base::MessageLoopProxy>, proxy, 46 if (!message_loop_proxy_.get())
47 (base::MessageLoopProxy::current())); 47 message_loop_proxy_ = base::MessageLoopProxy::current();
brettw 2012/07/13 16:36:22 I think you should just set this in the constructo
dmichael (off chromium) 2012/07/13 16:44:58 Agree. The important thing is that base::MessageLo
48 return proxy.get(); 48 return message_loop_proxy_.get();
49 } 49 }
50 50
51 bool PpapiGlobals::IsHostGlobals() const { 51 bool PpapiGlobals::IsHostGlobals() const {
52 return false; 52 return false;
53 } 53 }
54 54
55 bool PpapiGlobals::IsPluginGlobals() const { 55 bool PpapiGlobals::IsPluginGlobals() const {
56 return false; 56 return false;
57 } 57 }
58 58
59 // static 59 // static
60 PpapiGlobals* PpapiGlobals::GetThreadLocalPointer() { 60 PpapiGlobals* PpapiGlobals::GetThreadLocalPointer() {
61 return tls_ppapi_globals_for_test.Pointer()->Get(); 61 return tls_ppapi_globals_for_test.Pointer()->Get();
62 } 62 }
63 63
64 } // namespace ppapi 64 } // namespace ppapi
OLDNEW
« ppapi/shared_impl/ppapi_globals.h ('K') | « ppapi/shared_impl/ppapi_globals.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698