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

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

Issue 2322843002: Propagate connection info to Blimp android UI. (Closed)
Patch Set: Remove BlimpStringUtil after discussion of string res files. 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_)); 136 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_));
137 } 137 }
138 138
139 VLOG(1) << "Trying to get assignment."; 139 VLOG(1) << "Trying to get assignment.";
140 assignment_source_->GetAssignment( 140 assignment_source_->GetAssignment(
141 client_auth_token, 141 client_auth_token,
142 base::Bind(&BlimpClientContextImpl::ConnectWithAssignment, 142 base::Bind(&BlimpClientContextImpl::ConnectWithAssignment,
143 weak_factory_.GetWeakPtr())); 143 weak_factory_.GetWeakPtr()));
144 } 144 }
145 145
146 void BlimpClientContextImpl::OnConnected() {} 146 void BlimpClientContextImpl::OnConnected() {
David Trainor- moved to gerrit 2016/09/09 19:33:47 Get rid of these and make ConnectionStatus the Net
xingliu 2016/09/10 22:45:46 Make sense. Done.
147 connection_status_.OnConnected();
148 }
147 149
148 void BlimpClientContextImpl::OnDisconnected(int result) {} 150 void BlimpClientContextImpl::OnDisconnected(int result) {
151 connection_status_.OnDisconnected(result);
152 }
149 153
150 GURL BlimpClientContextImpl::GetAssignerURL() { 154 GURL BlimpClientContextImpl::GetAssignerURL() {
151 return GURL(kDefaultAssignerUrl); 155 return GURL(kDefaultAssignerUrl);
152 } 156 }
153 157
154 IdentitySource* BlimpClientContextImpl::GetIdentitySource() { 158 IdentitySource* BlimpClientContextImpl::GetIdentitySource() {
155 if (!identity_source_) { 159 if (!identity_source_) {
156 CreateIdentitySource(); 160 CreateIdentitySource();
157 } 161 }
158 return identity_source_.get(); 162 return identity_source_.get();
159 } 163 }
160 164
165 ConnectionStatus* BlimpClientContextImpl::GetConnectionStatus() {
166 return &connection_status_;
167 }
168
161 void BlimpClientContextImpl::ConnectWithAssignment( 169 void BlimpClientContextImpl::ConnectWithAssignment(
162 AssignmentRequestResult result, 170 AssignmentRequestResult result,
163 const Assignment& assignment) { 171 const Assignment& assignment) {
164 VLOG(1) << "Assignment result: " << result; 172 VLOG(1) << "Assignment result: " << result;
165 173
174 // Cache engine info.
175 connection_status_.onAssignmentResult(result, assignment);
176
177 // Inform the embedder of the assignment result.
166 if (delegate_) { 178 if (delegate_) {
167 delegate_->OnAssignmentConnectionAttempted(result, assignment); 179 delegate_->OnAssignmentConnectionAttempted(result, assignment);
168 } 180 }
169 181
170 if (result != ASSIGNMENT_REQUEST_RESULT_OK) { 182 if (result != ASSIGNMENT_REQUEST_RESULT_OK) {
171 LOG(ERROR) << "Assignment failed, reason: " << result; 183 LOG(ERROR) << "Assignment failed, reason: " << result;
172 return; 184 return;
173 } 185 }
174 186
187 // If we get the assignment, connect to engine.
175 io_thread_task_runner_->PostTask( 188 io_thread_task_runner_->PostTask(
176 FROM_HERE, 189 FROM_HERE,
177 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, 190 base::Bind(&ClientNetworkComponents::ConnectWithAssignment,
178 base::Unretained(net_components_.get()), assignment)); 191 base::Unretained(net_components_.get()), assignment));
179 } 192 }
180 193
181 void BlimpClientContextImpl::RegisterFeatures() { 194 void BlimpClientContextImpl::RegisterFeatures() {
182 // Register features' message senders and receivers. 195 // Register features' message senders and receivers.
183 thread_pipe_manager_->RegisterFeature(BlimpMessage::kBlobChannel, 196 thread_pipe_manager_->RegisterFeature(BlimpMessage::kBlobChannel,
184 blob_channel_feature_.get()); 197 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. 236 // Currently we just drop the connection on image decoding error.
224 io_thread_task_runner_->PostTask( 237 io_thread_task_runner_->PostTask(
225 FROM_HERE, 238 FROM_HERE,
226 base::Bind( 239 base::Bind(
227 &BrowserConnectionHandler::DropCurrentConnection, 240 &BrowserConnectionHandler::DropCurrentConnection,
228 base::Unretained(net_components_->GetBrowserConnectionHandler()))); 241 base::Unretained(net_components_->GetBrowserConnectionHandler())));
229 } 242 }
230 243
231 } // namespace client 244 } // namespace client
232 } // namespace blimp 245 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698