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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, | 522 result->Set(kDataKey, |
523 base::BinaryValue::CreateWithCopiedBuffer(io_buffer->data(), | 523 base::BinaryValue::CreateWithCopiedBuffer(io_buffer->data(), |
524 bytes_read)); | 524 bytes_read)); |
525 } else { | 525 } else { |
526 result->Set(kDataKey, new base::BinaryValue()); | 526 result->Set(kDataKey, new base::Value(base::Value::Type::BINARY)); |
527 } | 527 } |
528 SetResult(std::move(result)); | 528 SetResult(std::move(result)); |
529 | 529 |
530 AsyncWorkCompleted(); | 530 AsyncWorkCompleted(); |
531 } | 531 } |
532 | 532 |
533 SocketWriteFunction::SocketWriteFunction() | 533 SocketWriteFunction::SocketWriteFunction() |
534 : socket_id_(0), io_buffer_(NULL), io_buffer_size_(0) {} | 534 : socket_id_(0), io_buffer_(NULL), io_buffer_size_(0) {} |
535 | 535 |
536 SocketWriteFunction::~SocketWriteFunction() {} | 536 SocketWriteFunction::~SocketWriteFunction() {} |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, | 600 result->Set(kDataKey, |
601 base::BinaryValue::CreateWithCopiedBuffer(io_buffer->data(), | 601 base::BinaryValue::CreateWithCopiedBuffer(io_buffer->data(), |
602 bytes_read)); | 602 bytes_read)); |
603 } else { | 603 } else { |
604 result->Set(kDataKey, new base::BinaryValue()); | 604 result->Set(kDataKey, new base::Value(base::Value::Type::BINARY)); |
605 } | 605 } |
606 result->SetString(kAddressKey, address); | 606 result->SetString(kAddressKey, address); |
607 result->SetInteger(kPortKey, port); | 607 result->SetInteger(kPortKey, port); |
608 SetResult(std::move(result)); | 608 SetResult(std::move(result)); |
609 | 609 |
610 AsyncWorkCompleted(); | 610 AsyncWorkCompleted(); |
611 } | 611 } |
612 | 612 |
613 SocketSendToFunction::SocketSendToFunction() | 613 SocketSendToFunction::SocketSendToFunction() |
614 : 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 } else { | 1092 } else { |
1093 RemoveSocket(params_->socket_id); | 1093 RemoveSocket(params_->socket_id); |
1094 error_ = net::ErrorToString(result); | 1094 error_ = net::ErrorToString(result); |
1095 } | 1095 } |
1096 | 1096 |
1097 results_ = api::socket::Secure::Results::Create(result); | 1097 results_ = api::socket::Secure::Results::Create(result); |
1098 AsyncWorkCompleted(); | 1098 AsyncWorkCompleted(); |
1099 } | 1099 } |
1100 | 1100 |
1101 } // namespace extensions | 1101 } // namespace extensions |
OLD | NEW |