| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 void SocketsUdpSendFunction::OnCompleted(int net_result) { | 268 void SocketsUdpSendFunction::OnCompleted(int net_result) { |
| 269 if (net_result >= net::OK) { | 269 if (net_result >= net::OK) { |
| 270 SetSendResult(net::OK, net_result); | 270 SetSendResult(net::OK, net_result); |
| 271 } else { | 271 } else { |
| 272 SetSendResult(net_result, -1); | 272 SetSendResult(net_result, -1); |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 void SocketsUdpSendFunction::SetSendResult(int net_result, int bytes_sent) { | 276 void SocketsUdpSendFunction::SetSendResult(int net_result, int bytes_sent) { |
| 277 CHECK(net_result <= net::OK) << "Network status code must be < 0"; | 277 // Network status code must be < 0 |
| 278 CHECK(net_result <= net::OK); |
| 278 | 279 |
| 279 sockets_udp::SendInfo send_info; | 280 sockets_udp::SendInfo send_info; |
| 280 send_info.result_code = net_result; | 281 send_info.result_code = net_result; |
| 281 if (net_result == net::OK) { | 282 if (net_result == net::OK) { |
| 282 send_info.bytes_sent.reset(new int(bytes_sent)); | 283 send_info.bytes_sent.reset(new int(bytes_sent)); |
| 283 } | 284 } |
| 284 | 285 |
| 285 if (net_result != net::OK) | 286 if (net_result != net::OK) |
| 286 error_ = net::ErrorToString(net_result); | 287 error_ = net::ErrorToString(net_result); |
| 287 results_ = sockets_udp::Send::Results::Create(send_info); | 288 results_ = sockets_udp::Send::Results::Create(send_info); |
| (...skipping 229 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 |