| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <objbase.h> | 9 #include <objbase.h> |
| 10 #endif | 10 #endif |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 user_script_slave_(NULL), | 52 user_script_slave_(NULL), |
| 53 render_dns_master_(NULL) { | 53 render_dns_master_(NULL) { |
| 54 } | 54 } |
| 55 | 55 |
| 56 RenderThread::RenderThread(const std::wstring& channel_name) | 56 RenderThread::RenderThread(const std::wstring& channel_name) |
| 57 : ChildThread( | 57 : ChildThread( |
| 58 base::Thread::Options(RenderProcess::InProcessPlugins() ? | 58 base::Thread::Options(RenderProcess::InProcessPlugins() ? |
| 59 MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kStackSize)), | 59 MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kStackSize)), |
| 60 visited_link_slave_(NULL), | 60 visited_link_slave_(NULL), |
| 61 user_script_slave_(NULL), | 61 user_script_slave_(NULL), |
| 62 render_dns_master_(NULL) { | 62 render_dns_master_(NULL), |
| 63 renderer_histogram_snapshots_(NULL) { |
| 63 SetChannelName(channel_name); | 64 SetChannelName(channel_name); |
| 64 } | 65 } |
| 65 | 66 |
| 66 RenderThread::~RenderThread() { | 67 RenderThread::~RenderThread() { |
| 67 } | 68 } |
| 68 | 69 |
| 69 RenderThread* RenderThread::current() { | 70 RenderThread* RenderThread::current() { |
| 70 DCHECK(!IsPluginProcess()); | 71 DCHECK(!IsPluginProcess()); |
| 71 return static_cast<RenderThread*>(ChildThread::current()); | 72 return static_cast<RenderThread*>(ChildThread::current()); |
| 72 } | 73 } |
| 73 | 74 |
| 74 void RenderThread::AddFilter(IPC::ChannelProxy::MessageFilter* filter) { | 75 void RenderThread::AddFilter(IPC::ChannelProxy::MessageFilter* filter) { |
| 75 channel()->AddFilter(filter); | 76 channel()->AddFilter(filter); |
| 76 } | 77 } |
| 77 | 78 |
| 78 void RenderThread::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) { | 79 void RenderThread::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) { |
| 79 channel()->RemoveFilter(filter); | 80 channel()->RemoveFilter(filter); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void RenderThread::Resolve(const char* name, size_t length) { | 83 void RenderThread::Resolve(const char* name, size_t length) { |
| 83 return render_dns_master_->Resolve(name, length); | 84 return render_dns_master_->Resolve(name, length); |
| 84 } | 85 } |
| 85 | 86 |
| 87 void RenderThread::SendHistograms() { |
| 88 return renderer_histogram_snapshots_->SendHistograms(); |
| 89 } |
| 90 |
| 86 void RenderThread::Init() { | 91 void RenderThread::Init() { |
| 87 ChildThread::Init(); | 92 ChildThread::Init(); |
| 88 notification_service_.reset(new NotificationService); | 93 notification_service_.reset(new NotificationService); |
| 89 cache_stats_factory_.reset( | 94 cache_stats_factory_.reset( |
| 90 new ScopedRunnableMethodFactory<RenderThread>(this)); | 95 new ScopedRunnableMethodFactory<RenderThread>(this)); |
| 91 | 96 |
| 92 #if defined(OS_WIN) | 97 #if defined(OS_WIN) |
| 93 // The renderer thread should wind-up COM. | 98 // The renderer thread should wind-up COM. |
| 94 CoInitialize(0); | 99 CoInitialize(0); |
| 95 #endif | 100 #endif |
| 96 | 101 |
| 97 visited_link_slave_ = new VisitedLinkSlave(); | 102 visited_link_slave_ = new VisitedLinkSlave(); |
| 98 user_script_slave_ = new UserScriptSlave(); | 103 user_script_slave_ = new UserScriptSlave(); |
| 99 render_dns_master_.reset(new RenderDnsMaster()); | 104 render_dns_master_.reset(new RenderDnsMaster()); |
| 105 renderer_histogram_snapshots_.reset(new RendererHistogramSnapshots()); |
| 100 } | 106 } |
| 101 | 107 |
| 102 void RenderThread::CleanUp() { | 108 void RenderThread::CleanUp() { |
| 103 ChildThread::CleanUp(); | 109 ChildThread::CleanUp(); |
| 104 | 110 |
| 105 // TODO(port) | 111 // TODO(port) |
| 106 #if defined(OS_WIN) | 112 #if defined(OS_WIN) |
| 107 // Clean up plugin channels before this thread goes away. | 113 // Clean up plugin channels before this thread goes away. |
| 108 PluginChannelBase::CleanupChannels(); | 114 PluginChannelBase::CleanupChannels(); |
| 109 #endif | 115 #endif |
| (...skipping 23 matching lines...) Expand all Loading... |
| 133 } | 139 } |
| 134 | 140 |
| 135 void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { | 141 void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { |
| 136 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) | 142 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) |
| 137 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) | 143 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) |
| 138 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) | 144 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) |
| 139 // TODO(port): removed from render_messages_internal.h; | 145 // TODO(port): removed from render_messages_internal.h; |
| 140 // is there a new non-windows message I should add here? | 146 // is there a new non-windows message I should add here? |
| 141 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) | 147 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) |
| 142 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) | 148 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) |
| 149 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, |
| 150 OnGetRendererHistograms) |
| 143 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, | 151 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, |
| 144 OnGetCacheResourceStats) | 152 OnGetCacheResourceStats) |
| 145 IPC_MESSAGE_HANDLER(ViewMsg_PluginMessage, OnPluginMessage) | 153 IPC_MESSAGE_HANDLER(ViewMsg_PluginMessage, OnPluginMessage) |
| 146 IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_NewScripts, | 154 IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_NewScripts, |
| 147 OnUpdateUserScripts) | 155 OnUpdateUserScripts) |
| 148 IPC_END_MESSAGE_MAP() | 156 IPC_END_MESSAGE_MAP() |
| 149 } | 157 } |
| 150 | 158 |
| 151 void RenderThread::OnPluginMessage(const FilePath& plugin_path, | 159 void RenderThread::OnPluginMessage(const FilePath& plugin_path, |
| 152 const std::vector<uint8>& data) { | 160 const std::vector<uint8>& data) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 #if defined(OS_WIN) || defined(OS_LINUX) | 213 #if defined(OS_WIN) || defined(OS_LINUX) |
| 206 CacheManager::ResourceTypeStats stats; | 214 CacheManager::ResourceTypeStats stats; |
| 207 CacheManager::GetResourceTypeStats(&stats); | 215 CacheManager::GetResourceTypeStats(&stats); |
| 208 Send(new ViewHostMsg_ResourceTypeStats(stats)); | 216 Send(new ViewHostMsg_ResourceTypeStats(stats)); |
| 209 #else | 217 #else |
| 210 // TODO(port) | 218 // TODO(port) |
| 211 NOTIMPLEMENTED(); | 219 NOTIMPLEMENTED(); |
| 212 #endif | 220 #endif |
| 213 } | 221 } |
| 214 | 222 |
| 223 void RenderThread::OnGetRendererHistograms() { |
| 224 SendHistograms(); |
| 225 } |
| 226 |
| 215 void RenderThread::InformHostOfCacheStats() { | 227 void RenderThread::InformHostOfCacheStats() { |
| 216 #if defined(OS_WIN) || defined(OS_LINUX) | 228 #if defined(OS_WIN) || defined(OS_LINUX) |
| 217 CacheManager::UsageStats stats; | 229 CacheManager::UsageStats stats; |
| 218 CacheManager::GetUsageStats(&stats); | 230 CacheManager::GetUsageStats(&stats); |
| 219 Send(new ViewHostMsg_UpdatedCacheStats(stats)); | 231 Send(new ViewHostMsg_UpdatedCacheStats(stats)); |
| 220 #else | 232 #else |
| 221 // TODO(port) | 233 // TODO(port) |
| 222 NOTIMPLEMENTED(); | 234 NOTIMPLEMENTED(); |
| 223 #endif | 235 #endif |
| 224 } | 236 } |
| 225 | 237 |
| 226 void RenderThread::InformHostOfCacheStatsLater() { | 238 void RenderThread::InformHostOfCacheStatsLater() { |
| 227 // Rate limit informing the host of our cache stats. | 239 // Rate limit informing the host of our cache stats. |
| 228 if (!cache_stats_factory_->empty()) | 240 if (!cache_stats_factory_->empty()) |
| 229 return; | 241 return; |
| 230 | 242 |
| 231 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 243 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 232 cache_stats_factory_->NewRunnableMethod( | 244 cache_stats_factory_->NewRunnableMethod( |
| 233 &RenderThread::InformHostOfCacheStats), | 245 &RenderThread::InformHostOfCacheStats), |
| 234 kCacheStatsDelayMS); | 246 kCacheStatsDelayMS); |
| 235 } | 247 } |
| OLD | NEW |