| 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/socket/socket_api.h" | 5 #include "extensions/browser/api/socket/socket_api.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 scoped_refptr<net::IOBuffer> io_buffer, | 593 scoped_refptr<net::IOBuffer> io_buffer, |
| 594 bool socket_destroying, | 594 bool socket_destroying, |
| 595 const std::string& address, | 595 const std::string& address, |
| 596 uint16_t port) { | 596 uint16_t port) { |
| 597 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 597 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 598 result->SetInteger(kResultCodeKey, bytes_read); | 598 result->SetInteger(kResultCodeKey, bytes_read); |
| 599 if (bytes_read > 0) { | 599 if (bytes_read > 0) { |
| 600 result->Set(kDataKey, base::Value::CreateWithCopiedBuffer(io_buffer->data(), | 600 result->Set(kDataKey, base::Value::CreateWithCopiedBuffer(io_buffer->data(), |
| 601 bytes_read)); | 601 bytes_read)); |
| 602 } else { | 602 } else { |
| 603 result->Set(kDataKey, new base::Value(base::Value::Type::BINARY)); | 603 result->Set(kDataKey, |
| 604 base::MakeUnique<base::Value>(base::Value::Type::BINARY)); |
| 604 } | 605 } |
| 605 result->SetString(kAddressKey, address); | 606 result->SetString(kAddressKey, address); |
| 606 result->SetInteger(kPortKey, port); | 607 result->SetInteger(kPortKey, port); |
| 607 SetResult(std::move(result)); | 608 SetResult(std::move(result)); |
| 608 | 609 |
| 609 AsyncWorkCompleted(); | 610 AsyncWorkCompleted(); |
| 610 } | 611 } |
| 611 | 612 |
| 612 SocketSendToFunction::SocketSendToFunction() | 613 SocketSendToFunction::SocketSendToFunction() |
| 613 : socket_id_(0), io_buffer_(NULL), io_buffer_size_(0), port_(0) { | 614 : socket_id_(0), io_buffer_(NULL), io_buffer_size_(0), port_(0) { |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 } else { | 1089 } else { |
| 1089 RemoveSocket(params_->socket_id); | 1090 RemoveSocket(params_->socket_id); |
| 1090 error_ = net::ErrorToString(result); | 1091 error_ = net::ErrorToString(result); |
| 1091 } | 1092 } |
| 1092 | 1093 |
| 1093 results_ = api::socket::Secure::Results::Create(result); | 1094 results_ = api::socket::Secure::Results::Create(result); |
| 1094 AsyncWorkCompleted(); | 1095 AsyncWorkCompleted(); |
| 1095 } | 1096 } |
| 1096 | 1097 |
| 1097 } // namespace extensions | 1098 } // namespace extensions |
| OLD | NEW |