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 "content/child/blink_platform_impl.h" | 5 #include "content/child/blink_platform_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "base/sys_info.h" | 27 #include "base/sys_info.h" |
28 #include "base/thread_task_runner_handle.h" | 28 #include "base/thread_task_runner_handle.h" |
29 #include "base/threading/platform_thread.h" | 29 #include "base/threading/platform_thread.h" |
30 #include "base/time/time.h" | 30 #include "base/time/time.h" |
31 #include "base/trace_event/memory_allocator_dump_guid.h" | 31 #include "base/trace_event/memory_allocator_dump_guid.h" |
32 #include "base/trace_event/memory_dump_manager.h" | 32 #include "base/trace_event/memory_dump_manager.h" |
33 #include "base/trace_event/trace_event.h" | 33 #include "base/trace_event/trace_event.h" |
34 #include "blink/public/resources/grit/blink_image_resources.h" | 34 #include "blink/public/resources/grit/blink_image_resources.h" |
35 #include "blink/public/resources/grit/blink_resources.h" | 35 #include "blink/public/resources/grit/blink_resources.h" |
36 #include "components/mime_util/mime_util.h" | 36 #include "components/mime_util/mime_util.h" |
| 37 #include "components/scheduler/child/web_task_runner_impl.h" |
37 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" | 38 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" |
38 #include "content/app/resources/grit/content_resources.h" | 39 #include "content/app/resources/grit/content_resources.h" |
39 #include "content/app/strings/grit/content_strings.h" | 40 #include "content/app/strings/grit/content_strings.h" |
40 #include "content/child/background_sync/background_sync_provider.h" | 41 #include "content/child/background_sync/background_sync_provider.h" |
41 #include "content/child/background_sync/background_sync_provider_thread_proxy.h" | 42 #include "content/child/background_sync/background_sync_provider_thread_proxy.h" |
42 #include "content/child/child_thread_impl.h" | 43 #include "content/child/child_thread_impl.h" |
43 #include "content/child/content_child_helpers.h" | 44 #include "content/child/content_child_helpers.h" |
44 #include "content/child/geofencing/web_geofencing_provider_impl.h" | 45 #include "content/child/geofencing/web_geofencing_provider_impl.h" |
45 #include "content/child/navigator_connect/service_port_provider.h" | 46 #include "content/child/navigator_connect/service_port_provider.h" |
46 #include "content/child/notifications/notification_dispatcher.h" | 47 #include "content/child/notifications/notification_dispatcher.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 | 472 |
472 BlinkPlatformImpl::~BlinkPlatformImpl() { | 473 BlinkPlatformImpl::~BlinkPlatformImpl() { |
473 } | 474 } |
474 | 475 |
475 WebURLLoader* BlinkPlatformImpl::createURLLoader() { | 476 WebURLLoader* BlinkPlatformImpl::createURLLoader() { |
476 ChildThreadImpl* child_thread = ChildThreadImpl::current(); | 477 ChildThreadImpl* child_thread = ChildThreadImpl::current(); |
477 // There may be no child thread in RenderViewTests. These tests can still use | 478 // There may be no child thread in RenderViewTests. These tests can still use |
478 // data URLs to bypass the ResourceDispatcher. | 479 // data URLs to bypass the ResourceDispatcher. |
479 return new WebURLLoaderImpl( | 480 return new WebURLLoaderImpl( |
480 child_thread ? child_thread->resource_dispatcher() : NULL, | 481 child_thread ? child_thread->resource_dispatcher() : NULL, |
481 MainTaskRunnerForCurrentThread()); | 482 make_scoped_ptr(new scheduler::WebTaskRunnerImpl( |
| 483 base::ThreadTaskRunnerHandle::Get()))); |
482 } | 484 } |
483 | 485 |
484 blink::WebSocketHandle* BlinkPlatformImpl::createWebSocketHandle() { | 486 blink::WebSocketHandle* BlinkPlatformImpl::createWebSocketHandle() { |
485 return new WebSocketBridge; | 487 return new WebSocketBridge; |
486 } | 488 } |
487 | 489 |
488 WebString BlinkPlatformImpl::userAgent() { | 490 WebString BlinkPlatformImpl::userAgent() { |
489 return WebString::fromUTF8(GetContentClient()->GetUserAgent()); | 491 return WebString::fromUTF8(GetContentClient()->GetUserAgent()); |
490 } | 492 } |
491 | 493 |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 return noDecodedImageByteLimit; | 1358 return noDecodedImageByteLimit; |
1357 #endif | 1359 #endif |
1358 } | 1360 } |
1359 | 1361 |
1360 uint32_t BlinkPlatformImpl::getUniqueIdForProcess() { | 1362 uint32_t BlinkPlatformImpl::getUniqueIdForProcess() { |
1361 // TODO(rickyz): Replace this with base::GetUniqueIdForProcess when that's | 1363 // TODO(rickyz): Replace this with base::GetUniqueIdForProcess when that's |
1362 // ready. | 1364 // ready. |
1363 return base::trace_event::TraceLog::GetInstance()->process_id(); | 1365 return base::trace_event::TraceLog::GetInstance()->process_id(); |
1364 } | 1366 } |
1365 | 1367 |
1366 scoped_refptr<base::SingleThreadTaskRunner> | |
1367 BlinkPlatformImpl::MainTaskRunnerForCurrentThread() { | |
1368 if (main_thread_task_runner_.get() && | |
1369 main_thread_task_runner_->BelongsToCurrentThread()) { | |
1370 return main_thread_task_runner_; | |
1371 } else { | |
1372 return base::ThreadTaskRunnerHandle::Get(); | |
1373 } | |
1374 } | |
1375 | |
1376 bool BlinkPlatformImpl::IsMainThread() const { | 1368 bool BlinkPlatformImpl::IsMainThread() const { |
1377 return main_thread_task_runner_.get() && | 1369 return main_thread_task_runner_.get() && |
1378 main_thread_task_runner_->BelongsToCurrentThread(); | 1370 main_thread_task_runner_->BelongsToCurrentThread(); |
1379 } | 1371 } |
1380 | 1372 |
1381 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { | 1373 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { |
1382 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( | 1374 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( |
1383 static_cast<ui::DomCode>(dom_code))); | 1375 static_cast<ui::DomCode>(dom_code))); |
1384 } | 1376 } |
1385 | 1377 |
1386 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { | 1378 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { |
1387 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( | 1379 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( |
1388 code.utf8().data())); | 1380 code.utf8().data())); |
1389 } | 1381 } |
1390 | 1382 |
1391 WebString BlinkPlatformImpl::domKeyStringFromEnum(int dom_key) { | 1383 WebString BlinkPlatformImpl::domKeyStringFromEnum(int dom_key) { |
1392 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( | 1384 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( |
1393 static_cast<ui::DomKey>(dom_key))); | 1385 static_cast<ui::DomKey>(dom_key))); |
1394 } | 1386 } |
1395 | 1387 |
1396 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { | 1388 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { |
1397 return static_cast<int>( | 1389 return static_cast<int>( |
1398 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8().data())); | 1390 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8().data())); |
1399 } | 1391 } |
1400 | 1392 |
1401 } // namespace content | 1393 } // namespace content |
OLD | NEW |