| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/render_thread.h" | 5 #include "content/renderer/render_thread.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "ipc/ipc_channel_handle.h" | 49 #include "ipc/ipc_channel_handle.h" |
| 50 #include "ipc/ipc_platform_file.h" | 50 #include "ipc/ipc_platform_file.h" |
| 51 #include "net/base/net_errors.h" | 51 #include "net/base/net_errors.h" |
| 52 #include "net/base/net_util.h" | 52 #include "net/base/net_util.h" |
| 53 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" | 53 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" |
| 54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebColor.h" | 54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebColor.h" |
| 55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" | 55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" |
| 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 58 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 58 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 59 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi
er.h" |
| 59 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
| 60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h
" | 61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h
" |
| 61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageEventDispat
cher.h" | 62 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageEventDispat
cher.h" |
| 62 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 64 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 64 #include "v8/include/v8.h" | 65 #include "v8/include/v8.h" |
| 65 #include "webkit/extensions/v8/benchmarking_extension.h" | 66 #include "webkit/extensions/v8/benchmarking_extension.h" |
| 66 #include "webkit/extensions/v8/playback_extension.h" | 67 #include "webkit/extensions/v8/playback_extension.h" |
| 67 #include "webkit/glue/webkit_glue.h" | 68 #include "webkit/glue/webkit_glue.h" |
| 68 | 69 |
| 69 // TODO(port) | 70 // TODO(port) |
| 70 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
| 71 #include "content/plugin/plugin_channel.h" | 72 #include "content/plugin/plugin_channel.h" |
| 72 #else | 73 #else |
| 73 #include "base/memory/scoped_handle.h" | 74 #include "base/memory/scoped_handle.h" |
| 74 #include "content/plugin/plugin_channel_base.h" | 75 #include "content/plugin/plugin_channel_base.h" |
| 75 #endif | 76 #endif |
| 76 | 77 |
| 77 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
| 78 #include <windows.h> | 79 #include <windows.h> |
| 79 #include <objbase.h> | 80 #include <objbase.h> |
| 80 #endif | 81 #endif |
| 81 | 82 |
| 82 #if defined(OS_POSIX) | 83 #if defined(OS_POSIX) |
| 83 #include "ipc/ipc_channel_posix.h" | 84 #include "ipc/ipc_channel_posix.h" |
| 84 #endif | 85 #endif |
| 85 | 86 |
| 86 using WebKit::WebDocument; | 87 using WebKit::WebDocument; |
| 87 using WebKit::WebFrame; | 88 using WebKit::WebFrame; |
| 89 using WebKit::WebNetworkStateNotifier; |
| 88 using WebKit::WebRuntimeFeatures; | 90 using WebKit::WebRuntimeFeatures; |
| 89 using WebKit::WebScriptController; | 91 using WebKit::WebScriptController; |
| 90 using WebKit::WebString; | 92 using WebKit::WebString; |
| 91 using WebKit::WebStorageEventDispatcher; | 93 using WebKit::WebStorageEventDispatcher; |
| 92 using WebKit::WebView; | 94 using WebKit::WebView; |
| 93 | 95 |
| 94 namespace { | 96 namespace { |
| 95 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; | 97 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; |
| 96 | 98 |
| 97 // Keep the global RenderThread in a TLS slot so it is impossible to access | 99 // Keep the global RenderThread in a TLS slot so it is impossible to access |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 bool handled = true; | 392 bool handled = true; |
| 391 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) | 393 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) |
| 392 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, | 394 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, |
| 393 OnSetZoomLevelForCurrentURL) | 395 OnSetZoomLevelForCurrentURL) |
| 394 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) | 396 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) |
| 395 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) | 397 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) |
| 396 // TODO(port): removed from render_messages_internal.h; | 398 // TODO(port): removed from render_messages_internal.h; |
| 397 // is there a new non-windows message I should add here? | 399 // is there a new non-windows message I should add here? |
| 398 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) | 400 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) |
| 399 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) | 401 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) |
| 402 IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged) |
| 400 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent) | 403 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent) |
| 401 IPC_MESSAGE_UNHANDLED(handled = false) | 404 IPC_MESSAGE_UNHANDLED(handled = false) |
| 402 IPC_END_MESSAGE_MAP() | 405 IPC_END_MESSAGE_MAP() |
| 403 return handled; | 406 return handled; |
| 404 } | 407 } |
| 405 | 408 |
| 406 void RenderThread::OnSetNextPageID(int32 next_page_id) { | 409 void RenderThread::OnSetNextPageID(int32 next_page_id) { |
| 407 // This should only be called at process initialization time, so we shouldn't | 410 // This should only be called at process initialization time, so we shouldn't |
| 408 // have to worry about thread-safety. | 411 // have to worry about thread-safety. |
| 409 RenderView::SetNextPageID(next_page_id); | 412 RenderView::SetNextPageID(next_page_id); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 EnsureWebKitInitialized(); | 668 EnsureWebKitInitialized(); |
| 666 // The call below will cause a GetPlugins call with refresh=true, but at this | 669 // The call below will cause a GetPlugins call with refresh=true, but at this |
| 667 // point we already know that the browser has refreshed its list, so disable | 670 // point we already know that the browser has refreshed its list, so disable |
| 668 // refresh temporarily to prevent each renderer process causing the list to be | 671 // refresh temporarily to prevent each renderer process causing the list to be |
| 669 // regenerated. | 672 // regenerated. |
| 670 plugin_refresh_allowed_ = false; | 673 plugin_refresh_allowed_ = false; |
| 671 WebKit::resetPluginCache(reload_pages); | 674 WebKit::resetPluginCache(reload_pages); |
| 672 plugin_refresh_allowed_ = true; | 675 plugin_refresh_allowed_ = true; |
| 673 } | 676 } |
| 674 | 677 |
| 678 void RenderThread::OnNetworkStateChanged(bool online) { |
| 679 EnsureWebKitInitialized(); |
| 680 WebNetworkStateNotifier::setOnLine(online); |
| 681 } |
| 682 |
| 675 scoped_refptr<base::MessageLoopProxy> | 683 scoped_refptr<base::MessageLoopProxy> |
| 676 RenderThread::GetFileThreadMessageLoopProxy() { | 684 RenderThread::GetFileThreadMessageLoopProxy() { |
| 677 DCHECK(message_loop() == MessageLoop::current()); | 685 DCHECK(message_loop() == MessageLoop::current()); |
| 678 if (!file_thread_.get()) { | 686 if (!file_thread_.get()) { |
| 679 file_thread_.reset(new base::Thread("Renderer::FILE")); | 687 file_thread_.reset(new base::Thread("Renderer::FILE")); |
| 680 file_thread_->Start(); | 688 file_thread_->Start(); |
| 681 } | 689 } |
| 682 return file_thread_->message_loop_proxy(); | 690 return file_thread_->message_loop_proxy(); |
| 683 } | 691 } |
| 684 | 692 |
| 685 void RenderThread::RegisterExtension(v8::Extension* extension) { | 693 void RenderThread::RegisterExtension(v8::Extension* extension) { |
| 686 WebScriptController::registerExtension(extension); | 694 WebScriptController::registerExtension(extension); |
| 687 v8_extensions_.insert(extension->name()); | 695 v8_extensions_.insert(extension->name()); |
| 688 } | 696 } |
| 689 | 697 |
| 690 bool RenderThread::IsRegisteredExtension( | 698 bool RenderThread::IsRegisteredExtension( |
| 691 const std::string& v8_extension_name) const { | 699 const std::string& v8_extension_name) const { |
| 692 return v8_extensions_.find(v8_extension_name) != v8_extensions_.end(); | 700 return v8_extensions_.find(v8_extension_name) != v8_extensions_.end(); |
| 693 } | 701 } |
| OLD | NEW |