| OLD | NEW |
| 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/host_address_request.h" | 5 #include "content/renderer/p2p/host_address_request.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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 void P2PHostAddressRequest::DoSendRequest(const std::string& host_name, | 48 void P2PHostAddressRequest::DoSendRequest(const std::string& host_name, |
| 49 const DoneCallback& done_callback) { | 49 const DoneCallback& done_callback) { |
| 50 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); | 50 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); |
| 51 | 51 |
| 52 done_callback_ = done_callback; | 52 done_callback_ = done_callback; |
| 53 request_id_ = dispatcher_->RegisterHostAddressRequest(this); | 53 request_id_ = dispatcher_->RegisterHostAddressRequest(this); |
| 54 registered_ = true; | 54 registered_ = true; |
| 55 dispatcher_->SendP2PMessage( | 55 dispatcher_->SendP2PMessage( |
| 56 new P2PHostMsg_GetHostAddress(0, host_name, request_id_)); | 56 new P2PHostMsg_GetHostAddress(host_name, request_id_)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void P2PHostAddressRequest::DoUnregister() { | 59 void P2PHostAddressRequest::DoUnregister() { |
| 60 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); | 60 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); |
| 61 if (registered_) { | 61 if (registered_) { |
| 62 dispatcher_->UnregisterHostAddressRequest(request_id_); | 62 dispatcher_->UnregisterHostAddressRequest(request_id_); |
| 63 registered_ = false; | 63 registered_ = false; |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 78 void P2PHostAddressRequest::DeliverResponse( | 78 void P2PHostAddressRequest::DeliverResponse( |
| 79 const net::IPAddressNumber& address) { | 79 const net::IPAddressNumber& address) { |
| 80 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); | 80 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); |
| 81 if (state_ == STATE_SENT) { | 81 if (state_ == STATE_SENT) { |
| 82 done_callback_.Run(address); | 82 done_callback_.Run(address); |
| 83 state_ = STATE_FINISHED; | 83 state_ = STATE_FINISHED; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace content | 87 } // namespace content |
| OLD | NEW |