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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() {} | 75 virtual ~MessagePumpForUIStub() {} |
76 | 76 |
77 virtual void Start(base::MessagePump::Delegate* delegate) OVERRIDE { | 77 void Start(base::MessagePump::Delegate* delegate) override { |
78 NOTREACHED() << "The Start() method shouldn't be called in test, using" | 78 NOTREACHED() << "The Start() method shouldn't be called in test, using" |
79 " Run() method should be used."; | 79 " Run() method should be used."; |
80 } | 80 } |
81 | 81 |
82 virtual void Run(base::MessagePump::Delegate* delegate) OVERRIDE { | 82 void Run(base::MessagePump::Delegate* delegate) override { |
83 // 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 |
84 // WaitableEvent since there are no native message loop to use. | 84 // WaitableEvent since there are no native message loop to use. |
85 RunState state(delegate, g_state ? g_state->run_depth + 1 : 1); | 85 RunState state(delegate, g_state ? g_state->run_depth + 1 : 1); |
86 | 86 |
87 RunState* previous_state = g_state; | 87 RunState* previous_state = g_state; |
88 g_state = &state; | 88 g_state = &state; |
89 | 89 |
90 bool more_work_is_plausible = true; | 90 bool more_work_is_plausible = true; |
91 | 91 |
92 for (;;) { | 92 for (;;) { |
(...skipping 19 matching lines...) Expand all Loading... |
112 more_work_is_plausible = g_state->delegate->DoIdleWork(); | 112 more_work_is_plausible = g_state->delegate->DoIdleWork(); |
113 if (g_state->should_quit) | 113 if (g_state->should_quit) |
114 break; | 114 break; |
115 | 115 |
116 more_work_is_plausible |= !delayed_work_time.is_null(); | 116 more_work_is_plausible |= !delayed_work_time.is_null(); |
117 } | 117 } |
118 | 118 |
119 g_state = previous_state; | 119 g_state = previous_state; |
120 } | 120 } |
121 | 121 |
122 virtual void Quit() OVERRIDE { | 122 void Quit() override { Waitable::GetInstance()->Quit(); } |
123 Waitable::GetInstance()->Quit(); | |
124 } | |
125 | 123 |
126 virtual void ScheduleWork() OVERRIDE { | 124 void ScheduleWork() override { Waitable::GetInstance()->Signal(); } |
127 Waitable::GetInstance()->Signal(); | |
128 } | |
129 | 125 |
130 virtual void ScheduleDelayedWork( | 126 void ScheduleDelayedWork(const base::TimeTicks& delayed_work_time) override { |
131 const base::TimeTicks& delayed_work_time) OVERRIDE { | |
132 Waitable::GetInstance()->Signal(); | 127 Waitable::GetInstance()->Signal(); |
133 } | 128 } |
134 }; | 129 }; |
135 | 130 |
136 scoped_ptr<base::MessagePump> CreateMessagePumpForUIStub() { | 131 scoped_ptr<base::MessagePump> CreateMessagePumpForUIStub() { |
137 return scoped_ptr<base::MessagePump>(new MessagePumpForUIStub()); | 132 return scoped_ptr<base::MessagePump>(new MessagePumpForUIStub()); |
138 }; | 133 }; |
139 | 134 |
140 // Provides the test path for DIR_MODULE and DIR_ANDROID_APP_DATA. | 135 // Provides the test path for DIR_MODULE and DIR_ANDROID_APP_DATA. |
141 bool GetTestProviderPath(int key, base::FilePath* result) { | 136 bool GetTestProviderPath(int key, base::FilePath* result) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 if (!MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIStub)) | 175 if (!MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIStub)) |
181 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override."; | 176 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override."; |
182 } | 177 } |
183 | 178 |
184 void InitAndroidTest() { | 179 void InitAndroidTest() { |
185 InitAndroidTestLogging(); | 180 InitAndroidTestLogging(); |
186 InitAndroidTestPaths(); | 181 InitAndroidTestPaths(); |
187 InitAndroidTestMessageLoop(); | 182 InitAndroidTestMessageLoop(); |
188 } | 183 } |
189 } // namespace base | 184 } // namespace base |
OLD | NEW |