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

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

Issue 2144533002: Convert network hints to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address sammc's review comments Created 4 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_render_thread_observer.h" 5 #include "chrome/renderer/chrome_render_thread_observer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
(...skipping 19 matching lines...) Expand all
30 #include "chrome/common/child_process_logging.h" 30 #include "chrome/common/child_process_logging.h"
31 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
32 #include "chrome/common/media/media_resource_provider.h" 32 #include "chrome/common/media/media_resource_provider.h"
33 #include "chrome/common/net/net_resource_provider.h" 33 #include "chrome/common/net/net_resource_provider.h"
34 #include "chrome/common/render_messages.h" 34 #include "chrome/common/render_messages.h"
35 #include "chrome/common/resource_usage_reporter.mojom.h" 35 #include "chrome/common/resource_usage_reporter.mojom.h"
36 #include "chrome/common/resource_usage_reporter_type_converters.h" 36 #include "chrome/common/resource_usage_reporter_type_converters.h"
37 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
38 #include "chrome/renderer/content_settings_observer.h" 38 #include "chrome/renderer/content_settings_observer.h"
39 #include "chrome/renderer/security_filter_peer.h" 39 #include "chrome/renderer/security_filter_peer.h"
40 #include "components/network_hints/renderer/prescient_networking_dispatcher.h"
40 #include "content/public/child/resource_dispatcher_delegate.h" 41 #include "content/public/child/resource_dispatcher_delegate.h"
41 #include "content/public/renderer/render_thread.h" 42 #include "content/public/renderer/render_thread.h"
42 #include "content/public/renderer/render_view.h" 43 #include "content/public/renderer/render_view.h"
43 #include "content/public/renderer/render_view_visitor.h" 44 #include "content/public/renderer/render_view_visitor.h"
44 #include "media/base/media_resources.h" 45 #include "media/base/media_resources.h"
45 #include "mojo/public/cpp/bindings/strong_binding.h" 46 #include "mojo/public/cpp/bindings/strong_binding.h"
46 #include "net/base/net_errors.h" 47 #include "net/base/net_errors.h"
47 #include "net/base/net_module.h" 48 #include "net/base/net_module.h"
48 #include "services/shell/public/cpp/interface_registry.h" 49 #include "services/shell/public/cpp/interface_registry.h"
49 #include "third_party/WebKit/public/web/WebCache.h" 50 #include "third_party/WebKit/public/web/WebCache.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 base::WeakPtr<ChromeRenderThreadObserver> observer, 229 base::WeakPtr<ChromeRenderThreadObserver> observer,
229 mojo::InterfaceRequest<mojom::ResourceUsageReporter> request) { 230 mojo::InterfaceRequest<mojom::ResourceUsageReporter> request) {
230 new ResourceUsageReporterImpl(observer, std::move(request)); 231 new ResourceUsageReporterImpl(observer, std::move(request));
231 } 232 }
232 233
233 } // namespace 234 } // namespace
234 235
235 bool ChromeRenderThreadObserver::is_incognito_process_ = false; 236 bool ChromeRenderThreadObserver::is_incognito_process_ = false;
236 237
237 ChromeRenderThreadObserver::ChromeRenderThreadObserver() 238 ChromeRenderThreadObserver::ChromeRenderThreadObserver()
238 : field_trial_syncer_(this), weak_factory_(this) { 239 : field_trial_syncer_(this),
240 prescient_networking_dispatcher_(
241 new network_hints::PrescientNetworkingDispatcher()),
242 weak_factory_(this) {
239 const base::CommandLine& command_line = 243 const base::CommandLine& command_line =
240 *base::CommandLine::ForCurrentProcess(); 244 *base::CommandLine::ForCurrentProcess();
241 245
242 RenderThread* thread = RenderThread::Get(); 246 RenderThread* thread = RenderThread::Get();
243 resource_delegate_.reset(new RendererResourceDelegate()); 247 resource_delegate_.reset(new RendererResourceDelegate());
244 thread->SetResourceDispatcherDelegate(resource_delegate_.get()); 248 thread->SetResourceDispatcherDelegate(resource_delegate_.get());
245 249
246 thread->GetInterfaceRegistry()->AddInterface( 250 thread->GetInterfaceRegistry()->AddInterface(
247 base::Bind(CreateResourceUsageReporter, weak_factory_.GetWeakPtr())); 251 base::Bind(CreateResourceUsageReporter, weak_factory_.GetWeakPtr()));
248 252
(...skipping 27 matching lines...) Expand all
276 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess, 280 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess,
277 OnSetIsIncognitoProcess) 281 OnSetIsIncognitoProcess)
278 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) 282 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup)
279 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingRules, 283 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingRules,
280 OnSetContentSettingRules) 284 OnSetContentSettingRules)
281 IPC_MESSAGE_UNHANDLED(handled = false) 285 IPC_MESSAGE_UNHANDLED(handled = false)
282 IPC_END_MESSAGE_MAP() 286 IPC_END_MESSAGE_MAP()
283 return handled; 287 return handled;
284 } 288 }
285 289
290 void ChromeRenderThreadObserver::OnRenderProcessShutdown() {
291 prescient_networking_dispatcher_.reset();
292 }
293
286 void ChromeRenderThreadObserver::OnFieldTrialGroupFinalized( 294 void ChromeRenderThreadObserver::OnFieldTrialGroupFinalized(
287 const std::string& trial_name, 295 const std::string& trial_name,
288 const std::string& group_name) { 296 const std::string& group_name) {
289 content::RenderThread::Get()->Send( 297 content::RenderThread::Get()->Send(
290 new ChromeViewHostMsg_FieldTrialActivated(trial_name)); 298 new ChromeViewHostMsg_FieldTrialActivated(trial_name));
291 } 299 }
292 300
293 void ChromeRenderThreadObserver::OnSetIsIncognitoProcess( 301 void ChromeRenderThreadObserver::OnSetIsIncognitoProcess(
294 bool is_incognito_process) { 302 bool is_incognito_process) {
295 is_incognito_process_ = is_incognito_process; 303 is_incognito_process_ = is_incognito_process;
296 } 304 }
297 305
298 void ChromeRenderThreadObserver::OnSetContentSettingRules( 306 void ChromeRenderThreadObserver::OnSetContentSettingRules(
299 const RendererContentSettingRules& rules) { 307 const RendererContentSettingRules& rules) {
300 content_setting_rules_ = rules; 308 content_setting_rules_ = rules;
301 } 309 }
302 310
303 void ChromeRenderThreadObserver::OnSetFieldTrialGroup( 311 void ChromeRenderThreadObserver::OnSetFieldTrialGroup(
304 const std::string& trial_name, 312 const std::string& trial_name,
305 const std::string& group_name) { 313 const std::string& group_name) {
306 field_trial_syncer_.OnSetFieldTrialGroup(trial_name, group_name); 314 field_trial_syncer_.OnSetFieldTrialGroup(trial_name, group_name);
307 } 315 }
308 316
309 const RendererContentSettingRules* 317 const RendererContentSettingRules*
310 ChromeRenderThreadObserver::content_setting_rules() const { 318 ChromeRenderThreadObserver::content_setting_rules() const {
311 return &content_setting_rules_; 319 return &content_setting_rules_;
312 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698