| OLD | NEW |
| 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 25 matching lines...) Expand all Loading... |
| 36 bool should_quit; | 36 bool should_quit; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 RunState* g_state = NULL; | 39 RunState* g_state = NULL; |
| 40 | 40 |
| 41 // A singleton WaitableEvent wrapper so we avoid a busy loop in | 41 // A singleton WaitableEvent wrapper so we avoid a busy loop in |
| 42 // MessagePumpForUIStub. Other platforms use the native event loop which blocks | 42 // MessagePumpForUIStub. Other platforms use the native event loop which blocks |
| 43 // when there are no pending messages. | 43 // when there are no pending messages. |
| 44 class Waitable { | 44 class Waitable { |
| 45 public: | 45 public: |
| 46 static Waitable* GetInstance() { return base::Singleton<Waitable>::get(); } | 46 static Waitable* GetInstance() { |
| 47 return base::Singleton<Waitable, |
| 48 base::LeakySingletonTraits<Waitable>>::get(); |
| 49 } |
| 47 | 50 |
| 48 // Signals that there are more work to do. | 51 // Signals that there are more work to do. |
| 49 void Signal() { | 52 void Signal() { waitable_event_.Signal(); } |
| 50 waitable_event_.Signal(); | |
| 51 } | |
| 52 | 53 |
| 53 // Blocks until more work is scheduled. | 54 // Blocks until more work is scheduled. |
| 54 void Block() { | 55 void Block() { waitable_event_.Wait(); } |
| 55 waitable_event_.Wait(); | |
| 56 } | |
| 57 | 56 |
| 58 void Quit() { | 57 void Quit() { |
| 59 g_state->should_quit = true; | 58 g_state->should_quit = true; |
| 60 Signal(); | 59 Signal(); |
| 61 } | 60 } |
| 62 | 61 |
| 63 private: | 62 private: |
| 64 friend struct base::DefaultSingletonTraits<Waitable>; | 63 friend struct base::DefaultSingletonTraits<Waitable>; |
| 65 | 64 |
| 66 Waitable() | 65 Waitable() |
| 67 : waitable_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 66 : waitable_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 68 base::WaitableEvent::InitialState::NOT_SIGNALED) {} | 67 base::WaitableEvent::InitialState::NOT_SIGNALED) {} |
| 69 | 68 |
| 70 base::WaitableEvent waitable_event_; | 69 base::WaitableEvent waitable_event_; |
| 71 | 70 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override."; | 185 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override."; |
| 187 } | 186 } |
| 188 | 187 |
| 189 void InitAndroidTest() { | 188 void InitAndroidTest() { |
| 190 if (!base::AndroidIsChildProcess()) { | 189 if (!base::AndroidIsChildProcess()) { |
| 191 InitAndroidTestLogging(); | 190 InitAndroidTestLogging(); |
| 192 } | 191 } |
| 193 InitAndroidTestMessageLoop(); | 192 InitAndroidTestMessageLoop(); |
| 194 } | 193 } |
| 195 } // namespace base | 194 } // namespace base |
| OLD | NEW |