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

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: Changed implementation to receive synchronous calls 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(new BlimpConnectionStatistics);
178 net_components_.reset(new ClientNetworkComponents(
179 base::WrapUnique(new CrossThreadNetworkEventObserver(
180 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get())),
181 blimp_connection_statistics_.get()));
176 182
177 assignment_source_.reset(new AssignmentSource( 183 assignment_source_.reset(new AssignmentSource(
178 assigner_endpoint, io_thread_.task_runner(), io_thread_.task_runner())); 184 assigner_endpoint, io_thread_.task_runner(), io_thread_.task_runner()));
179 185
180 RegisterFeatures(); 186 RegisterFeatures();
181 187
182 // Initialize must only be posted after the RegisterFeature calls have 188 // Initialize must only be posted after the RegisterFeature calls have
183 // completed. 189 // completed.
184 io_thread_.task_runner()->PostTask( 190 io_thread_.task_runner()->PostTask(
185 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, 191 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize,
186 base::Unretained(net_components_.get()))); 192 base::Unretained(net_components_.get())));
187 } 193 }
188 194
189 BlimpClientSession::~BlimpClientSession() { 195 BlimpClientSession::~BlimpClientSession() {
190 io_thread_.task_runner()->DeleteSoon(FROM_HERE, net_components_.release()); 196 io_thread_.task_runner()->DeleteSoon(FROM_HERE, net_components_.release());
197 io_thread_.task_runner()->DeleteSoon(FROM_HERE,
Kevin M 2016/05/24 01:02:00 Move ownership of the statistics object into net_c
shaktisahu 2016/05/24 21:02:44 Done.
198 blimp_connection_statistics_.release());
191 } 199 }
192 200
193 void BlimpClientSession::Connect(const std::string& client_auth_token) { 201 void BlimpClientSession::Connect(const std::string& client_auth_token) {
194 assignment_source_->GetAssignment( 202 assignment_source_->GetAssignment(
195 client_auth_token, base::Bind(&BlimpClientSession::ConnectWithAssignment, 203 client_auth_token, base::Bind(&BlimpClientSession::ConnectWithAssignment,
196 weak_factory_.GetWeakPtr())); 204 weak_factory_.GetWeakPtr()));
197 } 205 }
198 206
199 void BlimpClientSession::ConnectWithAssignment(AssignmentSource::Result result, 207 void BlimpClientSession::ConnectWithAssignment(AssignmentSource::Result result,
200 const Assignment& assignment) { 208 const Assignment& assignment) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 276 }
269 277
270 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const { 278 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const {
271 return render_widget_feature_.get(); 279 return render_widget_feature_.get();
272 } 280 }
273 281
274 SettingsFeature* BlimpClientSession::GetSettingsFeature() const { 282 SettingsFeature* BlimpClientSession::GetSettingsFeature() const {
275 return settings_feature_.get(); 283 return settings_feature_.get();
276 } 284 }
277 285
286 BlimpConnectionStatistics* BlimpClientSession::GetBlimpConnectionStatistics()
287 const {
288 return blimp_connection_statistics_.get();
289 }
290
278 } // namespace client 291 } // namespace client
279 } // namespace blimp 292 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698