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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 | 255 |
256 void SocketsUdpSendFunction::StartSendTo() { | 256 void SocketsUdpSendFunction::StartSendTo() { |
257 ResumableUDPSocket* socket = GetUdpSocket(params_->socket_id); | 257 ResumableUDPSocket* socket = GetUdpSocket(params_->socket_id); |
258 if (!socket) { | 258 if (!socket) { |
259 error_ = kSocketNotFoundError; | 259 error_ = kSocketNotFoundError; |
260 AsyncWorkCompleted(); | 260 AsyncWorkCompleted(); |
261 return; | 261 return; |
262 } | 262 } |
263 | 263 |
264 socket->SendTo(io_buffer_, io_buffer_size_, addresses_.front(), | 264 socket->SendTo(io_buffer_, static_cast<int>(io_buffer_size_), |
| 265 addresses_.front(), |
265 base::Bind(&SocketsUdpSendFunction::OnCompleted, this)); | 266 base::Bind(&SocketsUdpSendFunction::OnCompleted, this)); |
266 } | 267 } |
267 | 268 |
268 void SocketsUdpSendFunction::OnCompleted(int net_result) { | 269 void SocketsUdpSendFunction::OnCompleted(int net_result) { |
269 if (net_result >= net::OK) { | 270 if (net_result >= net::OK) { |
270 SetSendResult(net::OK, net_result); | 271 SetSendResult(net::OK, net_result); |
271 } else { | 272 } else { |
272 SetSendResult(net_result, -1); | 273 SetSendResult(net_result, -1); |
273 } | 274 } |
274 } | 275 } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 | 518 |
518 int net_result = socket->SetBroadcast(params_->enabled); | 519 int net_result = socket->SetBroadcast(params_->enabled); |
519 if (net_result != net::OK) { | 520 if (net_result != net::OK) { |
520 error_ = net::ErrorToString(net_result); | 521 error_ = net::ErrorToString(net_result); |
521 } | 522 } |
522 results_ = sockets_udp::SetBroadcast::Results::Create(net_result); | 523 results_ = sockets_udp::SetBroadcast::Results::Create(net_result); |
523 } | 524 } |
524 | 525 |
525 } // namespace api | 526 } // namespace api |
526 } // namespace extensions | 527 } // namespace extensions |
OLD | NEW |