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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 | 515 |
516 void SocketReadFunction::OnCompleted(int bytes_read, | 516 void SocketReadFunction::OnCompleted(int bytes_read, |
517 scoped_refptr<net::IOBuffer> io_buffer, | 517 scoped_refptr<net::IOBuffer> io_buffer, |
518 bool socket_destroying) { | 518 bool socket_destroying) { |
519 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 519 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
520 result->SetInteger(kResultCodeKey, bytes_read); | 520 result->SetInteger(kResultCodeKey, bytes_read); |
521 if (bytes_read > 0) { | 521 if (bytes_read > 0) { |
522 result->Set(kDataKey, base::Value::CreateWithCopiedBuffer(io_buffer->data(), | 522 result->Set(kDataKey, base::Value::CreateWithCopiedBuffer(io_buffer->data(), |
523 bytes_read)); | 523 bytes_read)); |
524 } else { | 524 } else { |
525 result->Set(kDataKey, new base::Value(base::Value::Type::BINARY)); | 525 result->Set(kDataKey, |
| 526 base::MakeUnique<base::Value>(base::Value::Type::BINARY)); |
526 } | 527 } |
527 SetResult(std::move(result)); | 528 SetResult(std::move(result)); |
528 | 529 |
529 AsyncWorkCompleted(); | 530 AsyncWorkCompleted(); |
530 } | 531 } |
531 | 532 |
532 SocketWriteFunction::SocketWriteFunction() | 533 SocketWriteFunction::SocketWriteFunction() |
533 : socket_id_(0), io_buffer_(NULL), io_buffer_size_(0) {} | 534 : socket_id_(0), io_buffer_(NULL), io_buffer_size_(0) {} |
534 | 535 |
535 SocketWriteFunction::~SocketWriteFunction() {} | 536 SocketWriteFunction::~SocketWriteFunction() {} |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 } else { | 1088 } else { |
1088 RemoveSocket(params_->socket_id); | 1089 RemoveSocket(params_->socket_id); |
1089 error_ = net::ErrorToString(result); | 1090 error_ = net::ErrorToString(result); |
1090 } | 1091 } |
1091 | 1092 |
1092 results_ = api::socket::Secure::Results::Create(result); | 1093 results_ = api::socket::Secure::Results::Create(result); |
1093 AsyncWorkCompleted(); | 1094 AsyncWorkCompleted(); |
1094 } | 1095 } |
1095 | 1096 |
1096 } // namespace extensions | 1097 } // namespace extensions |
OLD | NEW |