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

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

Issue 1962393004: Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added empty implementation for linux client Created 4 years, 7 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
« no previous file with comments | « blimp/net/blimp_connection.h ('k') | blimp/net/blimp_connection_statistics.h » ('j') | no next file with comments »
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/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "blimp/common/logging.h" 12 #include "blimp/common/logging.h"
13 #include "blimp/common/proto/blimp_message.pb.h" 13 #include "blimp/common/proto/blimp_message.pb.h"
14 #include "blimp/net/blimp_message_processor.h" 14 #include "blimp/net/blimp_message_processor.h"
15 #include "blimp/net/blimp_message_pump.h" 15 #include "blimp/net/blimp_message_pump.h"
16 #include "blimp/net/common.h" 16 #include "blimp/net/common.h"
17 #include "blimp/net/connection_error_observer.h" 17 #include "blimp/net/connection_error_observer.h"
18 #include "blimp/net/packet_reader.h" 18 #include "blimp/net/packet_reader.h"
19 #include "blimp/net/packet_writer.h" 19 #include "blimp/net/packet_writer.h"
20 #include "net/base/completion_callback.h" 20 #include "net/base/completion_callback.h"
21 21
22 namespace blimp { 22 namespace blimp {
23 namespace {
24 23
25 // Forwards incoming blimp messages to PacketWriter. 24 // Forwards incoming blimp messages to PacketWriter.
26 class BlimpMessageSender : public BlimpMessageProcessor { 25 class BlimpMessageSender : public BlimpMessageProcessor {
27 public: 26 public:
28 explicit BlimpMessageSender(PacketWriter* writer); 27 explicit BlimpMessageSender(PacketWriter* writer);
29 ~BlimpMessageSender() override; 28 ~BlimpMessageSender() override;
30 29
31 void set_error_observer(ConnectionErrorObserver* observer) { 30 void set_error_observer(ConnectionErrorObserver* observer) {
32 error_observer_ = observer; 31 error_observer_ = observer;
33 } 32 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 89
91 void BlimpMessageSender::OnWritePacketComplete(int result) { 90 void BlimpMessageSender::OnWritePacketComplete(int result) {
92 DVLOG(2) << "OnWritePacketComplete, result=" << result; 91 DVLOG(2) << "OnWritePacketComplete, result=" << result;
93 DCHECK_NE(net::ERR_IO_PENDING, result); 92 DCHECK_NE(net::ERR_IO_PENDING, result);
94 base::ResetAndReturn(&pending_process_msg_callback_).Run(result); 93 base::ResetAndReturn(&pending_process_msg_callback_).Run(result);
95 if (result != net::OK) { 94 if (result != net::OK) {
96 error_observer_->OnConnectionError(result); 95 error_observer_->OnConnectionError(result);
97 } 96 }
98 } 97 }
99 98
100 } // namespace
101
102 BlimpConnection::BlimpConnection(std::unique_ptr<PacketReader> reader, 99 BlimpConnection::BlimpConnection(std::unique_ptr<PacketReader> reader,
103 std::unique_ptr<PacketWriter> writer) 100 std::unique_ptr<PacketWriter> writer)
104 : reader_(std::move(reader)), 101 : reader_(std::move(reader)),
105 message_pump_(new BlimpMessagePump(reader_.get())), 102 message_pump_(new BlimpMessagePump(reader_.get())),
106 writer_(std::move(writer)), 103 writer_(std::move(writer)),
107 outgoing_msg_processor_(new BlimpMessageSender(writer_.get())) { 104 outgoing_msg_processor_(new BlimpMessageSender(writer_.get())) {
108 DCHECK(writer_); 105 DCHECK(writer_);
109 106
110 // Observe the connection errors received by any of this connection's network 107 // Observe the connection errors received by any of this connection's network
111 // objects. 108 // objects.
112 message_pump_->set_error_observer(this); 109 message_pump_->set_error_observer(this);
113 BlimpMessageSender* sender = 110 outgoing_msg_processor_->set_error_observer(this);
114 static_cast<BlimpMessageSender*>(outgoing_msg_processor_.get());
115 sender->set_error_observer(this);
116 } 111 }
117 112
118 BlimpConnection::BlimpConnection() {} 113 BlimpConnection::BlimpConnection() {}
119 114
120 BlimpConnection::~BlimpConnection() { 115 BlimpConnection::~BlimpConnection() {
121 VLOG(1) << "BlimpConnection destroyed."; 116 VLOG(1) << "BlimpConnection destroyed.";
122 } 117 }
123 118
124 void BlimpConnection::AddConnectionErrorObserver( 119 void BlimpConnection::AddConnectionErrorObserver(
125 ConnectionErrorObserver* observer) { 120 ConnectionErrorObserver* observer) {
(...skipping 16 matching lines...) Expand all
142 137
143 void BlimpConnection::OnConnectionError(int error) { 138 void BlimpConnection::OnConnectionError(int error) {
144 VLOG(1) << "OnConnectionError, error=" << error; 139 VLOG(1) << "OnConnectionError, error=" << error;
145 140
146 // Propagate the error to all observers. 141 // Propagate the error to all observers.
147 FOR_EACH_OBSERVER(ConnectionErrorObserver, error_observers_, 142 FOR_EACH_OBSERVER(ConnectionErrorObserver, error_observers_,
148 OnConnectionError(error)); 143 OnConnectionError(error));
149 } 144 }
150 145
151 } // namespace blimp 146 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/blimp_connection.h ('k') | blimp/net/blimp_connection_statistics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698