| 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 21 matching lines...) Expand all  Loading... | 
| 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  Loading... | 
| 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 | 
| OLD | NEW | 
|---|