| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 : waitable_event_(false, false) { | 65 : waitable_event_(false, false) { |
| 66 } | 66 } |
| 67 | 67 |
| 68 base::WaitableEvent waitable_event_; | 68 base::WaitableEvent waitable_event_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(Waitable); | 70 DISALLOW_COPY_AND_ASSIGN(Waitable); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 // The MessagePumpForUI implementation for test purpose. | 73 // The MessagePumpForUI implementation for test purpose. |
| 74 class MessagePumpForUIStub : public base::MessagePumpForUI { | 74 class MessagePumpForUIStub : public base::MessagePumpForUI { |
| 75 virtual ~MessagePumpForUIStub() {} | |
| 76 | |
| 77 virtual void Start(base::MessagePump::Delegate* delegate) OVERRIDE { | 75 virtual void Start(base::MessagePump::Delegate* delegate) OVERRIDE { |
| 78 NOTREACHED() << "The Start() method shouldn't be called in test, using" | 76 NOTREACHED() << "The Start() method shouldn't be called in test, using" |
| 79 " Run() method should be used."; | 77 " Run() method should be used."; |
| 80 } | 78 } |
| 81 | 79 |
| 82 virtual void Run(base::MessagePump::Delegate* delegate) OVERRIDE { | 80 virtual void Run(base::MessagePump::Delegate* delegate) OVERRIDE { |
| 83 // The following was based on message_pump_glib.cc, except we're using a | 81 // The following was based on message_pump_glib.cc, except we're using a |
| 84 // WaitableEvent since there are no native message loop to use. | 82 // WaitableEvent since there are no native message loop to use. |
| 85 RunState state(delegate, g_state ? g_state->run_depth + 1 : 1); | 83 RunState state(delegate, g_state ? g_state->run_depth + 1 : 1); |
| 86 | 84 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 122 } |
| 125 | 123 |
| 126 virtual void ScheduleWork() OVERRIDE { | 124 virtual void ScheduleWork() OVERRIDE { |
| 127 Waitable::GetInstance()->Signal(); | 125 Waitable::GetInstance()->Signal(); |
| 128 } | 126 } |
| 129 | 127 |
| 130 virtual void ScheduleDelayedWork( | 128 virtual void ScheduleDelayedWork( |
| 131 const base::TimeTicks& delayed_work_time) OVERRIDE { | 129 const base::TimeTicks& delayed_work_time) OVERRIDE { |
| 132 Waitable::GetInstance()->Signal(); | 130 Waitable::GetInstance()->Signal(); |
| 133 } | 131 } |
| 132 |
| 133 protected: |
| 134 virtual ~MessagePumpForUIStub() {} |
| 134 }; | 135 }; |
| 135 | 136 |
| 136 base::MessagePump* CreateMessagePumpForUIStub() { | 137 base::MessagePump* CreateMessagePumpForUIStub() { |
| 137 return new MessagePumpForUIStub(); | 138 return new MessagePumpForUIStub(); |
| 138 }; | 139 }; |
| 139 | 140 |
| 140 // Provides the test path for DIR_MODULE and DIR_ANDROID_APP_DATA. | 141 // Provides the test path for DIR_MODULE and DIR_ANDROID_APP_DATA. |
| 141 bool GetTestProviderPath(int key, base::FilePath* result) { | 142 bool GetTestProviderPath(int key, base::FilePath* result) { |
| 142 switch (key) { | 143 switch (key) { |
| 143 case base::DIR_MODULE: { | 144 case base::DIR_MODULE: { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 if (!MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIStub)) | 184 if (!MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIStub)) |
| 184 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override."; | 185 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override."; |
| 185 } | 186 } |
| 186 | 187 |
| 187 void InitAndroidTest() { | 188 void InitAndroidTest() { |
| 188 InitAndroidTestLogging(); | 189 InitAndroidTestLogging(); |
| 189 InitAndroidTestPaths(); | 190 InitAndroidTestPaths(); |
| 190 InitAndroidTestMessageLoop(); | 191 InitAndroidTestMessageLoop(); |
| 191 } | 192 } |
| 192 } // namespace base | 193 } // namespace base |
| OLD | NEW |