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

Side by Side Diff: content/browser/net/browser_online_state_observer.cc

Issue 2400313002: Convert miscellaneous RenderThreadImpl messages to mojom (Closed)
Patch Set: rebase Created 4 years, 2 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 | « content/browser/android/content_view_statics.cc ('k') | content/browser/plugin_service_impl.cc » ('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) 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 "content/browser/net/browser_online_state_observer.h" 5 #include "content/browser/net/browser_online_state_observer.h"
6 6
7 #include "content/common/view_messages.h" 7 #include "content/common/view_messages.h"
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_service.h"
10 #include "content/public/browser/notification_types.h" 10 #include "content/public/browser/notification_types.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 BrowserOnlineStateObserver::BrowserOnlineStateObserver() { 14 BrowserOnlineStateObserver::BrowserOnlineStateObserver() {
15 net::NetworkChangeNotifier::AddMaxBandwidthObserver(this); 15 net::NetworkChangeNotifier::AddMaxBandwidthObserver(this);
16 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, 16 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED,
17 content::NotificationService::AllSources()); 17 content::NotificationService::AllSources());
18 } 18 }
19 19
20 BrowserOnlineStateObserver::~BrowserOnlineStateObserver() { 20 BrowserOnlineStateObserver::~BrowserOnlineStateObserver() {
21 net::NetworkChangeNotifier::RemoveMaxBandwidthObserver(this); 21 net::NetworkChangeNotifier::RemoveMaxBandwidthObserver(this);
22 } 22 }
23 23
24 void BrowserOnlineStateObserver::OnMaxBandwidthChanged( 24 void BrowserOnlineStateObserver::OnMaxBandwidthChanged(
25 double max_bandwidth_mbps, 25 double max_bandwidth_mbps,
26 net::NetworkChangeNotifier::ConnectionType type) { 26 net::NetworkChangeNotifier::ConnectionType type) {
27 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); 27 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
28 !it.IsAtEnd(); it.Advance()) { 28 !it.IsAtEnd(); it.Advance()) {
29 it.GetCurrentValue()->Send( 29 it.GetCurrentValue()->GetRendererInterface()->OnNetworkConnectionChanged(
30 new ViewMsg_NetworkConnectionChanged(type, max_bandwidth_mbps)); 30 type, max_bandwidth_mbps);
31 } 31 }
32 } 32 }
33 33
34 void BrowserOnlineStateObserver::Observe( 34 void BrowserOnlineStateObserver::Observe(
35 int type, 35 int type,
36 const content::NotificationSource& source, 36 const content::NotificationSource& source,
37 const content::NotificationDetails& details) { 37 const content::NotificationDetails& details) {
38 DCHECK_EQ(NOTIFICATION_RENDERER_PROCESS_CREATED, type); 38 DCHECK_EQ(NOTIFICATION_RENDERER_PROCESS_CREATED, type);
39 39
40 content::RenderProcessHost* rph = 40 content::RenderProcessHost* rph =
41 content::Source<content::RenderProcessHost>(source).ptr(); 41 content::Source<content::RenderProcessHost>(source).ptr();
42 double max_bandwidth_mbps; 42 double max_bandwidth_mbps;
43 net::NetworkChangeNotifier::ConnectionType connection_type; 43 net::NetworkChangeNotifier::ConnectionType connection_type;
44 net::NetworkChangeNotifier::GetMaxBandwidthAndConnectionType( 44 net::NetworkChangeNotifier::GetMaxBandwidthAndConnectionType(
45 &max_bandwidth_mbps, &connection_type); 45 &max_bandwidth_mbps, &connection_type);
46 rph->Send(new ViewMsg_NetworkConnectionChanged(connection_type, 46 rph->GetRendererInterface()->OnNetworkConnectionChanged(
47 max_bandwidth_mbps)); 47 connection_type, max_bandwidth_mbps);
48 } 48 }
49 49
50 } // namespace content 50 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_statics.cc ('k') | content/browser/plugin_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698