| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
| 12 #include "base/stats_table.h" | 12 #include "base/stats_table.h" |
| 13 #include "chrome/common/app_cache/app_cache_context_impl.h" |
| 14 #include "chrome/common/app_cache/app_cache_dispatcher.h" |
| 13 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/render_messages.h" |
| 15 #include "chrome/common/notification_service.h" | 17 #include "chrome/common/notification_service.h" |
| 16 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/plugin/npobject_util.h" | 19 #include "chrome/plugin/npobject_util.h" |
| 18 // TODO(port) | 20 // TODO(port) |
| 19 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 20 #include "chrome/plugin/plugin_channel.h" | 22 #include "chrome/plugin/plugin_channel.h" |
| 21 #else | 23 #else |
| 22 #include "base/scoped_handle.h" | 24 #include "base/scoped_handle.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 86 } |
| 85 | 87 |
| 86 void RenderThread::Resolve(const char* name, size_t length) { | 88 void RenderThread::Resolve(const char* name, size_t length) { |
| 87 return dns_master_->Resolve(name, length); | 89 return dns_master_->Resolve(name, length); |
| 88 } | 90 } |
| 89 | 91 |
| 90 void RenderThread::SendHistograms() { | 92 void RenderThread::SendHistograms() { |
| 91 return histogram_snapshots_->SendHistograms(); | 93 return histogram_snapshots_->SendHistograms(); |
| 92 } | 94 } |
| 93 | 95 |
| 96 static WebAppCacheContext* CreateAppCacheContextForRenderer() { |
| 97 return new AppCacheContextImpl(RenderThread::current()); |
| 98 } |
| 99 |
| 94 void RenderThread::Init() { | 100 void RenderThread::Init() { |
| 95 // TODO(darin): Why do we need COM here? This is probably bogus. | 101 // TODO(darin): Why do we need COM here? This is probably bogus. Perhaps |
| 102 // this is for InProcessPlugin support? |
| 96 #if defined(OS_WIN) | 103 #if defined(OS_WIN) |
| 97 // The renderer thread should wind-up COM. | 104 // The renderer thread should wind-up COM. |
| 98 CoInitialize(0); | 105 CoInitialize(0); |
| 99 #endif | 106 #endif |
| 100 | 107 |
| 101 ChildThread::Init(); | 108 ChildThread::Init(); |
| 102 notification_service_.reset(new NotificationService); | 109 notification_service_.reset(new NotificationService); |
| 103 cache_stats_factory_.reset( | 110 cache_stats_factory_.reset( |
| 104 new ScopedRunnableMethodFactory<RenderThread>(this)); | 111 new ScopedRunnableMethodFactory<RenderThread>(this)); |
| 105 | 112 |
| 106 visited_link_slave_.reset(new VisitedLinkSlave()); | 113 visited_link_slave_.reset(new VisitedLinkSlave()); |
| 107 user_script_slave_.reset(new UserScriptSlave()); | 114 user_script_slave_.reset(new UserScriptSlave()); |
| 108 dns_master_.reset(new RenderDnsMaster()); | 115 dns_master_.reset(new RenderDnsMaster()); |
| 109 histogram_snapshots_.reset(new RendererHistogramSnapshots()); | 116 histogram_snapshots_.reset(new RendererHistogramSnapshots()); |
| 117 app_cache_dispatcher_.reset(new AppCacheDispatcher()); |
| 118 WebAppCacheContext::SetFactory(CreateAppCacheContextForRenderer); |
| 110 } | 119 } |
| 111 | 120 |
| 112 void RenderThread::CleanUp() { | 121 void RenderThread::CleanUp() { |
| 113 // Shutdown in reverse of the initialization order. | 122 // Shutdown in reverse of the initialization order. |
| 114 | 123 |
| 124 WebAppCacheContext::SetFactory(NULL); |
| 125 app_cache_dispatcher_.reset(); |
| 115 histogram_snapshots_.reset(); | 126 histogram_snapshots_.reset(); |
| 116 dns_master_.reset(); | 127 dns_master_.reset(); |
| 117 user_script_slave_.reset(); | 128 user_script_slave_.reset(); |
| 118 visited_link_slave_.reset(); | 129 visited_link_slave_.reset(); |
| 119 | 130 |
| 120 if (webkit_client_.get()) { | 131 if (webkit_client_.get()) { |
| 121 WebKit::shutdown(); | 132 WebKit::shutdown(); |
| 122 webkit_client_.reset(); | 133 webkit_client_.reset(); |
| 123 } | 134 } |
| 124 | 135 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 147 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; | 158 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; |
| 148 user_script_slave_->UpdateScripts(scripts); | 159 user_script_slave_->UpdateScripts(scripts); |
| 149 } | 160 } |
| 150 | 161 |
| 151 void RenderThread::OnSetExtensionFunctionNames( | 162 void RenderThread::OnSetExtensionFunctionNames( |
| 152 const std::vector<std::string>& names) { | 163 const std::vector<std::string>& names) { |
| 153 extensions_v8::ExtensionProcessBindings::SetFunctionNames(names); | 164 extensions_v8::ExtensionProcessBindings::SetFunctionNames(names); |
| 154 } | 165 } |
| 155 | 166 |
| 156 void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { | 167 void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { |
| 168 // App cache messages are handled by a delegate. |
| 169 if (app_cache_dispatcher_->OnMessageReceived(msg)) |
| 170 return; |
| 171 |
| 157 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) | 172 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) |
| 158 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) | 173 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) |
| 159 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) | 174 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) |
| 160 // TODO(port): removed from render_messages_internal.h; | 175 // TODO(port): removed from render_messages_internal.h; |
| 161 // is there a new non-windows message I should add here? | 176 // is there a new non-windows message I should add here? |
| 162 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) | 177 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) |
| 163 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) | 178 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) |
| 164 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, | 179 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, |
| 165 OnGetRendererHistograms) | 180 OnGetRendererHistograms) |
| 166 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, | 181 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } | 304 } |
| 290 | 305 |
| 291 void RenderThread::OnExtensionHandleConnect(int port_id) { | 306 void RenderThread::OnExtensionHandleConnect(int port_id) { |
| 292 extensions_v8::RendererExtensionBindings::HandleConnect(port_id); | 307 extensions_v8::RendererExtensionBindings::HandleConnect(port_id); |
| 293 } | 308 } |
| 294 | 309 |
| 295 void RenderThread::OnExtensionHandleMessage(const std::string& message, | 310 void RenderThread::OnExtensionHandleMessage(const std::string& message, |
| 296 int port_id) { | 311 int port_id) { |
| 297 extensions_v8::RendererExtensionBindings::HandleMessage(message, port_id); | 312 extensions_v8::RendererExtensionBindings::HandleMessage(message, port_id); |
| 298 } | 313 } |
| OLD | NEW |