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

Side by Side Diff: content/browser/renderer_host/p2p/socket_dispatcher_host.cc

Issue 11620007: Switch from OnIPAddressChanged and OnConnectionTypeChange to OnNetworkChanged Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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/renderer_host/p2p/socket_dispatcher_host.h" 5 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/browser/renderer_host/p2p/socket_host.h" 9 #include "content/browser/renderer_host/p2p/socket_host.h"
10 #include "content/public/browser/resource_context.h" 10 #include "content/public/browser/resource_context.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 BrowserMessageFilter::OnChannelClosing(); 99 BrowserMessageFilter::OnChannelClosing();
100 100
101 // Since the IPC channel is gone, close pending connections. 101 // Since the IPC channel is gone, close pending connections.
102 STLDeleteContainerPairSecondPointers(sockets_.begin(), sockets_.end()); 102 STLDeleteContainerPairSecondPointers(sockets_.begin(), sockets_.end());
103 sockets_.clear(); 103 sockets_.clear();
104 104
105 STLDeleteContainerPointers(dns_requests_.begin(), dns_requests_.end()); 105 STLDeleteContainerPointers(dns_requests_.begin(), dns_requests_.end());
106 dns_requests_.clear(); 106 dns_requests_.clear();
107 107
108 if (monitoring_networks_) { 108 if (monitoring_networks_) {
109 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 109 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
110 monitoring_networks_ = false; 110 monitoring_networks_ = false;
111 } 111 }
112 } 112 }
113 113
114 void P2PSocketDispatcherHost::OnDestruct() const { 114 void P2PSocketDispatcherHost::OnDestruct() const {
115 BrowserThread::DeleteOnIOThread::Destruct(this); 115 BrowserThread::DeleteOnIOThread::Destruct(this);
116 } 116 }
117 117
118 bool P2PSocketDispatcherHost::OnMessageReceived(const IPC::Message& message, 118 bool P2PSocketDispatcherHost::OnMessageReceived(const IPC::Message& message,
119 bool* message_was_ok) { 119 bool* message_was_ok) {
120 bool handled = true; 120 bool handled = true;
121 IPC_BEGIN_MESSAGE_MAP_EX(P2PSocketDispatcherHost, message, *message_was_ok) 121 IPC_BEGIN_MESSAGE_MAP_EX(P2PSocketDispatcherHost, message, *message_was_ok)
122 IPC_MESSAGE_HANDLER(P2PHostMsg_StartNetworkNotifications, 122 IPC_MESSAGE_HANDLER(P2PHostMsg_StartNetworkNotifications,
123 OnStartNetworkNotifications) 123 OnStartNetworkNotifications)
124 IPC_MESSAGE_HANDLER(P2PHostMsg_StopNetworkNotifications, 124 IPC_MESSAGE_HANDLER(P2PHostMsg_StopNetworkNotifications,
125 OnStopNetworkNotifications) 125 OnStopNetworkNotifications)
126 IPC_MESSAGE_HANDLER(P2PHostMsg_GetHostAddress, OnGetHostAddress) 126 IPC_MESSAGE_HANDLER(P2PHostMsg_GetHostAddress, OnGetHostAddress)
127 IPC_MESSAGE_HANDLER(P2PHostMsg_CreateSocket, OnCreateSocket) 127 IPC_MESSAGE_HANDLER(P2PHostMsg_CreateSocket, OnCreateSocket)
128 IPC_MESSAGE_HANDLER(P2PHostMsg_AcceptIncomingTcpConnection, 128 IPC_MESSAGE_HANDLER(P2PHostMsg_AcceptIncomingTcpConnection,
129 OnAcceptIncomingTcpConnection) 129 OnAcceptIncomingTcpConnection)
130 IPC_MESSAGE_HANDLER(P2PHostMsg_Send, OnSend) 130 IPC_MESSAGE_HANDLER(P2PHostMsg_Send, OnSend)
131 IPC_MESSAGE_HANDLER(P2PHostMsg_DestroySocket, OnDestroySocket) 131 IPC_MESSAGE_HANDLER(P2PHostMsg_DestroySocket, OnDestroySocket)
132 IPC_MESSAGE_UNHANDLED(handled = false) 132 IPC_MESSAGE_UNHANDLED(handled = false)
133 IPC_END_MESSAGE_MAP_EX() 133 IPC_END_MESSAGE_MAP_EX()
134 return handled; 134 return handled;
135 } 135 }
136 136
137 void P2PSocketDispatcherHost::OnIPAddressChanged() { 137 void P2PSocketDispatcherHost::OnNetworkChanged(
138 net::NetworkChangeNotifier::ConnectionType type) {
139 if (type != net::NetworkChangeNotifier::CONNECTION_NONE)
140 return;
szym 2013/01/20 06:52:08 Wondering if the renderer should still be told whe
138 // Notify the renderer about changes to list of network interfaces. 141 // Notify the renderer about changes to list of network interfaces.
139 BrowserThread::PostTask( 142 BrowserThread::PostTask(
140 BrowserThread::FILE, FROM_HERE, base::Bind( 143 BrowserThread::FILE, FROM_HERE, base::Bind(
141 &P2PSocketDispatcherHost::DoGetNetworkList, this)); 144 &P2PSocketDispatcherHost::DoGetNetworkList, this));
142 } 145 }
143 146
144 P2PSocketDispatcherHost::~P2PSocketDispatcherHost() { 147 P2PSocketDispatcherHost::~P2PSocketDispatcherHost() {
145 DCHECK(sockets_.empty()); 148 DCHECK(sockets_.empty());
146 DCHECK(dns_requests_.empty()); 149 DCHECK(dns_requests_.empty());
147 150
148 if (monitoring_networks_) 151 if (monitoring_networks_)
149 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 152 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
150 } 153 }
151 154
152 P2PSocketHost* P2PSocketDispatcherHost::LookupSocket(int socket_id) { 155 P2PSocketHost* P2PSocketDispatcherHost::LookupSocket(int socket_id) {
153 SocketsMap::iterator it = sockets_.find(socket_id); 156 SocketsMap::iterator it = sockets_.find(socket_id);
154 return (it == sockets_.end()) ? NULL : it->second; 157 return (it == sockets_.end()) ? NULL : it->second;
155 } 158 }
156 159
157 void P2PSocketDispatcherHost::OnStartNetworkNotifications( 160 void P2PSocketDispatcherHost::OnStartNetworkNotifications(
158 const IPC::Message& msg) { 161 const IPC::Message& msg) {
159 if (!monitoring_networks_) { 162 if (!monitoring_networks_) {
160 net::NetworkChangeNotifier::AddIPAddressObserver(this); 163 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
161 monitoring_networks_ = true; 164 monitoring_networks_ = true;
162 } 165 }
163 166
164 BrowserThread::PostTask( 167 BrowserThread::PostTask(
165 BrowserThread::FILE, FROM_HERE, base::Bind( 168 BrowserThread::FILE, FROM_HERE, base::Bind(
166 &P2PSocketDispatcherHost::DoGetNetworkList, this)); 169 &P2PSocketDispatcherHost::DoGetNetworkList, this));
167 } 170 }
168 171
169 void P2PSocketDispatcherHost::OnStopNetworkNotifications( 172 void P2PSocketDispatcherHost::OnStopNetworkNotifications(
170 const IPC::Message& msg) { 173 const IPC::Message& msg) {
171 if (monitoring_networks_) { 174 if (monitoring_networks_) {
172 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 175 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
173 monitoring_networks_ = false; 176 monitoring_networks_ = false;
174 } 177 }
175 } 178 }
176 179
177 void P2PSocketDispatcherHost::OnGetHostAddress(const std::string& host_name, 180 void P2PSocketDispatcherHost::OnGetHostAddress(const std::string& host_name,
178 int32 request_id) { 181 int32 request_id) {
179 DnsRequest* request = new DnsRequest(request_id, 182 DnsRequest* request = new DnsRequest(request_id,
180 resource_context_->GetHostResolver()); 183 resource_context_->GetHostResolver());
181 dns_requests_.insert(request); 184 dns_requests_.insert(request);
182 request->Resolve(host_name, base::Bind( 185 request->Resolve(host_name, base::Bind(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 void P2PSocketDispatcherHost::OnAddressResolved( 263 void P2PSocketDispatcherHost::OnAddressResolved(
261 DnsRequest* request, 264 DnsRequest* request,
262 const net::IPAddressNumber& result) { 265 const net::IPAddressNumber& result) {
263 Send(new P2PMsg_GetHostAddressResult(request->request_id(), result)); 266 Send(new P2PMsg_GetHostAddressResult(request->request_id(), result));
264 267
265 dns_requests_.erase(request); 268 dns_requests_.erase(request);
266 delete request; 269 delete request;
267 } 270 }
268 271
269 } // namespace content 272 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698