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" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; | 55 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; |
56 | 56 |
57 //----------------------------------------------------------------------------- | 57 //----------------------------------------------------------------------------- |
58 // Methods below are only called on the owner's thread: | 58 // Methods below are only called on the owner's thread: |
59 | 59 |
60 // When we run plugins in process, we actually run them on the render thread, | 60 // When we run plugins in process, we actually run them on the render thread, |
61 // which means that we need to make the render thread pump UI events. | 61 // which means that we need to make the render thread pump UI events. |
62 RenderThread::RenderThread() | 62 RenderThread::RenderThread() |
63 : ChildThread( | 63 : ChildThread( |
64 base::Thread::Options(RenderProcess::InProcessPlugins() ? | 64 base::Thread::Options(RenderProcess::InProcessPlugins() ? |
65 MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kV8StackSize)) { | 65 MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kV8StackSize)), |
| 66 plugin_refresh_allowed_(true) { |
66 } | 67 } |
67 | 68 |
68 RenderThread::RenderThread(const std::wstring& channel_name) | 69 RenderThread::RenderThread(const std::wstring& channel_name) |
69 : ChildThread( | 70 : ChildThread( |
70 base::Thread::Options(RenderProcess::InProcessPlugins() ? | 71 base::Thread::Options(RenderProcess::InProcessPlugins() ? |
71 MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kV8StackSize)) { | 72 MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kV8StackSize)), |
| 73 plugin_refresh_allowed_(true) { |
72 SetChannelName(channel_name); | 74 SetChannelName(channel_name); |
73 } | 75 } |
74 | 76 |
75 RenderThread::~RenderThread() { | 77 RenderThread::~RenderThread() { |
76 } | 78 } |
77 | 79 |
78 RenderThread* RenderThread::current() { | 80 RenderThread* RenderThread::current() { |
79 DCHECK(!IsPluginProcess()); | 81 DCHECK(!IsPluginProcess()); |
80 return static_cast<RenderThread*>(ChildThread::current()); | 82 return static_cast<RenderThread*>(ChildThread::current()); |
81 } | 83 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // TODO(rafaelw): create an ExtensionDispatcher that handles extension | 192 // TODO(rafaelw): create an ExtensionDispatcher that handles extension |
191 // messages seperates their handling from the RenderThread. | 193 // messages seperates their handling from the RenderThread. |
192 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionHandleConnect, | 194 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionHandleConnect, |
193 OnExtensionHandleConnect) | 195 OnExtensionHandleConnect) |
194 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionHandleMessage, | 196 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionHandleMessage, |
195 OnExtensionHandleMessage) | 197 OnExtensionHandleMessage) |
196 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionHandleEvent, | 198 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionHandleEvent, |
197 OnExtensionHandleEvent) | 199 OnExtensionHandleEvent) |
198 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames, | 200 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames, |
199 OnSetExtensionFunctionNames) | 201 OnSetExtensionFunctionNames) |
| 202 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, |
| 203 OnPurgePluginListCache) |
200 IPC_END_MESSAGE_MAP() | 204 IPC_END_MESSAGE_MAP() |
201 } | 205 } |
202 | 206 |
203 void RenderThread::OnSetNextPageID(int32 next_page_id) { | 207 void RenderThread::OnSetNextPageID(int32 next_page_id) { |
204 // This should only be called at process initialization time, so we shouldn't | 208 // This should only be called at process initialization time, so we shouldn't |
205 // have to worry about thread-safety. | 209 // have to worry about thread-safety. |
206 RenderView::SetNextPageID(next_page_id); | 210 RenderView::SetNextPageID(next_page_id); |
207 } | 211 } |
208 | 212 |
209 void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd, | 213 void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 332 |
329 void RenderThread::OnExtensionHandleMessage(const std::string& message, | 333 void RenderThread::OnExtensionHandleMessage(const std::string& message, |
330 int port_id) { | 334 int port_id) { |
331 RendererExtensionBindings::HandleMessage(message, port_id); | 335 RendererExtensionBindings::HandleMessage(message, port_id); |
332 } | 336 } |
333 | 337 |
334 void RenderThread::OnExtensionHandleEvent(const std::string event_name, | 338 void RenderThread::OnExtensionHandleEvent(const std::string event_name, |
335 const std::string event_data) { | 339 const std::string event_data) { |
336 RendererExtensionBindings::HandleEvent(event_name, event_data); | 340 RendererExtensionBindings::HandleEvent(event_name, event_data); |
337 } | 341 } |
| 342 |
| 343 void RenderThread::OnPurgePluginListCache() { |
| 344 // The call below will cause a GetPlugins call with refresh=true, but at this |
| 345 // point we already know that the browser has refreshed its list, so disable |
| 346 // refresh temporarily to prevent each renderer process causing the list to be |
| 347 // regenerated. |
| 348 plugin_refresh_allowed_ = false; |
| 349 WebKit::resetPluginCache(); |
| 350 plugin_refresh_allowed_ = true; |
| 351 } |
OLD | NEW |