| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/renderer/render_thread.h" | 5 #include "chrome/renderer/render_thread.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/nullable_string16.h" |
| 14 #include "base/shared_memory.h" | 15 #include "base/shared_memory.h" |
| 15 #include "base/stats_table.h" | 16 #include "base/stats_table.h" |
| 17 #include "base/string_util.h" |
| 16 #include "base/thread_local.h" | 18 #include "base/thread_local.h" |
| 17 #include "chrome/common/appcache/appcache_dispatcher.h" | 19 #include "chrome/common/appcache/appcache_dispatcher.h" |
| 18 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/db_message_filter.h" | 21 #include "chrome/common/db_message_filter.h" |
| 20 #include "chrome/common/render_messages.h" | 22 #include "chrome/common/render_messages.h" |
| 21 #include "chrome/common/renderer_preferences.h" | 23 #include "chrome/common/renderer_preferences.h" |
| 22 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/plugin/npobject_util.h" | 25 #include "chrome/plugin/npobject_util.h" |
| 24 // TODO(port) | 26 // TODO(port) |
| 25 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 38 #include "chrome/renderer/loadtimes_extension_bindings.h" | 40 #include "chrome/renderer/loadtimes_extension_bindings.h" |
| 39 #include "chrome/renderer/net/render_dns_master.h" | 41 #include "chrome/renderer/net/render_dns_master.h" |
| 40 #include "chrome/renderer/render_process.h" | 42 #include "chrome/renderer/render_process.h" |
| 41 #include "chrome/renderer/render_view.h" | 43 #include "chrome/renderer/render_view.h" |
| 42 #include "chrome/renderer/renderer_webkitclient_impl.h" | 44 #include "chrome/renderer/renderer_webkitclient_impl.h" |
| 43 #include "chrome/renderer/user_script_slave.h" | 45 #include "chrome/renderer/user_script_slave.h" |
| 44 #include "ipc/ipc_message.h" | 46 #include "ipc/ipc_message.h" |
| 45 #include "webkit/api/public/WebColor.h" | 47 #include "webkit/api/public/WebColor.h" |
| 46 #include "webkit/api/public/WebCache.h" | 48 #include "webkit/api/public/WebCache.h" |
| 47 #include "webkit/api/public/WebKit.h" | 49 #include "webkit/api/public/WebKit.h" |
| 50 #include "webkit/api/public/WebStorageEventDispatcher.h" |
| 48 #include "webkit/api/public/WebString.h" | 51 #include "webkit/api/public/WebString.h" |
| 49 #include "webkit/extensions/v8/benchmarking_extension.h" | 52 #include "webkit/extensions/v8/benchmarking_extension.h" |
| 50 #include "webkit/extensions/v8/gears_extension.h" | 53 #include "webkit/extensions/v8/gears_extension.h" |
| 51 #include "webkit/extensions/v8/interval_extension.h" | 54 #include "webkit/extensions/v8/interval_extension.h" |
| 52 #include "webkit/extensions/v8/playback_extension.h" | 55 #include "webkit/extensions/v8/playback_extension.h" |
| 53 #include "third_party/tcmalloc/tcmalloc/src/google/malloc_extension.h" | 56 #include "third_party/tcmalloc/tcmalloc/src/google/malloc_extension.h" |
| 54 | 57 |
| 55 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 56 #include <windows.h> | 59 #include <windows.h> |
| 57 #include <objbase.h> | 60 #include <objbase.h> |
| 58 #endif | 61 #endif |
| 59 | 62 |
| 60 using WebKit::WebCache; | 63 using WebKit::WebCache; |
| 61 using WebKit::WebString; | 64 using WebKit::WebString; |
| 65 using WebKit::WebStorageEventDispatcher; |
| 62 | 66 |
| 63 namespace { | 67 namespace { |
| 64 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; | 68 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; |
| 65 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; | 69 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; |
| 66 | 70 |
| 67 static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls( | 71 static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls( |
| 68 base::LINKER_INITIALIZED); | 72 base::LINKER_INITIALIZED); |
| 69 | 73 |
| 70 #if defined(OS_POSIX) | 74 #if defined(OS_POSIX) |
| 71 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter { | 75 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 const std::string& extension_id, | 237 const std::string& extension_id, |
| 234 const std::vector<std::string>& permissions) { | 238 const std::vector<std::string>& permissions) { |
| 235 ExtensionProcessBindings::SetAPIPermissions(extension_id, permissions); | 239 ExtensionProcessBindings::SetAPIPermissions(extension_id, permissions); |
| 236 } | 240 } |
| 237 | 241 |
| 238 void RenderThread::OnExtensionSetHostPermissions( | 242 void RenderThread::OnExtensionSetHostPermissions( |
| 239 const GURL& extension_url, const std::vector<URLPattern>& permissions) { | 243 const GURL& extension_url, const std::vector<URLPattern>& permissions) { |
| 240 ExtensionProcessBindings::SetHostPermissions(extension_url, permissions); | 244 ExtensionProcessBindings::SetHostPermissions(extension_url, permissions); |
| 241 } | 245 } |
| 242 | 246 |
| 247 void RenderThread::OnDOMStorageEvent(const string16& key, |
| 248 const NullableString16& old_value, const NullableString16& new_value, |
| 249 const string16& origin, DOMStorageType dom_storage_type) { |
| 250 if (!dom_storage_event_dispatcher_.get()) { |
| 251 dom_storage_event_dispatcher_.reset(WebStorageEventDispatcher::create()); |
| 252 } |
| 253 dom_storage_event_dispatcher_->dispatchStorageEvent(key, old_value, new_value, |
| 254 origin, dom_storage_type == DOM_STORAGE_LOCAL); |
| 255 } |
| 256 |
| 243 void RenderThread::OnExtensionSetL10nMessages( | 257 void RenderThread::OnExtensionSetL10nMessages( |
| 244 const std::string& extension_id, | 258 const std::string& extension_id, |
| 245 const std::map<std::string, std::string>& l10n_messages) { | 259 const std::map<std::string, std::string>& l10n_messages) { |
| 246 ExtensionProcessBindings::SetL10nMessages(extension_id, l10n_messages); | 260 ExtensionProcessBindings::SetL10nMessages(extension_id, l10n_messages); |
| 247 } | 261 } |
| 248 | 262 |
| 249 void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { | 263 void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { |
| 250 // App cache messages are handled by a delegate. | 264 // App cache messages are handled by a delegate. |
| 251 if (appcache_dispatcher_->OnMessageReceived(msg)) | 265 if (appcache_dispatcher_->OnMessageReceived(msg)) |
| 252 return; | 266 return; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 274 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames, | 288 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames, |
| 275 OnSetExtensionFunctionNames) | 289 OnSetExtensionFunctionNames) |
| 276 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, | 290 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, |
| 277 OnPurgePluginListCache) | 291 OnPurgePluginListCache) |
| 278 IPC_MESSAGE_HANDLER(ViewMsg_Extension_UpdatePageActions, | 292 IPC_MESSAGE_HANDLER(ViewMsg_Extension_UpdatePageActions, |
| 279 OnPageActionsUpdated) | 293 OnPageActionsUpdated) |
| 280 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetAPIPermissions, | 294 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetAPIPermissions, |
| 281 OnExtensionSetAPIPermissions) | 295 OnExtensionSetAPIPermissions) |
| 282 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetHostPermissions, | 296 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetHostPermissions, |
| 283 OnExtensionSetHostPermissions) | 297 OnExtensionSetHostPermissions) |
| 298 IPC_MESSAGE_HANDLER(ViewMsg_DOMStorageEvent, |
| 299 OnDOMStorageEvent) |
| 284 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetL10nMessages, | 300 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetL10nMessages, |
| 285 OnExtensionSetL10nMessages) | 301 OnExtensionSetL10nMessages) |
| 286 #if defined(IPC_MESSAGE_LOG_ENABLED) | 302 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 287 IPC_MESSAGE_HANDLER(ViewMsg_SetIPCLoggingEnabled, | 303 IPC_MESSAGE_HANDLER(ViewMsg_SetIPCLoggingEnabled, |
| 288 OnSetIPCLoggingEnabled) | 304 OnSetIPCLoggingEnabled) |
| 289 #endif | 305 #endif |
| 290 IPC_END_MESSAGE_MAP() | 306 IPC_END_MESSAGE_MAP() |
| 291 } | 307 } |
| 292 | 308 |
| 293 void RenderThread::OnSetNextPageID(int32 next_page_id) { | 309 void RenderThread::OnSetNextPageID(int32 next_page_id) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 514 |
| 499 void RenderThread::OnPurgePluginListCache(bool reload_pages) { | 515 void RenderThread::OnPurgePluginListCache(bool reload_pages) { |
| 500 // The call below will cause a GetPlugins call with refresh=true, but at this | 516 // The call below will cause a GetPlugins call with refresh=true, but at this |
| 501 // point we already know that the browser has refreshed its list, so disable | 517 // point we already know that the browser has refreshed its list, so disable |
| 502 // refresh temporarily to prevent each renderer process causing the list to be | 518 // refresh temporarily to prevent each renderer process causing the list to be |
| 503 // regenerated. | 519 // regenerated. |
| 504 plugin_refresh_allowed_ = false; | 520 plugin_refresh_allowed_ = false; |
| 505 WebKit::resetPluginCache(reload_pages); | 521 WebKit::resetPluginCache(reload_pages); |
| 506 plugin_refresh_allowed_ = true; | 522 plugin_refresh_allowed_ = true; |
| 507 } | 523 } |
| OLD | NEW |