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