| 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_tcp/sockets_tcp_api.h" | 5 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
| 9 #include "content/public/browser/storage_partition.h" | 9 #include "content/public/browser/storage_partition.h" |
| 10 #include "content/public/common/socket_permission_request.h" | 10 #include "content/public/common/socket_permission_request.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 363 |
| 364 void SocketsTcpSendFunction::OnCompleted(int net_result) { | 364 void SocketsTcpSendFunction::OnCompleted(int net_result) { |
| 365 if (net_result >= net::OK) { | 365 if (net_result >= net::OK) { |
| 366 SetSendResult(net::OK, net_result); | 366 SetSendResult(net::OK, net_result); |
| 367 } else { | 367 } else { |
| 368 SetSendResult(net_result, -1); | 368 SetSendResult(net_result, -1); |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 | 371 |
| 372 void SocketsTcpSendFunction::SetSendResult(int net_result, int bytes_sent) { | 372 void SocketsTcpSendFunction::SetSendResult(int net_result, int bytes_sent) { |
| 373 CHECK(net_result <= net::OK) << "Network status code must be <= net::OK"; | 373 // Network status code must be <= net::OK |
| 374 CHECK(net_result <= net::OK); |
| 374 | 375 |
| 375 sockets_tcp::SendInfo send_info; | 376 sockets_tcp::SendInfo send_info; |
| 376 send_info.result_code = net_result; | 377 send_info.result_code = net_result; |
| 377 if (net_result == net::OK) { | 378 if (net_result == net::OK) { |
| 378 send_info.bytes_sent.reset(new int(bytes_sent)); | 379 send_info.bytes_sent.reset(new int(bytes_sent)); |
| 379 } | 380 } |
| 380 | 381 |
| 381 if (net_result != net::OK) | 382 if (net_result != net::OK) |
| 382 error_ = net::ErrorToString(net_result); | 383 error_ = net::ErrorToString(net_result); |
| 383 results_ = sockets_tcp::Send::Results::Create(send_info); | 384 results_ = sockets_tcp::Send::Results::Create(send_info); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 RemoveSocket(params_->socket_id); | 539 RemoveSocket(params_->socket_id); |
| 539 error_ = net::ErrorToString(result); | 540 error_ = net::ErrorToString(result); |
| 540 } | 541 } |
| 541 | 542 |
| 542 results_ = api::sockets_tcp::Secure::Results::Create(result); | 543 results_ = api::sockets_tcp::Secure::Results::Create(result); |
| 543 AsyncWorkCompleted(); | 544 AsyncWorkCompleted(); |
| 544 } | 545 } |
| 545 | 546 |
| 546 } // namespace api | 547 } // namespace api |
| 547 } // namespace extensions | 548 } // namespace extensions |
| OLD | NEW |