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