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

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: Addressed Kevin's comments 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
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_statistics.h>
5 #include "blimp/net/blimp_connection.h" 6 #include "blimp/net/blimp_connection.h"
6 7
7 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 #include "blimp/common/logging.h" 13 #include "blimp/common/logging.h"
13 #include "blimp/common/proto/blimp_message.pb.h" 14 #include "blimp/common/proto/blimp_message.pb.h"
14 #include "blimp/net/blimp_message_processor.h" 15 #include "blimp/net/blimp_message_processor.h"
(...skipping 14 matching lines...) Expand all
29 ~BlimpMessageSender() override; 30 ~BlimpMessageSender() override;
30 31
31 void set_error_observer(ConnectionErrorObserver* observer) { 32 void set_error_observer(ConnectionErrorObserver* observer) {
32 error_observer_ = observer; 33 error_observer_ = observer;
33 } 34 }
34 35
35 // BlimpMessageProcessor implementation. 36 // BlimpMessageProcessor implementation.
36 void ProcessMessage(std::unique_ptr<BlimpMessage> message, 37 void ProcessMessage(std::unique_ptr<BlimpMessage> message,
37 const net::CompletionCallback& callback) override; 38 const net::CompletionCallback& callback) override;
38 39
40 void SetBlimpConnectionStatistics(BlimpConnectionStatistics* statistics) {
41 DCHECK(writer_);
42 writer_->set_blimp_connection_statistics(statistics);
43 }
44
39 private: 45 private:
40 void OnWritePacketComplete(int result); 46 void OnWritePacketComplete(int result);
41 47
42 PacketWriter* writer_; 48 PacketWriter* writer_;
43 ConnectionErrorObserver* error_observer_ = nullptr; 49 ConnectionErrorObserver* error_observer_ = nullptr;
44 scoped_refptr<net::IOBuffer> buffer_; 50 scoped_refptr<net::IOBuffer> buffer_;
45 net::CompletionCallback pending_process_msg_callback_; 51 net::CompletionCallback pending_process_msg_callback_;
46 base::WeakPtrFactory<BlimpMessageSender> weak_factory_; 52 base::WeakPtrFactory<BlimpMessageSender> weak_factory_;
47 53
48 DISALLOW_COPY_AND_ASSIGN(BlimpMessageSender); 54 DISALLOW_COPY_AND_ASSIGN(BlimpMessageSender);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void BlimpConnection::RemoveConnectionErrorObserver( 135 void BlimpConnection::RemoveConnectionErrorObserver(
130 ConnectionErrorObserver* observer) { 136 ConnectionErrorObserver* observer) {
131 error_observers_.RemoveObserver(observer); 137 error_observers_.RemoveObserver(observer);
132 } 138 }
133 139
134 void BlimpConnection::SetIncomingMessageProcessor( 140 void BlimpConnection::SetIncomingMessageProcessor(
135 BlimpMessageProcessor* processor) { 141 BlimpMessageProcessor* processor) {
136 message_pump_->SetMessageProcessor(processor); 142 message_pump_->SetMessageProcessor(processor);
137 } 143 }
138 144
145 void BlimpConnection::SetBlimpConnectionStatistics(
146 BlimpConnectionStatistics* statistics) {
147 if (message_pump_) {
Kevin M 2016/05/20 01:02:03 message_pump_ will always be set, ditto for the se
shaktisahu 2016/05/22 22:36:56 Done.
148 message_pump_->SetBlimpConnectionStatistics(statistics);
149 }
150 BlimpMessageSender* sender =
151 static_cast<BlimpMessageSender*>(outgoing_msg_processor_.get());
Kevin M 2016/05/20 01:02:03 Change the type of outgoing_msg_processor_ to a Bl
shaktisahu 2016/05/22 22:36:56 In that case I have to forward declare BlimpMessag
152 if (sender) {
153 sender->SetBlimpConnectionStatistics(statistics);
154 }
155 }
156
139 BlimpMessageProcessor* BlimpConnection::GetOutgoingMessageProcessor() { 157 BlimpMessageProcessor* BlimpConnection::GetOutgoingMessageProcessor() {
140 return outgoing_msg_processor_.get(); 158 return outgoing_msg_processor_.get();
141 } 159 }
142 160
143 void BlimpConnection::OnConnectionError(int error) { 161 void BlimpConnection::OnConnectionError(int error) {
144 VLOG(1) << "OnConnectionError, error=" << error; 162 VLOG(1) << "OnConnectionError, error=" << error;
145 163
146 // Propagate the error to all observers. 164 // Propagate the error to all observers.
147 FOR_EACH_OBSERVER(ConnectionErrorObserver, error_observers_, 165 FOR_EACH_OBSERVER(ConnectionErrorObserver, error_observers_,
148 OnConnectionError(error)); 166 OnConnectionError(error));
149 } 167 }
150 168
151 } // namespace blimp 169 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698