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

Side by Side Diff: base/test/test_support_android.cc

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ToT Created 5 years, 3 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 | « base/memory/singleton_unittest.cc ('k') | base/threading/thread_id_name_manager.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) 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 <stdarg.h> 5 #include <stdarg.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "base/android/path_utils.h" 8 #include "base/android/path_utils.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 21 matching lines...) Expand all
32 bool should_quit; 32 bool should_quit;
33 }; 33 };
34 34
35 RunState* g_state = NULL; 35 RunState* g_state = NULL;
36 36
37 // A singleton WaitableEvent wrapper so we avoid a busy loop in 37 // A singleton WaitableEvent wrapper so we avoid a busy loop in
38 // MessagePumpForUIStub. Other platforms use the native event loop which blocks 38 // MessagePumpForUIStub. Other platforms use the native event loop which blocks
39 // when there are no pending messages. 39 // when there are no pending messages.
40 class Waitable { 40 class Waitable {
41 public: 41 public:
42 static Waitable* GetInstance() { 42 static Waitable* GetInstance() { return base::Singleton<Waitable>::get(); }
43 return Singleton<Waitable>::get();
44 }
45 43
46 // Signals that there are more work to do. 44 // Signals that there are more work to do.
47 void Signal() { 45 void Signal() {
48 waitable_event_.Signal(); 46 waitable_event_.Signal();
49 } 47 }
50 48
51 // Blocks until more work is scheduled. 49 // Blocks until more work is scheduled.
52 void Block() { 50 void Block() {
53 waitable_event_.Wait(); 51 waitable_event_.Wait();
54 } 52 }
55 53
56 void Quit() { 54 void Quit() {
57 g_state->should_quit = true; 55 g_state->should_quit = true;
58 Signal(); 56 Signal();
59 } 57 }
60 58
61 private: 59 private:
62 friend struct DefaultSingletonTraits<Waitable>; 60 friend struct base::DefaultSingletonTraits<Waitable>;
63 61
64 Waitable() 62 Waitable()
65 : waitable_event_(false, false) { 63 : waitable_event_(false, false) {
66 } 64 }
67 65
68 base::WaitableEvent waitable_event_; 66 base::WaitableEvent waitable_event_;
69 67
70 DISALLOW_COPY_AND_ASSIGN(Waitable); 68 DISALLOW_COPY_AND_ASSIGN(Waitable);
71 }; 69 };
72 70
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if (!MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIStub)) 173 if (!MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIStub))
176 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override."; 174 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override.";
177 } 175 }
178 176
179 void InitAndroidTest() { 177 void InitAndroidTest() {
180 InitAndroidTestLogging(); 178 InitAndroidTestLogging();
181 InitAndroidTestPaths(); 179 InitAndroidTestPaths();
182 InitAndroidTestMessageLoop(); 180 InitAndroidTestMessageLoop();
183 } 181 }
184 } // namespace base 182 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/singleton_unittest.cc ('k') | base/threading/thread_id_name_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698