Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: extensions/browser/api/socket/socket_api.cc

Issue 2336843002: Decompose //extensions/browser/BUILD.gn (Closed)
Patch Set: unending win fixes Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 545
546 void SocketWriteFunction::AsyncWorkStart() { 546 void SocketWriteFunction::AsyncWorkStart() {
547 Socket* socket = GetSocket(socket_id_); 547 Socket* socket = GetSocket(socket_id_);
548 548
549 if (!socket) { 549 if (!socket) {
550 error_ = kSocketNotFoundError; 550 error_ = kSocketNotFoundError;
551 OnCompleted(-1); 551 OnCompleted(-1);
552 return; 552 return;
553 } 553 }
554 554
555 socket->Write(io_buffer_, 555 socket->Write(io_buffer_, static_cast<int>(io_buffer_size_),
556 io_buffer_size_,
557 base::Bind(&SocketWriteFunction::OnCompleted, this)); 556 base::Bind(&SocketWriteFunction::OnCompleted, this));
558 } 557 }
559 558
560 void SocketWriteFunction::OnCompleted(int bytes_written) { 559 void SocketWriteFunction::OnCompleted(int bytes_written) {
561 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 560 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
562 result->SetInteger(kBytesWrittenKey, bytes_written); 561 result->SetInteger(kBytesWrittenKey, bytes_written);
563 SetResult(std::move(result)); 562 SetResult(std::move(result));
564 563
565 AsyncWorkCompleted(); 564 AsyncWorkCompleted();
566 } 565 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 665
667 void SocketSendToFunction::StartSendTo() { 666 void SocketSendToFunction::StartSendTo() {
668 Socket* socket = GetSocket(socket_id_); 667 Socket* socket = GetSocket(socket_id_);
669 if (!socket) { 668 if (!socket) {
670 error_ = kSocketNotFoundError; 669 error_ = kSocketNotFoundError;
671 SetResult(base::MakeUnique<base::FundamentalValue>(-1)); 670 SetResult(base::MakeUnique<base::FundamentalValue>(-1));
672 AsyncWorkCompleted(); 671 AsyncWorkCompleted();
673 return; 672 return;
674 } 673 }
675 674
676 socket->SendTo(io_buffer_, io_buffer_size_, addresses_.front(), 675 socket->SendTo(io_buffer_, static_cast<int>(io_buffer_size_),
676 addresses_.front(),
677 base::Bind(&SocketSendToFunction::OnCompleted, this)); 677 base::Bind(&SocketSendToFunction::OnCompleted, this));
678 } 678 }
679 679
680 void SocketSendToFunction::OnCompleted(int bytes_written) { 680 void SocketSendToFunction::OnCompleted(int bytes_written) {
681 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 681 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
682 result->SetInteger(kBytesWrittenKey, bytes_written); 682 result->SetInteger(kBytesWrittenKey, bytes_written);
683 SetResult(std::move(result)); 683 SetResult(std::move(result));
684 684
685 AsyncWorkCompleted(); 685 AsyncWorkCompleted();
686 } 686 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 } else { 1089 } else {
1090 RemoveSocket(params_->socket_id); 1090 RemoveSocket(params_->socket_id);
1091 error_ = net::ErrorToString(result); 1091 error_ = net::ErrorToString(result);
1092 } 1092 }
1093 1093
1094 results_ = api::socket::Secure::Results::Create(result); 1094 results_ = api::socket::Secure::Results::Create(result);
1095 AsyncWorkCompleted(); 1095 AsyncWorkCompleted();
1096 } 1096 }
1097 1097
1098 } // namespace extensions 1098 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698