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

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

Issue 6250176: Make RenderView not have to know about how PhishingClassifierDelegate. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | Annotate | Revision Log
« 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
17 #include "base/metrics/stats_table.h" 17 #include "base/metrics/stats_table.h"
18 #include "base/process_util.h" 18 #include "base/process_util.h"
19 #include "base/scoped_callback_factory.h"
20 #include "base/shared_memory.h" 19 #include "base/shared_memory.h"
21 #include "base/string_util.h" 20 #include "base/string_util.h"
22 #include "base/task.h" 21 #include "base/task.h"
23 #include "base/threading/thread_local.h" 22 #include "base/threading/thread_local.h"
24 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
25 #include "base/values.h" 24 #include "base/values.h"
26 #include "chrome/common/appcache/appcache_dispatcher.h" 25 #include "chrome/common/appcache/appcache_dispatcher.h"
27 #include "chrome/common/child_process_logging.h" 26 #include "chrome/common/child_process_logging.h"
28 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/database_messages.h" 28 #include "chrome/common/database_messages.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "chrome/renderer/loadtimes_extension_bindings.h" 61 #include "chrome/renderer/loadtimes_extension_bindings.h"
63 #include "chrome/renderer/net/renderer_net_predictor.h" 62 #include "chrome/renderer/net/renderer_net_predictor.h"
64 #include "chrome/renderer/plugin_channel_host.h" 63 #include "chrome/renderer/plugin_channel_host.h"
65 #include "chrome/renderer/render_process_impl.h" 64 #include "chrome/renderer/render_process_impl.h"
66 #include "chrome/renderer/render_view.h" 65 #include "chrome/renderer/render_view.h"
67 #include "chrome/renderer/render_view_visitor.h" 66 #include "chrome/renderer/render_view_visitor.h"
68 #include "chrome/renderer/renderer_histogram_snapshots.h" 67 #include "chrome/renderer/renderer_histogram_snapshots.h"
69 #include "chrome/renderer/renderer_webidbfactory_impl.h" 68 #include "chrome/renderer/renderer_webidbfactory_impl.h"
70 #include "chrome/renderer/renderer_webkitclient_impl.h" 69 #include "chrome/renderer/renderer_webkitclient_impl.h"
71 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" 70 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
72 #include "chrome/renderer/safe_browsing/scorer.h"
73 #include "chrome/renderer/search_extension.h" 71 #include "chrome/renderer/search_extension.h"
74 #include "chrome/renderer/searchbox_extension.h" 72 #include "chrome/renderer/searchbox_extension.h"
75 #include "chrome/renderer/spellchecker/spellcheck.h" 73 #include "chrome/renderer/spellchecker/spellcheck.h"
76 #include "chrome/renderer/user_script_slave.h" 74 #include "chrome/renderer/user_script_slave.h"
77 #include "ipc/ipc_channel_handle.h" 75 #include "ipc/ipc_channel_handle.h"
78 #include "ipc/ipc_message.h" 76 #include "ipc/ipc_message.h"
79 #include "ipc/ipc_platform_file.h" 77 #include "ipc/ipc_platform_file.h"
80 #include "net/base/net_util.h" 78 #include "net/base/net_util.h"
81 #include "third_party/sqlite/sqlite3.h" 79 #include "third_party/sqlite/sqlite3.h"
82 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" 80 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return true; 208 return true;
211 } 209 }
212 210
213 private: 211 private:
214 std::string host_; 212 std::string host_;
215 double zoom_level_; 213 double zoom_level_;
216 214
217 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); 215 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
218 }; 216 };
219 217
220 class RenderViewPhishingScorerSetter : public RenderViewVisitor {
221 public:
222 explicit RenderViewPhishingScorerSetter(const safe_browsing::Scorer* scorer)
223 : scorer_(scorer) {
224 }
225
226 virtual bool Visit(RenderView* render_view) {
227 safe_browsing::PhishingClassifierDelegate* delegate =
228 render_view->phishing_classifier_delegate();
229 if (delegate)
230 delegate->SetPhishingScorer(scorer_);
231 return true;
232 }
233
234 private:
235 const safe_browsing::Scorer* scorer_;
236
237 DISALLOW_COPY_AND_ASSIGN(RenderViewPhishingScorerSetter);
238 };
239
240 } // namespace 218 } // namespace
241 219
242 // When we run plugins in process, we actually run them on the render thread, 220 // When we run plugins in process, we actually run them on the render thread,
243 // which means that we need to make the render thread pump UI events. 221 // which means that we need to make the render thread pump UI events.
244 RenderThread::RenderThread() { 222 RenderThread::RenderThread() {
245 Init(); 223 Init();
246 } 224 }
247 225
248 RenderThread::RenderThread(const std::string& channel_name) 226 RenderThread::RenderThread(const std::string& channel_name)
249 : ChildThread(channel_name) { 227 : ChildThread(channel_name) {
(...skipping 20 matching lines...) Expand all
270 is_speech_input_enabled_ = false; 248 is_speech_input_enabled_ = false;
271 suspend_webkit_shared_timer_ = true; 249 suspend_webkit_shared_timer_ = true;
272 notify_webkit_of_modal_loop_ = true; 250 notify_webkit_of_modal_loop_ = true;
273 plugin_refresh_allowed_ = true; 251 plugin_refresh_allowed_ = true;
274 cache_stats_task_pending_ = false; 252 cache_stats_task_pending_ = false;
275 widget_count_ = 0; 253 widget_count_ = 0;
276 hidden_widget_count_ = 0; 254 hidden_widget_count_ = 0;
277 idle_notification_delay_in_s_ = is_extension_process_ ? 255 idle_notification_delay_in_s_ = is_extension_process_ ?
278 kInitialExtensionIdleHandlerDelayS : kInitialIdleHandlerDelayS; 256 kInitialExtensionIdleHandlerDelayS : kInitialIdleHandlerDelayS;
279 task_factory_.reset(new ScopedRunnableMethodFactory<RenderThread>(this)); 257 task_factory_.reset(new ScopedRunnableMethodFactory<RenderThread>(this));
280 callback_factory_.reset(new base::ScopedCallbackFactory<RenderThread>(this));
281 258
282 visited_link_slave_.reset(new VisitedLinkSlave()); 259 visited_link_slave_.reset(new VisitedLinkSlave());
283 user_script_slave_.reset(new UserScriptSlave(&extensions_)); 260 user_script_slave_.reset(new UserScriptSlave(&extensions_));
284 renderer_net_predictor_.reset(new RendererNetPredictor()); 261 renderer_net_predictor_.reset(new RendererNetPredictor());
285 histogram_snapshots_.reset(new RendererHistogramSnapshots()); 262 histogram_snapshots_.reset(new RendererHistogramSnapshots());
286 appcache_dispatcher_.reset(new AppCacheDispatcher(this)); 263 appcache_dispatcher_.reset(new AppCacheDispatcher(this));
287 indexed_db_dispatcher_.reset(new IndexedDBDispatcher()); 264 indexed_db_dispatcher_.reset(new IndexedDBDispatcher());
288 spellchecker_.reset(new SpellCheck()); 265 spellchecker_.reset(new SpellCheck());
289 266
290 devtools_agent_filter_ = new DevToolsAgentFilter(); 267 devtools_agent_filter_ = new DevToolsAgentFilter();
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 if (channel_handle.name.size() != 0) { 1084 if (channel_handle.name.size() != 0) {
1108 // Connect to the GPU process if a channel name was received. 1085 // Connect to the GPU process if a channel name was received.
1109 gpu_channel_->Connect(channel_handle); 1086 gpu_channel_->Connect(channel_handle);
1110 } else { 1087 } else {
1111 // Otherwise cancel the connection. 1088 // Otherwise cancel the connection.
1112 gpu_channel_ = NULL; 1089 gpu_channel_ = NULL;
1113 } 1090 }
1114 } 1091 }
1115 1092
1116 void RenderThread::OnSetPhishingModel(IPC::PlatformFileForTransit model_file) { 1093 void RenderThread::OnSetPhishingModel(IPC::PlatformFileForTransit model_file) {
1117 safe_browsing::Scorer::CreateFromFile( 1094 safe_browsing::PhishingClassifierDelegate::SetPhishingModel(model_file);
1118 IPC::PlatformFileForTransitToPlatformFile(model_file),
1119 GetFileThreadMessageLoopProxy(),
1120 callback_factory_->NewCallback(&RenderThread::PhishingScorerCreated));
1121 }
1122
1123 void RenderThread::PhishingScorerCreated(safe_browsing::Scorer* scorer) {
1124 if (!scorer) {
1125 DLOG(ERROR) << "Unable to create a PhishingScorer - corrupt model?";
1126 return;
1127 }
1128 phishing_scorer_.reset(scorer);
1129 RenderViewPhishingScorerSetter setter(phishing_scorer_.get());
1130 RenderView::ForEach(&setter);
1131 } 1095 }
1132 1096
1133 scoped_refptr<base::MessageLoopProxy> 1097 scoped_refptr<base::MessageLoopProxy>
1134 RenderThread::GetFileThreadMessageLoopProxy() { 1098 RenderThread::GetFileThreadMessageLoopProxy() {
1135 DCHECK(message_loop() == MessageLoop::current()); 1099 DCHECK(message_loop() == MessageLoop::current());
1136 if (!file_thread_.get()) { 1100 if (!file_thread_.get()) {
1137 file_thread_.reset(new base::Thread("Renderer::FILE")); 1101 file_thread_.reset(new base::Thread("Renderer::FILE"));
1138 file_thread_->Start(); 1102 file_thread_->Start();
1139 } 1103 }
1140 return file_thread_->message_loop_proxy(); 1104 return file_thread_->message_loop_proxy();
(...skipping 19 matching lines...) Expand all
1160 } 1124 }
1161 1125
1162 return false; 1126 return false;
1163 } 1127 }
1164 1128
1165 void RenderThread::RegisterExtension(v8::Extension* extension, 1129 void RenderThread::RegisterExtension(v8::Extension* extension,
1166 bool restrict_to_extensions) { 1130 bool restrict_to_extensions) {
1167 WebScriptController::registerExtension(extension); 1131 WebScriptController::registerExtension(extension);
1168 v8_extensions_[extension->name()] = restrict_to_extensions; 1132 v8_extensions_[extension->name()] = restrict_to_extensions;
1169 } 1133 }
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