Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: chrome/renderer/render_thread.cc

Issue 17281: This is a rename of the term 'Greasemonkey' to 'user script' in Chromium. (Closed)
Patch Set: Fix indent Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/render_thread.h ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <windows.h> 5 #include <windows.h>
6 #include <algorithm> 6 #include <algorithm>
7 7
8 #include "chrome/renderer/render_thread.h" 8 #include "chrome/renderer/render_thread.h"
9 9
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
11 #include "chrome/common/chrome_plugin_lib.h" 11 #include "chrome/common/chrome_plugin_lib.h"
12 #include "chrome/common/ipc_logging.h" 12 #include "chrome/common/ipc_logging.h"
13 #include "chrome/common/notification_service.h" 13 #include "chrome/common/notification_service.h"
14 #include "chrome/plugin/plugin_channel.h" 14 #include "chrome/plugin/plugin_channel.h"
15 #include "chrome/renderer/net/render_dns_master.h" 15 #include "chrome/renderer/net/render_dns_master.h"
16 #include "chrome/renderer/greasemonkey_slave.h"
17 #include "chrome/renderer/render_process.h" 16 #include "chrome/renderer/render_process.h"
18 #include "chrome/renderer/render_view.h" 17 #include "chrome/renderer/render_view.h"
18 #include "chrome/renderer/user_script_slave.h"
19 #include "chrome/renderer/visitedlink_slave.h" 19 #include "chrome/renderer/visitedlink_slave.h"
20 #include "webkit/glue/cache_manager.h" 20 #include "webkit/glue/cache_manager.h"
21 21
22 RenderThread* g_render_thread; 22 RenderThread* g_render_thread;
23 23
24 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; 24 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */;
25 25
26 // V8 needs a 1MB stack size. 26 // V8 needs a 1MB stack size.
27 static const size_t kStackSize = 1024 * 1024; 27 static const size_t kStackSize = 1024 * 1024;
28 28
29 //----------------------------------------------------------------------------- 29 //-----------------------------------------------------------------------------
30 // Methods below are only called on the owner's thread: 30 // Methods below are only called on the owner's thread:
31 31
32 RenderThread::RenderThread(const std::wstring& channel_name) 32 RenderThread::RenderThread(const std::wstring& channel_name)
33 : Thread("Chrome_RenderThread"), 33 : Thread("Chrome_RenderThread"),
34 channel_name_(channel_name), 34 channel_name_(channel_name),
35 owner_loop_(MessageLoop::current()), 35 owner_loop_(MessageLoop::current()),
36 visited_link_slave_(NULL), 36 visited_link_slave_(NULL),
37 greasemonkey_slave_(NULL), 37 user_script_slave_(NULL),
38 render_dns_master_(NULL), 38 render_dns_master_(NULL),
39 in_send_(0) { 39 in_send_(0) {
40 DCHECK(owner_loop_); 40 DCHECK(owner_loop_);
41 base::Thread::Options options; 41 base::Thread::Options options;
42 options.stack_size = kStackSize; 42 options.stack_size = kStackSize;
43 // When we run plugins in process, we actually run them on the render thread, 43 // When we run plugins in process, we actually run them on the render thread,
44 // which means that we need to make the render thread pump UI events. 44 // which means that we need to make the render thread pump UI events.
45 if (RenderProcess::ShouldLoadPluginsInProcess()) 45 if (RenderProcess::ShouldLoadPluginsInProcess())
46 options.message_loop_type = MessageLoop::TYPE_UI; 46 options.message_loop_type = MessageLoop::TYPE_UI;
47 StartWithOptions(options); 47 StartWithOptions(options);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 new ScopedRunnableMethodFactory<RenderThread>(this)); 98 new ScopedRunnableMethodFactory<RenderThread>(this));
99 99
100 channel_.reset(new IPC::SyncChannel(channel_name_, 100 channel_.reset(new IPC::SyncChannel(channel_name_,
101 IPC::Channel::MODE_CLIENT, this, NULL, owner_loop_, true, 101 IPC::Channel::MODE_CLIENT, this, NULL, owner_loop_, true,
102 RenderProcess::GetShutDownEvent())); 102 RenderProcess::GetShutDownEvent()));
103 103
104 // The renderer thread should wind-up COM. 104 // The renderer thread should wind-up COM.
105 CoInitialize(0); 105 CoInitialize(0);
106 106
107 visited_link_slave_ = new VisitedLinkSlave(); 107 visited_link_slave_ = new VisitedLinkSlave();
108 greasemonkey_slave_ = new GreasemonkeySlave(); 108 user_script_slave_ = new UserScriptSlave();
109 109
110 render_dns_master_.reset(new RenderDnsMaster()); 110 render_dns_master_.reset(new RenderDnsMaster());
111 111
112 #ifdef IPC_MESSAGE_LOG_ENABLED 112 #ifdef IPC_MESSAGE_LOG_ENABLED
113 IPC::Logging::current()->SetIPCSender(this); 113 IPC::Logging::current()->SetIPCSender(this);
114 #endif 114 #endif
115 } 115 }
116 116
117 void RenderThread::CleanUp() { 117 void RenderThread::CleanUp() {
118 DCHECK(g_render_thread == this); 118 DCHECK(g_render_thread == this);
119 g_render_thread = NULL; 119 g_render_thread = NULL;
120 120
121 // Need to destruct the SyncChannel to the browser before we go away because 121 // Need to destruct the SyncChannel to the browser before we go away because
122 // it caches a pointer to this thread. 122 // it caches a pointer to this thread.
123 channel_.reset(); 123 channel_.reset();
124 124
125 // Clean up plugin channels before this thread goes away. 125 // Clean up plugin channels before this thread goes away.
126 PluginChannelBase::CleanupChannels(); 126 PluginChannelBase::CleanupChannels();
127 127
128 #ifdef IPC_MESSAGE_LOG_ENABLED 128 #ifdef IPC_MESSAGE_LOG_ENABLED
129 IPC::Logging::current()->SetIPCSender(NULL); 129 IPC::Logging::current()->SetIPCSender(NULL);
130 #endif 130 #endif
131 131
132 notification_service_.reset(); 132 notification_service_.reset();
133 133
134 delete visited_link_slave_; 134 delete visited_link_slave_;
135 visited_link_slave_ = NULL; 135 visited_link_slave_ = NULL;
136 136
137 delete greasemonkey_slave_; 137 delete user_script_slave_;
138 greasemonkey_slave_ = NULL; 138 user_script_slave_ = NULL;
139 139
140 CoUninitialize(); 140 CoUninitialize();
141 } 141 }
142 142
143 void RenderThread::OnUpdateVisitedLinks(base::SharedMemoryHandle table) { 143 void RenderThread::OnUpdateVisitedLinks(base::SharedMemoryHandle table) {
144 DCHECK(table) << "Bad table handle"; 144 DCHECK(table) << "Bad table handle";
145 visited_link_slave_->Init(table); 145 visited_link_slave_->Init(table);
146 } 146 }
147 147
148 void RenderThread::OnUpdateGreasemonkeyScripts( 148 void RenderThread::OnUpdateUserScripts(
149 base::SharedMemoryHandle scripts) { 149 base::SharedMemoryHandle scripts) {
150 DCHECK(scripts) << "Bad scripts handle"; 150 DCHECK(scripts) << "Bad scripts handle";
151 greasemonkey_slave_->UpdateScripts(scripts); 151 user_script_slave_->UpdateScripts(scripts);
152 } 152 }
153 153
154 void RenderThread::OnMessageReceived(const IPC::Message& msg) { 154 void RenderThread::OnMessageReceived(const IPC::Message& msg) {
155 // NOTE: We could subclass router_ to intercept OnControlMessageReceived, but 155 // NOTE: We could subclass router_ to intercept OnControlMessageReceived, but
156 // it seems simpler to just process any control messages that we care about 156 // it seems simpler to just process any control messages that we care about
157 // up-front and then send the rest of the messages onto router_. 157 // up-front and then send the rest of the messages onto router_.
158 158
159 if (msg.routing_id() == MSG_ROUTING_CONTROL) { 159 if (msg.routing_id() == MSG_ROUTING_CONTROL) {
160 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) 160 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg)
161 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) 161 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks)
162 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) 162 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID)
163 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) 163 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView)
164 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) 164 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities)
165 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, 165 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats,
166 OnGetCacheResourceStats) 166 OnGetCacheResourceStats)
167 IPC_MESSAGE_HANDLER(ViewMsg_PluginMessage, OnPluginMessage) 167 IPC_MESSAGE_HANDLER(ViewMsg_PluginMessage, OnPluginMessage)
168 IPC_MESSAGE_HANDLER(ViewMsg_Greasemonkey_NewScripts, 168 IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_NewScripts,
169 OnUpdateGreasemonkeyScripts) 169 OnUpdateUserScripts)
170 // send the rest to the router 170 // send the rest to the router
171 IPC_MESSAGE_UNHANDLED(router_.OnMessageReceived(msg)) 171 IPC_MESSAGE_UNHANDLED(router_.OnMessageReceived(msg))
172 IPC_END_MESSAGE_MAP() 172 IPC_END_MESSAGE_MAP()
173 } else { 173 } else {
174 router_.OnMessageReceived(msg); 174 router_.OnMessageReceived(msg);
175 } 175 }
176 } 176 }
177 177
178 void RenderThread::OnPluginMessage(const FilePath& plugin_path, 178 void RenderThread::OnPluginMessage(const FilePath& plugin_path,
179 const std::vector<uint8>& data) { 179 const std::vector<uint8>& data) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 void RenderThread::InformHostOfCacheStatsLater() { 224 void RenderThread::InformHostOfCacheStatsLater() {
225 // Rate limit informing the host of our cache stats. 225 // Rate limit informing the host of our cache stats.
226 if (!cache_stats_factory_->empty()) 226 if (!cache_stats_factory_->empty())
227 return; 227 return;
228 228
229 MessageLoop::current()->PostDelayedTask(FROM_HERE, 229 MessageLoop::current()->PostDelayedTask(FROM_HERE,
230 cache_stats_factory_->NewRunnableMethod( 230 cache_stats_factory_->NewRunnableMethod(
231 &RenderThread::InformHostOfCacheStats), 231 &RenderThread::InformHostOfCacheStats),
232 kCacheStatsDelayMS); 232 kCacheStatsDelayMS);
233 } 233 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_thread.h ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698