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

Unified Diff: content/browser/renderer_host/p2p/socket_dispatcher_host.cc

Issue 10917167: Refactor the P2PSocketDispatcher to be created on the RenderThread instead of the RenderView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change P2PSocketDispatcher to take the io message loop as input to fix existing unit tests Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/p2p/socket_dispatcher_host.cc
diff --git a/content/browser/renderer_host/p2p/socket_dispatcher_host.cc b/content/browser/renderer_host/p2p/socket_dispatcher_host.cc
index eaf7beb1293b08b65a45e619d51dc47eaf5e6793..c8d73e9ae9a9b0537f5aa07477403010ed3cac03 100644
--- a/content/browser/renderer_host/p2p/socket_dispatcher_host.cc
+++ b/content/browser/renderer_host/p2p/socket_dispatcher_host.cc
@@ -25,10 +25,9 @@ class P2PSocketDispatcherHost::DnsRequest {
public:
typedef base::Callback<void(const net::IPAddressNumber&)> DoneCallback;
- DnsRequest(int32 routing_id, int32 request_id,
+ DnsRequest(int32 request_id,
net::HostResolver* host_resolver)
- : routing_id_(routing_id),
- request_id_(request_id),
+ : request_id_(request_id),
resolver_(host_resolver) {
}
@@ -60,7 +59,6 @@ class P2PSocketDispatcherHost::DnsRequest {
OnDone(result);
}
- int32 routing_id() { return routing_id_; }
int32 request_id() { return request_id_; }
private:
@@ -83,7 +81,6 @@ class P2PSocketDispatcherHost::DnsRequest {
done_callback_.Run(addresses_.front().address());
}
- int32 routing_id_;
int32 request_id_;
net::AddressList addresses_;
@@ -165,8 +162,6 @@ void P2PSocketDispatcherHost::OnStartNetworkNotifications(
monitoring_networks_ = true;
}
- notifications_routing_ids_.insert(msg.routing_id());
-
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE, base::Bind(
&P2PSocketDispatcherHost::DoGetNetworkList, this));
@@ -174,14 +169,17 @@ void P2PSocketDispatcherHost::OnStartNetworkNotifications(
void P2PSocketDispatcherHost::OnStopNetworkNotifications(
const IPC::Message& msg) {
- notifications_routing_ids_.erase(msg.routing_id());
+ if (monitoring_networks_) {
+ net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
+ monitoring_networks_ = false;
+ }
}
void P2PSocketDispatcherHost::OnGetHostAddress(const IPC::Message& msg,
const std::string& host_name,
int32 request_id) {
- DnsRequest* request = new DnsRequest(
- msg.routing_id(), request_id, resource_context_->GetHostResolver());
+ DnsRequest* request = new DnsRequest(request_id,
+ resource_context_->GetHostResolver());
dns_requests_.insert(request);
request->Resolve(host_name, base::Bind(
&P2PSocketDispatcherHost::OnAddressResolved,
@@ -199,10 +197,10 @@ void P2PSocketDispatcherHost::OnCreateSocket(
}
scoped_ptr<P2PSocketHost> socket(
- P2PSocketHost::Create(this, msg.routing_id(), socket_id, type));
+ P2PSocketHost::Create(this, socket_id, type));
if (!socket.get()) {
- Send(new P2PMsg_OnError(msg.routing_id(), socket_id));
+ Send(new P2PMsg_OnError(socket_id));
return;
}
@@ -263,17 +261,13 @@ void P2PSocketDispatcherHost::DoGetNetworkList() {
void P2PSocketDispatcherHost::SendNetworkList(
const net::NetworkInterfaceList& list) {
- for (std::set<int>::iterator it = notifications_routing_ids_.begin();
- it != notifications_routing_ids_.end(); ++it) {
- Send(new P2PMsg_NetworkListChanged(*it, list));
- }
+ Send(new P2PMsg_NetworkListChanged(list));
}
void P2PSocketDispatcherHost::OnAddressResolved(
DnsRequest* request,
const net::IPAddressNumber& result) {
- Send(new P2PMsg_GetHostAddressResult(
- request->routing_id(), request->request_id(), result));
+ Send(new P2PMsg_GetHostAddressResult(request->request_id(), result));
dns_requests_.erase(request);
delete request;
« no previous file with comments | « content/browser/renderer_host/p2p/socket_dispatcher_host.h ('k') | content/browser/renderer_host/p2p/socket_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698