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

Side by Side Diff: content/renderer/p2p/socket_dispatcher.cc

Issue 10387135: Add deletion observer to P2PSocketDispatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix dll export. Created 8 years, 7 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 | « content/renderer/p2p/socket_dispatcher.h ('k') | no next file » | 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/renderer/p2p/socket_dispatcher.h" 5 #include "content/renderer/p2p/socket_dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "content/common/p2p_messages.h" 10 #include "content/common/p2p_messages.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 P2PSocketDispatcher::P2PSocketDispatcher(RenderViewImpl* render_view) 52 P2PSocketDispatcher::P2PSocketDispatcher(RenderViewImpl* render_view)
53 : content::RenderViewObserver(render_view), 53 : content::RenderViewObserver(render_view),
54 message_loop_(base::MessageLoopProxy::current()), 54 message_loop_(base::MessageLoopProxy::current()),
55 network_notifications_started_(false), 55 network_notifications_started_(false),
56 network_list_observers_( 56 network_list_observers_(
57 new ObserverListThreadSafe<webkit_glue::NetworkListObserver>()), 57 new ObserverListThreadSafe<webkit_glue::NetworkListObserver>()),
58 async_message_sender_(new AsyncMessageSender(this)) { 58 async_message_sender_(new AsyncMessageSender(this)) {
59 } 59 }
60 60
61 P2PSocketDispatcher::~P2PSocketDispatcher() { 61 P2PSocketDispatcher::~P2PSocketDispatcher() {
62 FOR_EACH_OBSERVER(P2PSocketDispatcherDestructionObserver,
63 destruction_observer_, OnSocketDispatcherDestroyed());
62 network_list_observers_->AssertEmpty(); 64 network_list_observers_->AssertEmpty();
63 if (network_notifications_started_) 65 if (network_notifications_started_)
64 Send(new P2PHostMsg_StopNetworkNotifications(routing_id())); 66 Send(new P2PHostMsg_StopNetworkNotifications(routing_id()));
65 for (IDMap<P2PSocketClient>::iterator i(&clients_); !i.IsAtEnd(); 67 for (IDMap<P2PSocketClient>::iterator i(&clients_); !i.IsAtEnd();
66 i.Advance()) { 68 i.Advance()) {
67 i.GetCurrentValue()->Detach(); 69 i.GetCurrentValue()->Detach();
68 } 70 }
69 async_message_sender_->Detach(); 71 async_message_sender_->Detach();
70 } 72 }
71 73
72 void P2PSocketDispatcher::AddNetworkListObserver( 74 void P2PSocketDispatcher::AddNetworkListObserver(
73 webkit_glue::NetworkListObserver* network_list_observer) { 75 webkit_glue::NetworkListObserver* network_list_observer) {
74 network_list_observers_->AddObserver(network_list_observer); 76 network_list_observers_->AddObserver(network_list_observer);
75 network_notifications_started_ = true; 77 network_notifications_started_ = true;
76 async_message_sender_->Send( 78 async_message_sender_->Send(
77 new P2PHostMsg_StartNetworkNotifications(routing_id())); 79 new P2PHostMsg_StartNetworkNotifications(routing_id()));
78 } 80 }
79 81
80 void P2PSocketDispatcher::RemoveNetworkListObserver( 82 void P2PSocketDispatcher::RemoveNetworkListObserver(
81 webkit_glue::NetworkListObserver* network_list_observer) { 83 webkit_glue::NetworkListObserver* network_list_observer) {
82 network_list_observers_->RemoveObserver(network_list_observer); 84 network_list_observers_->RemoveObserver(network_list_observer);
83 } 85 }
84 86
87 void P2PSocketDispatcher::AddDestructionObserver(
88 P2PSocketDispatcherDestructionObserver* observer) {
89 destruction_observer_.AddObserver(observer);
90 }
91
92 void P2PSocketDispatcher::RemoveDestructionObserver(
93 P2PSocketDispatcherDestructionObserver* observer) {
94 destruction_observer_.RemoveObserver(observer);
95 }
96
85 bool P2PSocketDispatcher::OnMessageReceived(const IPC::Message& message) { 97 bool P2PSocketDispatcher::OnMessageReceived(const IPC::Message& message) {
86 bool handled = true; 98 bool handled = true;
87 IPC_BEGIN_MESSAGE_MAP(P2PSocketDispatcher, message) 99 IPC_BEGIN_MESSAGE_MAP(P2PSocketDispatcher, message)
88 IPC_MESSAGE_HANDLER(P2PMsg_NetworkListChanged, OnNetworkListChanged) 100 IPC_MESSAGE_HANDLER(P2PMsg_NetworkListChanged, OnNetworkListChanged)
89 IPC_MESSAGE_HANDLER(P2PMsg_GetHostAddressResult, OnGetHostAddressResult) 101 IPC_MESSAGE_HANDLER(P2PMsg_GetHostAddressResult, OnGetHostAddressResult)
90 IPC_MESSAGE_HANDLER(P2PMsg_OnSocketCreated, OnSocketCreated) 102 IPC_MESSAGE_HANDLER(P2PMsg_OnSocketCreated, OnSocketCreated)
91 IPC_MESSAGE_HANDLER(P2PMsg_OnIncomingTcpConnection, OnIncomingTcpConnection) 103 IPC_MESSAGE_HANDLER(P2PMsg_OnIncomingTcpConnection, OnIncomingTcpConnection)
92 IPC_MESSAGE_HANDLER(P2PMsg_OnError, OnError) 104 IPC_MESSAGE_HANDLER(P2PMsg_OnError, OnError)
93 IPC_MESSAGE_HANDLER(P2PMsg_OnDataReceived, OnDataReceived) 105 IPC_MESSAGE_HANDLER(P2PMsg_OnDataReceived, OnDataReceived)
94 IPC_MESSAGE_UNHANDLED(handled = false) 106 IPC_MESSAGE_UNHANDLED(handled = false)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // hasn't processed the close message by the time it sends the 191 // hasn't processed the close message by the time it sends the
180 // message to the renderer. 192 // message to the renderer.
181 VLOG(1) << "Received P2P message for socket that doesn't exist."; 193 VLOG(1) << "Received P2P message for socket that doesn't exist.";
182 return NULL; 194 return NULL;
183 } 195 }
184 196
185 return client; 197 return client;
186 } 198 }
187 199
188 } // namespace content 200 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/p2p/socket_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698