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