| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/sockets_udp/sockets_udp_api.h" | 5 #include "extensions/browser/api/sockets_udp/sockets_udp_api.h" |
| 6 | 6 |
| 7 #include "content/public/common/socket_permission_request.h" | 7 #include "content/public/common/socket_permission_request.h" |
| 8 #include "extensions/browser/api/socket/udp_socket.h" | 8 #include "extensions/browser/api/socket/udp_socket.h" |
| 9 #include "extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h" | 9 #include "extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h" |
| 10 #include "extensions/common/api/sockets/sockets_manifest_data.h" | 10 #include "extensions/common/api/sockets/sockets_manifest_data.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 StartDnsLookup(net::HostPortPair(params_->address, params_->port)); | 245 StartDnsLookup(net::HostPortPair(params_->address, params_->port)); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void SocketsUdpSendFunction::AfterDnsLookup(int lookup_result) { | 248 void SocketsUdpSendFunction::AfterDnsLookup(int lookup_result) { |
| 249 if (lookup_result == net::OK) { | 249 if (lookup_result == net::OK) { |
| 250 StartSendTo(); | 250 StartSendTo(); |
| 251 } else { | 251 } else { |
| 252 SetSendResult(lookup_result, -1); | 252 SetSendResult(lookup_result, -1); |
| 253 } | 253 } |
| 254 |
| 255 // TODO(maksims): investigate why std::unique_ptr<HostResolver::Request>'s |
| 256 // destructor is not called automatically. |
| 257 request_handle_.reset(); |
| 254 } | 258 } |
| 255 | 259 |
| 256 void SocketsUdpSendFunction::StartSendTo() { | 260 void SocketsUdpSendFunction::StartSendTo() { |
| 257 ResumableUDPSocket* socket = GetUdpSocket(params_->socket_id); | 261 ResumableUDPSocket* socket = GetUdpSocket(params_->socket_id); |
| 258 if (!socket) { | 262 if (!socket) { |
| 259 error_ = kSocketNotFoundError; | 263 error_ = kSocketNotFoundError; |
| 260 AsyncWorkCompleted(); | 264 AsyncWorkCompleted(); |
| 261 return; | 265 return; |
| 262 } | 266 } |
| 263 | 267 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 521 |
| 518 int net_result = socket->SetBroadcast(params_->enabled); | 522 int net_result = socket->SetBroadcast(params_->enabled); |
| 519 if (net_result != net::OK) { | 523 if (net_result != net::OK) { |
| 520 error_ = net::ErrorToString(net_result); | 524 error_ = net::ErrorToString(net_result); |
| 521 } | 525 } |
| 522 results_ = sockets_udp::SetBroadcast::Results::Create(net_result); | 526 results_ = sockets_udp::SetBroadcast::Results::Create(net_result); |
| 523 } | 527 } |
| 524 | 528 |
| 525 } // namespace api | 529 } // namespace api |
| 526 } // namespace extensions | 530 } // namespace extensions |
| OLD | NEW |