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

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

Issue 2008283004: Revert of Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 {
23 24
24 // Forwards incoming blimp messages to PacketWriter. 25 // Forwards incoming blimp messages to PacketWriter.
25 class BlimpMessageSender : public BlimpMessageProcessor { 26 class BlimpMessageSender : public BlimpMessageProcessor {
26 public: 27 public:
27 explicit BlimpMessageSender(PacketWriter* writer); 28 explicit BlimpMessageSender(PacketWriter* writer);
28 ~BlimpMessageSender() override; 29 ~BlimpMessageSender() override;
29 30
30 void set_error_observer(ConnectionErrorObserver* observer) { 31 void set_error_observer(ConnectionErrorObserver* observer) {
31 error_observer_ = observer; 32 error_observer_ = observer;
32 } 33 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 90
90 void BlimpMessageSender::OnWritePacketComplete(int result) { 91 void BlimpMessageSender::OnWritePacketComplete(int result) {
91 DVLOG(2) << "OnWritePacketComplete, result=" << result; 92 DVLOG(2) << "OnWritePacketComplete, result=" << result;
92 DCHECK_NE(net::ERR_IO_PENDING, result); 93 DCHECK_NE(net::ERR_IO_PENDING, result);
93 base::ResetAndReturn(&pending_process_msg_callback_).Run(result); 94 base::ResetAndReturn(&pending_process_msg_callback_).Run(result);
94 if (result != net::OK) { 95 if (result != net::OK) {
95 error_observer_->OnConnectionError(result); 96 error_observer_->OnConnectionError(result);
96 } 97 }
97 } 98 }
98 99
100 } // namespace
101
99 BlimpConnection::BlimpConnection(std::unique_ptr<PacketReader> reader, 102 BlimpConnection::BlimpConnection(std::unique_ptr<PacketReader> reader,
100 std::unique_ptr<PacketWriter> writer) 103 std::unique_ptr<PacketWriter> writer)
101 : reader_(std::move(reader)), 104 : reader_(std::move(reader)),
102 message_pump_(new BlimpMessagePump(reader_.get())), 105 message_pump_(new BlimpMessagePump(reader_.get())),
103 writer_(std::move(writer)), 106 writer_(std::move(writer)),
104 outgoing_msg_processor_(new BlimpMessageSender(writer_.get())) { 107 outgoing_msg_processor_(new BlimpMessageSender(writer_.get())) {
105 DCHECK(writer_); 108 DCHECK(writer_);
106 109
107 // Observe the connection errors received by any of this connection's network 110 // Observe the connection errors received by any of this connection's network
108 // objects. 111 // objects.
109 message_pump_->set_error_observer(this); 112 message_pump_->set_error_observer(this);
110 outgoing_msg_processor_->set_error_observer(this); 113 BlimpMessageSender* sender =
114 static_cast<BlimpMessageSender*>(outgoing_msg_processor_.get());
115 sender->set_error_observer(this);
111 } 116 }
112 117
113 BlimpConnection::BlimpConnection() {} 118 BlimpConnection::BlimpConnection() {}
114 119
115 BlimpConnection::~BlimpConnection() { 120 BlimpConnection::~BlimpConnection() {
116 VLOG(1) << "BlimpConnection destroyed."; 121 VLOG(1) << "BlimpConnection destroyed.";
117 } 122 }
118 123
119 void BlimpConnection::AddConnectionErrorObserver( 124 void BlimpConnection::AddConnectionErrorObserver(
120 ConnectionErrorObserver* observer) { 125 ConnectionErrorObserver* observer) {
(...skipping 16 matching lines...) Expand all
137 142
138 void BlimpConnection::OnConnectionError(int error) { 143 void BlimpConnection::OnConnectionError(int error) {
139 VLOG(1) << "OnConnectionError, error=" << error; 144 VLOG(1) << "OnConnectionError, error=" << error;
140 145
141 // Propagate the error to all observers. 146 // Propagate the error to all observers.
142 FOR_EACH_OBSERVER(ConnectionErrorObserver, error_observers_, 147 FOR_EACH_OBSERVER(ConnectionErrorObserver, error_observers_,
143 OnConnectionError(error)); 148 OnConnectionError(error));
144 } 149 }
145 150
146 } // namespace blimp 151 } // 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