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

Side by Side Diff: blimp/client/session/blimp_client_session.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/client/session/blimp_client_session.h" 5 #include "blimp/client/session/blimp_client_session.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 } // namespace 67 } // namespace
68 68
69 // This class's functions and destruction are all invoked on the IO thread by 69 // This class's functions and destruction are all invoked on the IO thread by
70 // the BlimpClientSession. 70 // the BlimpClientSession.
71 class ClientNetworkComponents : public ConnectionHandler, 71 class ClientNetworkComponents : public ConnectionHandler,
72 public ConnectionErrorObserver { 72 public ConnectionErrorObserver {
73 public: 73 public:
74 // Can be created on any thread. 74 // Can be created on any thread.
75 explicit ClientNetworkComponents( 75 explicit ClientNetworkComponents(
76 std::unique_ptr<NetworkEventObserver> observer); 76 std::unique_ptr<NetworkEventObserver> observer,
77 BlimpConnectionStatistics* blimp_connection_statistics);
77 ~ClientNetworkComponents() override; 78 ~ClientNetworkComponents() override;
78 79
79 // Sets up network components. 80 // Sets up network components.
80 void Initialize(); 81 void Initialize();
81 82
82 // Starts the connection to the engine using the given |assignment|. 83 // Starts the connection to the engine using the given |assignment|.
83 // It is required to first call Initialize. 84 // It is required to first call Initialize.
84 void ConnectWithAssignment(const Assignment& assignment); 85 void ConnectWithAssignment(const Assignment& assignment);
85 86
86 BrowserConnectionHandler* GetBrowserConnectionHandler(); 87 BrowserConnectionHandler* GetBrowserConnectionHandler();
87 88
88 private: 89 private:
89 // ConnectionHandler implementation. 90 // ConnectionHandler implementation.
90 void HandleConnection(std::unique_ptr<BlimpConnection> connection) override; 91 void HandleConnection(std::unique_ptr<BlimpConnection> connection) override;
91 92
92 // ConnectionErrorObserver implementation. 93 // ConnectionErrorObserver implementation.
93 void OnConnectionError(int error) override; 94 void OnConnectionError(int error) override;
94 95
95 std::unique_ptr<BrowserConnectionHandler> connection_handler_; 96 std::unique_ptr<BrowserConnectionHandler> connection_handler_;
96 std::unique_ptr<ClientConnectionManager> connection_manager_; 97 std::unique_ptr<ClientConnectionManager> connection_manager_;
97 std::unique_ptr<NetworkEventObserver> network_observer_; 98 std::unique_ptr<NetworkEventObserver> network_observer_;
99 BlimpConnectionStatistics* connection_statistics_;
98 100
99 DISALLOW_COPY_AND_ASSIGN(ClientNetworkComponents); 101 DISALLOW_COPY_AND_ASSIGN(ClientNetworkComponents);
100 }; 102 };
101 103
102 ClientNetworkComponents::ClientNetworkComponents( 104 ClientNetworkComponents::ClientNetworkComponents(
103 std::unique_ptr<NetworkEventObserver> network_observer) 105 std::unique_ptr<NetworkEventObserver> network_observer,
106 BlimpConnectionStatistics* statistics)
104 : connection_handler_(new BrowserConnectionHandler), 107 : connection_handler_(new BrowserConnectionHandler),
105 network_observer_(std::move(network_observer)) {} 108 network_observer_(std::move(network_observer)),
109 connection_statistics_(statistics) {}
106 110
107 ClientNetworkComponents::~ClientNetworkComponents() {} 111 ClientNetworkComponents::~ClientNetworkComponents() {}
108 112
109 void ClientNetworkComponents::Initialize() { 113 void ClientNetworkComponents::Initialize() {
110 DCHECK(!connection_manager_); 114 DCHECK(!connection_manager_);
111 connection_manager_ = base::WrapUnique(new ClientConnectionManager(this)); 115 connection_manager_ = base::WrapUnique(new ClientConnectionManager(this));
112 } 116 }
113 117
114 void ClientNetworkComponents::ConnectWithAssignment( 118 void ClientNetworkComponents::ConnectWithAssignment(
115 const Assignment& assignment) { 119 const Assignment& assignment) {
(...skipping 27 matching lines...) Expand all
143 BrowserConnectionHandler* 147 BrowserConnectionHandler*
144 ClientNetworkComponents::GetBrowserConnectionHandler() { 148 ClientNetworkComponents::GetBrowserConnectionHandler() {
145 return connection_handler_.get(); 149 return connection_handler_.get();
146 } 150 }
147 151
148 void ClientNetworkComponents::HandleConnection( 152 void ClientNetworkComponents::HandleConnection(
149 std::unique_ptr<BlimpConnection> connection) { 153 std::unique_ptr<BlimpConnection> connection) {
150 VLOG(1) << "Connection established."; 154 VLOG(1) << "Connection established.";
151 connection->AddConnectionErrorObserver(this); 155 connection->AddConnectionErrorObserver(this);
152 network_observer_->OnConnected(); 156 network_observer_->OnConnected();
157 connection->SetBlimpConnectionStatistics(connection_statistics_);
153 connection_handler_->HandleConnection(std::move(connection)); 158 connection_handler_->HandleConnection(std::move(connection));
154 } 159 }
155 160
156 void ClientNetworkComponents::OnConnectionError(int result) { 161 void ClientNetworkComponents::OnConnectionError(int result) {
157 VLOG(1) << "Connection error: " << net::ErrorToString(result); 162 VLOG(1) << "Connection error: " << net::ErrorToString(result);
158 network_observer_->OnDisconnected(result); 163 network_observer_->OnDisconnected(result);
159 } 164 }
160 165
161 BlimpClientSession::BlimpClientSession(const GURL& assigner_endpoint) 166 BlimpClientSession::BlimpClientSession(const GURL& assigner_endpoint)
162 : io_thread_("BlimpIOThread"), 167 : io_thread_("BlimpIOThread"),
163 tab_control_feature_(new TabControlFeature), 168 tab_control_feature_(new TabControlFeature),
164 navigation_feature_(new NavigationFeature), 169 navigation_feature_(new NavigationFeature),
165 ime_feature_(new ImeFeature), 170 ime_feature_(new ImeFeature),
166 render_widget_feature_(new RenderWidgetFeature), 171 render_widget_feature_(new RenderWidgetFeature),
167 settings_feature_(new SettingsFeature), 172 settings_feature_(new SettingsFeature),
168 weak_factory_(this) { 173 weak_factory_(this) {
169 net_components_.reset(new ClientNetworkComponents(
170 base::WrapUnique(new CrossThreadNetworkEventObserver(
171 weak_factory_.GetWeakPtr(),
172 base::SequencedTaskRunnerHandle::Get()))));
173 base::Thread::Options options; 174 base::Thread::Options options;
174 options.message_loop_type = base::MessageLoop::TYPE_IO; 175 options.message_loop_type = base::MessageLoop::TYPE_IO;
175 io_thread_.StartWithOptions(options); 176 io_thread_.StartWithOptions(options);
177 blimp_connection_statistics_.reset(
Kevin M 2016/05/20 01:02:03 Can you move this into ClientNetworkComponents? We
shaktisahu 2016/05/22 22:36:56 This object needs to stay closer to the UI thread
178 new BlimpConnectionStatistics(base::SequencedTaskRunnerHandle::Get()));
179 net_components_.reset(new ClientNetworkComponents(
180 base::WrapUnique(new CrossThreadNetworkEventObserver(
181 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get())),
182 blimp_connection_statistics_.get()));
176 183
177 assignment_source_.reset(new AssignmentSource( 184 assignment_source_.reset(new AssignmentSource(
178 assigner_endpoint, io_thread_.task_runner(), io_thread_.task_runner())); 185 assigner_endpoint, io_thread_.task_runner(), io_thread_.task_runner()));
179 186
180 RegisterFeatures(); 187 RegisterFeatures();
181 188
182 // Initialize must only be posted after the RegisterFeature calls have 189 // Initialize must only be posted after the RegisterFeature calls have
183 // completed. 190 // completed.
184 io_thread_.task_runner()->PostTask( 191 io_thread_.task_runner()->PostTask(
185 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, 192 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize,
186 base::Unretained(net_components_.get()))); 193 base::Unretained(net_components_.get())));
187 } 194 }
188 195
189 BlimpClientSession::~BlimpClientSession() { 196 BlimpClientSession::~BlimpClientSession() {
190 io_thread_.task_runner()->DeleteSoon(FROM_HERE, net_components_.release()); 197 io_thread_.task_runner()->DeleteSoon(FROM_HERE, net_components_.release());
198 io_thread_.task_runner()->DeleteSoon(FROM_HERE,
199 blimp_connection_statistics_.release());
191 } 200 }
192 201
193 void BlimpClientSession::Connect(const std::string& client_auth_token) { 202 void BlimpClientSession::Connect(const std::string& client_auth_token) {
194 assignment_source_->GetAssignment( 203 assignment_source_->GetAssignment(
195 client_auth_token, base::Bind(&BlimpClientSession::ConnectWithAssignment, 204 client_auth_token, base::Bind(&BlimpClientSession::ConnectWithAssignment,
196 weak_factory_.GetWeakPtr())); 205 weak_factory_.GetWeakPtr()));
197 } 206 }
198 207
199 void BlimpClientSession::ConnectWithAssignment(AssignmentSource::Result result, 208 void BlimpClientSession::ConnectWithAssignment(AssignmentSource::Result result,
200 const Assignment& assignment) { 209 const Assignment& assignment) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // Client will not send send any RenderWidget messages, so don't save the 253 // Client will not send send any RenderWidget messages, so don't save the
245 // outgoing BlimpMessageProcessor in the RenderWidgetFeature. 254 // outgoing BlimpMessageProcessor in the RenderWidgetFeature.
246 thread_pipe_manager_->RegisterFeature(BlimpMessage::RENDER_WIDGET, 255 thread_pipe_manager_->RegisterFeature(BlimpMessage::RENDER_WIDGET,
247 render_widget_feature_.get()); 256 render_widget_feature_.get());
248 257
249 ime_feature_->set_outgoing_message_processor( 258 ime_feature_->set_outgoing_message_processor(
250 thread_pipe_manager_->RegisterFeature(BlimpMessage::IME, 259 thread_pipe_manager_->RegisterFeature(BlimpMessage::IME,
251 ime_feature_.get())); 260 ime_feature_.get()));
252 } 261 }
253 262
263 void BlimpClientSession::GetDebugInfo() {
264 blimp_connection_statistics_->GetDebugInfo(base::Bind(
265 &BlimpClientSession::UpdateDebugInfo, weak_factory_.GetWeakPtr()));
266 }
267
268 void BlimpClientSession::UpdateDebugInfo(
269 BlimpConnectionStatistics::StatisticsMap stats) {}
270
254 void BlimpClientSession::OnConnected() {} 271 void BlimpClientSession::OnConnected() {}
255 272
256 void BlimpClientSession::OnDisconnected(int result) {} 273 void BlimpClientSession::OnDisconnected(int result) {}
257 274
258 TabControlFeature* BlimpClientSession::GetTabControlFeature() const { 275 TabControlFeature* BlimpClientSession::GetTabControlFeature() const {
259 return tab_control_feature_.get(); 276 return tab_control_feature_.get();
260 } 277 }
261 278
262 NavigationFeature* BlimpClientSession::GetNavigationFeature() const { 279 NavigationFeature* BlimpClientSession::GetNavigationFeature() const {
263 return navigation_feature_.get(); 280 return navigation_feature_.get();
264 } 281 }
265 282
266 ImeFeature* BlimpClientSession::GetImeFeature() const { 283 ImeFeature* BlimpClientSession::GetImeFeature() const {
267 return ime_feature_.get(); 284 return ime_feature_.get();
268 } 285 }
269 286
270 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const { 287 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const {
271 return render_widget_feature_.get(); 288 return render_widget_feature_.get();
272 } 289 }
273 290
274 SettingsFeature* BlimpClientSession::GetSettingsFeature() const { 291 SettingsFeature* BlimpClientSession::GetSettingsFeature() const {
275 return settings_feature_.get(); 292 return settings_feature_.get();
276 } 293 }
277 294
295 BlimpConnectionStatistics* BlimpClientSession::GetBlimpConnectionStatistics()
Kevin M 2016/05/20 01:02:03 This is risky - we are exposing an IO thread membe
shaktisahu 2016/05/22 22:36:56 Yea, but if it lives on UI thread and is called fr
296 const {
297 return blimp_connection_statistics_.get();
298 }
299
278 } // namespace client 300 } // namespace client
279 } // namespace blimp 301 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698