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

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

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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/port_allocator.cc ('k') | content/renderer/p2p/socket_dispatcher.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_client.h" 5 #include "content/renderer/p2p/socket_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "content/common/p2p_messages.h" 9 #include "content/common/p2p_messages.h"
10 #include "content/renderer/p2p/socket_dispatcher.h" 10 #include "content/renderer/p2p/socket_dispatcher.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); 104 DCHECK(delegate_message_loop_->BelongsToCurrentThread());
105 if (delegate_) 105 if (delegate_)
106 delegate_->OnOpen(address); 106 delegate_->OnOpen(address);
107 } 107 }
108 108
109 void P2PSocketClient::OnIncomingTcpConnection(const net::IPEndPoint& address) { 109 void P2PSocketClient::OnIncomingTcpConnection(const net::IPEndPoint& address) {
110 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); 110 DCHECK(ipc_message_loop_->BelongsToCurrentThread());
111 DCHECK_EQ(state_, STATE_OPEN); 111 DCHECK_EQ(state_, STATE_OPEN);
112 112
113 scoped_refptr<P2PSocketClient> new_client = new P2PSocketClient(dispatcher_); 113 scoped_refptr<P2PSocketClient> new_client = new P2PSocketClient(dispatcher_);
114 new_client->socket_id_ = dispatcher_->RegisterClient(new_client); 114 new_client->socket_id_ = dispatcher_->RegisterClient(new_client.get());
115 new_client->state_ = STATE_OPEN; 115 new_client->state_ = STATE_OPEN;
116 new_client->delegate_message_loop_ = delegate_message_loop_; 116 new_client->delegate_message_loop_ = delegate_message_loop_;
117 117
118 dispatcher_->SendP2PMessage(new P2PHostMsg_AcceptIncomingTcpConnection( 118 dispatcher_->SendP2PMessage(new P2PHostMsg_AcceptIncomingTcpConnection(
119 socket_id_, address, new_client->socket_id_)); 119 socket_id_, address, new_client->socket_id_));
120 120
121 delegate_message_loop_->PostTask( 121 delegate_message_loop_->PostTask(
122 FROM_HERE, base::Bind(&P2PSocketClient::DeliverOnIncomingTcpConnection, 122 FROM_HERE, base::Bind(&P2PSocketClient::DeliverOnIncomingTcpConnection,
123 this, address, new_client)); 123 this, address, new_client));
124 } 124 }
125 125
126 void P2PSocketClient::DeliverOnIncomingTcpConnection( 126 void P2PSocketClient::DeliverOnIncomingTcpConnection(
127 const net::IPEndPoint& address, scoped_refptr<P2PSocketClient> new_client) { 127 const net::IPEndPoint& address, scoped_refptr<P2PSocketClient> new_client) {
128 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); 128 DCHECK(delegate_message_loop_->BelongsToCurrentThread());
129 if (delegate_) { 129 if (delegate_) {
130 delegate_->OnIncomingTcpConnection(address, new_client); 130 delegate_->OnIncomingTcpConnection(address, new_client.get());
131 } else { 131 } else {
132 // Just close the socket if there is no delegate to accept it. 132 // Just close the socket if there is no delegate to accept it.
133 new_client->Close(); 133 new_client->Close();
134 } 134 }
135 } 135 }
136 136
137 void P2PSocketClient::OnSendComplete() { 137 void P2PSocketClient::OnSendComplete() {
138 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); 138 DCHECK(ipc_message_loop_->BelongsToCurrentThread());
139 139
140 delegate_message_loop_->PostTask( 140 delegate_message_loop_->PostTask(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 delegate_->OnDataReceived(address, data); 177 delegate_->OnDataReceived(address, data);
178 } 178 }
179 179
180 void P2PSocketClient::Detach() { 180 void P2PSocketClient::Detach() {
181 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); 181 DCHECK(ipc_message_loop_->BelongsToCurrentThread());
182 dispatcher_ = NULL; 182 dispatcher_ = NULL;
183 OnError(); 183 OnError();
184 } 184 }
185 185
186 } // namespace content 186 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/p2p/port_allocator.cc ('k') | content/renderer/p2p/socket_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698