OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/html_viewer/blink_platform_impl.h" | 5 #include "mojo/services/html_viewer/blink_platform_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/threading/platform_thread.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "mojo/public/cpp/application/application_impl.h" | 14 #include "mojo/public/cpp/application/application_impl.h" |
14 #include "mojo/services/html_viewer/webclipboard_impl.h" | 15 #include "mojo/services/html_viewer/webclipboard_impl.h" |
15 #include "mojo/services/html_viewer/webcookiejar_impl.h" | 16 #include "mojo/services/html_viewer/webcookiejar_impl.h" |
16 #include "mojo/services/html_viewer/websockethandle_impl.h" | 17 #include "mojo/services/html_viewer/websockethandle_impl.h" |
17 #include "mojo/services/html_viewer/webthread_impl.h" | 18 #include "mojo/services/html_viewer/webthread_impl.h" |
18 #include "mojo/services/html_viewer/weburlloader_impl.h" | 19 #include "mojo/services/html_viewer/weburlloader_impl.h" |
19 #include "net/base/data_url.h" | 20 #include "net/base/data_url.h" |
20 #include "net/base/mime_util.h" | 21 #include "net/base/mime_util.h" |
21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 scoped_refptr<base::MessageLoopProxy> message_loop = | 215 scoped_refptr<base::MessageLoopProxy> message_loop = |
215 base::MessageLoopProxy::current(); | 216 base::MessageLoopProxy::current(); |
216 if (!message_loop.get()) | 217 if (!message_loop.get()) |
217 return NULL; | 218 return NULL; |
218 | 219 |
219 thread = new WebThreadImplForMessageLoop(message_loop.get()); | 220 thread = new WebThreadImplForMessageLoop(message_loop.get()); |
220 current_thread_slot_.Set(thread); | 221 current_thread_slot_.Set(thread); |
221 return thread; | 222 return thread; |
222 } | 223 } |
223 | 224 |
| 225 void BlinkPlatformImpl::yieldCurrentThread() { |
| 226 base::PlatformThread::YieldCurrentThread(); |
| 227 } |
| 228 |
224 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent() { | 229 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent() { |
225 return new WebWaitableEventImpl(); | 230 return new WebWaitableEventImpl(); |
226 } | 231 } |
227 | 232 |
228 blink::WebWaitableEvent* BlinkPlatformImpl::waitMultipleEvents( | 233 blink::WebWaitableEvent* BlinkPlatformImpl::waitMultipleEvents( |
229 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { | 234 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { |
230 std::vector<base::WaitableEvent*> events; | 235 std::vector<base::WaitableEvent*> events; |
231 for (size_t i = 0; i < web_events.size(); ++i) | 236 for (size_t i = 0; i < web_events.size(); ++i) |
232 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); | 237 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); |
233 size_t idx = base::WaitableEvent::WaitMany( | 238 size_t idx = base::WaitableEvent::WaitMany( |
234 vector_as_array(&events), events.size()); | 239 vector_as_array(&events), events.size()); |
235 DCHECK_LT(idx, web_events.size()); | 240 DCHECK_LT(idx, web_events.size()); |
236 return web_events[idx]; | 241 return web_events[idx]; |
237 } | 242 } |
238 | 243 |
239 // static | 244 // static |
240 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { | 245 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { |
241 WebThreadImplForMessageLoop* impl = | 246 WebThreadImplForMessageLoop* impl = |
242 static_cast<WebThreadImplForMessageLoop*>(thread); | 247 static_cast<WebThreadImplForMessageLoop*>(thread); |
243 delete impl; | 248 delete impl; |
244 } | 249 } |
245 | 250 |
246 } // namespace mojo | 251 } // namespace mojo |
OLD | NEW |