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

Side by Side Diff: blimp/client/core/blimp_client_context_impl.cc

Issue 2322843002: Propagate connection info to Blimp android UI. (Closed)
Patch Set: git cl format.... Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/core/blimp_client_context_impl.h" 5 #include "blimp/client/core/blimp_client_context_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 tab_control_feature_(new TabControlFeature), 82 tab_control_feature_(new TabControlFeature),
83 blimp_contents_manager_( 83 blimp_contents_manager_(
84 new BlimpContentsManager(blimp_compositor_dependencies_.get(), 84 new BlimpContentsManager(blimp_compositor_dependencies_.get(),
85 ime_feature_.get(), 85 ime_feature_.get(),
86 navigation_feature_.get(), 86 navigation_feature_.get(),
87 render_widget_feature_.get(), 87 render_widget_feature_.get(),
88 tab_control_feature_.get())), 88 tab_control_feature_.get())),
89 weak_factory_(this) { 89 weak_factory_(this) {
90 net_components_.reset(new ClientNetworkComponents( 90 net_components_.reset(new ClientNetworkComponents(
91 base::MakeUnique<CrossThreadNetworkEventObserver>( 91 base::MakeUnique<CrossThreadNetworkEventObserver>(
92 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()))); 92 connection_status_.GetWeakPtr(),
93 base::SequencedTaskRunnerHandle::Get())));
93 94
94 // The |thread_pipe_manager_| must be set up correctly before features are 95 // The |thread_pipe_manager_| must be set up correctly before features are
95 // registered. 96 // registered.
96 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( 97 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>(
97 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); 98 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler());
98 99
99 RegisterFeatures(); 100 RegisterFeatures();
100 InitializeSettings(); 101 InitializeSettings();
101 102
102 // Initialize must only be posted after the features have been 103 // Initialize must only be posted after the features have been
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_)); 137 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_));
137 } 138 }
138 139
139 VLOG(1) << "Trying to get assignment."; 140 VLOG(1) << "Trying to get assignment.";
140 assignment_source_->GetAssignment( 141 assignment_source_->GetAssignment(
141 client_auth_token, 142 client_auth_token,
142 base::Bind(&BlimpClientContextImpl::ConnectWithAssignment, 143 base::Bind(&BlimpClientContextImpl::ConnectWithAssignment,
143 weak_factory_.GetWeakPtr())); 144 weak_factory_.GetWeakPtr()));
144 } 145 }
145 146
146 void BlimpClientContextImpl::OnConnected() {}
147
148 void BlimpClientContextImpl::OnDisconnected(int result) {}
149
150 GURL BlimpClientContextImpl::GetAssignerURL() { 147 GURL BlimpClientContextImpl::GetAssignerURL() {
151 return GURL(kDefaultAssignerUrl); 148 return GURL(kDefaultAssignerUrl);
152 } 149 }
153 150
154 IdentitySource* BlimpClientContextImpl::GetIdentitySource() { 151 IdentitySource* BlimpClientContextImpl::GetIdentitySource() {
155 if (!identity_source_) { 152 if (!identity_source_) {
156 CreateIdentitySource(); 153 CreateIdentitySource();
157 } 154 }
158 return identity_source_.get(); 155 return identity_source_.get();
159 } 156 }
160 157
158 ConnectionStatus* BlimpClientContextImpl::GetConnectionStatus() {
159 return &connection_status_;
160 }
161
161 void BlimpClientContextImpl::ConnectWithAssignment( 162 void BlimpClientContextImpl::ConnectWithAssignment(
162 AssignmentRequestResult result, 163 AssignmentRequestResult result,
163 const Assignment& assignment) { 164 const Assignment& assignment) {
164 VLOG(1) << "Assignment result: " << result; 165 VLOG(1) << "Assignment result: " << result;
165 166
167 // Cache engine info.
168 connection_status_.OnAssignmentResult(result, assignment);
169
170 // Inform the embedder of the assignment result.
166 if (delegate_) { 171 if (delegate_) {
167 delegate_->OnAssignmentConnectionAttempted(result, assignment); 172 delegate_->OnAssignmentConnectionAttempted(result, assignment);
168 } 173 }
169 174
170 if (result != ASSIGNMENT_REQUEST_RESULT_OK) { 175 if (result != ASSIGNMENT_REQUEST_RESULT_OK) {
171 LOG(ERROR) << "Assignment failed, reason: " << result; 176 LOG(ERROR) << "Assignment failed, reason: " << result;
172 return; 177 return;
173 } 178 }
174 179
180 // If we get the assignment, connect to engine.
175 io_thread_task_runner_->PostTask( 181 io_thread_task_runner_->PostTask(
176 FROM_HERE, 182 FROM_HERE,
177 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, 183 base::Bind(&ClientNetworkComponents::ConnectWithAssignment,
178 base::Unretained(net_components_.get()), assignment)); 184 base::Unretained(net_components_.get()), assignment));
179 } 185 }
180 186
181 void BlimpClientContextImpl::RegisterFeatures() { 187 void BlimpClientContextImpl::RegisterFeatures() {
182 // Register features' message senders and receivers. 188 // Register features' message senders and receivers.
183 thread_pipe_manager_->RegisterFeature(BlimpMessage::kBlobChannel, 189 thread_pipe_manager_->RegisterFeature(BlimpMessage::kBlobChannel,
184 blob_channel_feature_.get()); 190 blob_channel_feature_.get());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // Currently we just drop the connection on image decoding error. 229 // Currently we just drop the connection on image decoding error.
224 io_thread_task_runner_->PostTask( 230 io_thread_task_runner_->PostTask(
225 FROM_HERE, 231 FROM_HERE,
226 base::Bind( 232 base::Bind(
227 &BrowserConnectionHandler::DropCurrentConnection, 233 &BrowserConnectionHandler::DropCurrentConnection,
228 base::Unretained(net_components_->GetBrowserConnectionHandler()))); 234 base::Unretained(net_components_->GetBrowserConnectionHandler())));
229 } 235 }
230 236
231 } // namespace client 237 } // namespace client
232 } // namespace blimp 238 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698