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

Side by Side Diff: blimp/net/blimp_connection.cc

Issue 1452823011: Make PacketReader/PacketWriter interfaces async-only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address wez feedback Created 5 years 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
« no previous file with comments | « no previous file | blimp/net/blimp_connection_unittest.cc » ('j') | blimp/net/blimp_message_pump.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "blimp/net/blimp_connection.h" 5 #include "blimp/net/blimp_connection.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 buffer_->SetOffset(0); 68 buffer_->SetOffset(0);
69 if (!message->SerializeToArray(buffer_->data(), message->ByteSize())) { 69 if (!message->SerializeToArray(buffer_->data(), message->ByteSize())) {
70 DLOG(ERROR) << "Failed to serialize message."; 70 DLOG(ERROR) << "Failed to serialize message.";
71 callback.Run(net::ERR_INVALID_ARGUMENT); 71 callback.Run(net::ERR_INVALID_ARGUMENT);
72 return; 72 return;
73 } 73 }
74 74
75 write_packet_callback_.Reset(base::Bind( 75 write_packet_callback_.Reset(base::Bind(
76 &BlimpMessageSender::OnWritePacketComplete, base::Unretained(this))); 76 &BlimpMessageSender::OnWritePacketComplete, base::Unretained(this)));
77 pending_process_msg_callback_ = callback; 77 pending_process_msg_callback_ = callback;
78 int result = writer_->WritePacket(buffer_, write_packet_callback_.callback()); 78 writer_->WritePacket(buffer_, write_packet_callback_.callback());
79 if (result != net::ERR_IO_PENDING) {
80 base::MessageLoop::current()->PostTask(
81 FROM_HERE, base::Bind(write_packet_callback_.callback(), result));
82 }
83 } 79 }
84 80
85 void BlimpMessageSender::OnWritePacketComplete(int result) { 81 void BlimpMessageSender::OnWritePacketComplete(int result) {
86 DCHECK_NE(net::ERR_IO_PENDING, result); 82 DCHECK_NE(net::ERR_IO_PENDING, result);
87 write_packet_callback_.Cancel(); 83 write_packet_callback_.Cancel();
88 base::ResetAndReturn(&pending_process_msg_callback_).Run(result); 84 base::ResetAndReturn(&pending_process_msg_callback_).Run(result);
89 if (result != net::OK) { 85 if (result != net::OK) {
90 error_observer_->OnConnectionError(result); 86 error_observer_->OnConnectionError(result);
91 } 87 }
92 } 88 }
(...skipping 22 matching lines...) Expand all
115 void BlimpConnection::SetIncomingMessageProcessor( 111 void BlimpConnection::SetIncomingMessageProcessor(
116 BlimpMessageProcessor* processor) { 112 BlimpMessageProcessor* processor) {
117 message_pump_->SetMessageProcessor(processor); 113 message_pump_->SetMessageProcessor(processor);
118 } 114 }
119 115
120 BlimpMessageProcessor* BlimpConnection::GetOutgoingMessageProcessor() const { 116 BlimpMessageProcessor* BlimpConnection::GetOutgoingMessageProcessor() const {
121 return outgoing_msg_processor_.get(); 117 return outgoing_msg_processor_.get();
122 } 118 }
123 119
124 } // namespace blimp 120 } // namespace blimp
OLDNEW
« no previous file with comments | « no previous file | blimp/net/blimp_connection_unittest.cc » ('j') | blimp/net/blimp_message_pump.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698