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

Side by Side Diff: blimp/client/session/assignment_source.cc

Issue 1696563002: Blimp: add support for SSL connections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated "running.md" Created 4 years, 10 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/session/assignment_source.h" 5 #include "blimp/client/session/assignment_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h"
10 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
11 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
12 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/memory/ref_counted.h"
13 #include "base/numerics/safe_conversions.h" 15 #include "base/numerics/safe_conversions.h"
14 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/task_runner_util.h"
15 #include "base/values.h" 18 #include "base/values.h"
16 #include "blimp/client/app/blimp_client_switches.h" 19 #include "blimp/client/app/blimp_client_switches.h"
17 #include "blimp/common/protocol_version.h" 20 #include "blimp/common/protocol_version.h"
21 #include "components/safe_json/safe_json_parser.h"
18 #include "net/base/ip_address.h" 22 #include "net/base/ip_address.h"
19 #include "net/base/ip_endpoint.h" 23 #include "net/base/ip_endpoint.h"
20 #include "net/base/load_flags.h" 24 #include "net/base/load_flags.h"
21 #include "net/base/net_errors.h" 25 #include "net/base/net_errors.h"
22 #include "net/base/url_util.h" 26 #include "net/base/url_util.h"
23 #include "net/http/http_status_code.h" 27 #include "net/http/http_status_code.h"
24 #include "net/proxy/proxy_config_service.h" 28 #include "net/proxy/proxy_config_service.h"
25 #include "net/proxy/proxy_service.h" 29 #include "net/proxy/proxy_service.h"
26 #include "net/url_request/url_fetcher.h" 30 #include "net/url_request/url_fetcher.h"
27 #include "net/url_request/url_request_context.h" 31 #include "net/url_request/url_request_context.h"
28 #include "net/url_request/url_request_context_builder.h" 32 #include "net/url_request/url_request_context_builder.h"
29 #include "net/url_request/url_request_context_getter.h" 33 #include "net/url_request/url_request_context_getter.h"
30 34
31 namespace blimp { 35 namespace blimp {
32 namespace client { 36 namespace client {
33 37
34 namespace { 38 namespace {
35 39
36 // Assignment request JSON keys. 40 // Assignment request JSON keys.
37 const char kProtocolVersionKey[] = "protocol_version"; 41 const char kProtocolVersionKey[] = "protocol_version";
38 42
39 // Assignment response JSON keys. 43 // Assignment response JSON keys.
40 const char kClientTokenKey[] = "clientToken"; 44 const char kClientTokenKey[] = "clientToken";
41 const char kHostKey[] = "host"; 45 const char kHostKey[] = "host";
42 const char kPortKey[] = "port"; 46 const char kPortKey[] = "port";
43 const char kCertificateFingerprintKey[] = "certificateFingerprint";
44 const char kCertificateKey[] = "certificate"; 47 const char kCertificateKey[] = "certificate";
45 48
46 // URL scheme constants for custom assignments. See the '--blimplet-endpoint' 49 // URL scheme constants for custom assignments. See the '--blimplet-endpoint'
47 // documentation in blimp_client_switches.cc for details. 50 // documentation in blimp_client_switches.cc for details.
48 const char kCustomSSLScheme[] = "ssl"; 51 const char kCustomSSLScheme[] = "ssl";
49 const char kCustomTCPScheme[] = "tcp"; 52 const char kCustomTCPScheme[] = "tcp";
50 const char kCustomQUICScheme[] = "quic"; 53 const char kCustomQUICScheme[] = "quic";
51 54
52 Assignment GetCustomBlimpletAssignment() {
53 GURL url(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
54 switches::kBlimpletEndpoint));
55
56 std::string host;
57 int port;
58 if (url.is_empty() || !url.is_valid() || !url.has_scheme() ||
59 !net::ParseHostAndPort(url.path(), &host, &port)) {
60 return Assignment();
61 }
62
63 net::IPAddress ip_address;
64 if (!ip_address.AssignFromIPLiteral(host)) {
65 CHECK(false) << "Invalid BlimpletAssignment host " << host;
66 }
67
68 if (!base::IsValueInRangeForNumericType<uint16_t>(port)) {
69 CHECK(false) << "Invalid BlimpletAssignment port " << port;
70 }
71
72 Assignment::TransportProtocol protocol =
73 Assignment::TransportProtocol::UNKNOWN;
74 if (url.has_scheme()) {
75 if (url.SchemeIs(kCustomSSLScheme)) {
76 protocol = Assignment::TransportProtocol::SSL;
77 } else if (url.SchemeIs(kCustomTCPScheme)) {
78 protocol = Assignment::TransportProtocol::TCP;
79 } else if (url.SchemeIs(kCustomQUICScheme)) {
80 protocol = Assignment::TransportProtocol::QUIC;
81 } else {
82 CHECK(false) << "Invalid BlimpletAssignment scheme " << url.scheme();
83 }
84 }
85
86 Assignment assignment;
87 assignment.transport_protocol = protocol;
88 assignment.ip_endpoint = net::IPEndPoint(ip_address, port);
89 assignment.client_token = kDummyClientToken;
90 return assignment;
91 }
92
93 GURL GetBlimpAssignerURL() { 55 GURL GetBlimpAssignerURL() {
94 // TODO(dtrainor): Add a way to specify another assigner. 56 // TODO(dtrainor): Add a way to specify another assigner.
95 return GURL(kDefaultAssignerURL); 57 return GURL(kDefaultAssignerURL);
96 } 58 }
97 59
98 class SimpleURLRequestContextGetter : public net::URLRequestContextGetter { 60 class SimpleURLRequestContextGetter : public net::URLRequestContextGetter {
99 public: 61 public:
100 SimpleURLRequestContextGetter( 62 SimpleURLRequestContextGetter(
101 const scoped_refptr<base::SingleThreadTaskRunner>& io_loop_task_runner) 63 scoped_refptr<base::SingleThreadTaskRunner> io_loop_task_runner)
102 : io_loop_task_runner_(io_loop_task_runner), 64 : io_loop_task_runner_(std::move(io_loop_task_runner)),
103 proxy_config_service_(net::ProxyService::CreateSystemProxyConfigService( 65 proxy_config_service_(net::ProxyService::CreateSystemProxyConfigService(
104 io_loop_task_runner_, 66 io_loop_task_runner_,
105 io_loop_task_runner_)) {} 67 io_loop_task_runner_)) {}
106 68
107 // net::URLRequestContextGetter implementation. 69 // net::URLRequestContextGetter implementation.
108 net::URLRequestContext* GetURLRequestContext() override { 70 net::URLRequestContext* GetURLRequestContext() override {
109 if (!url_request_context_) { 71 if (!url_request_context_) {
110 net::URLRequestContextBuilder builder; 72 net::URLRequestContextBuilder builder;
111 builder.set_proxy_config_service(std::move(proxy_config_service_)); 73 builder.set_proxy_config_service(std::move(proxy_config_service_));
112 builder.DisableHttpCache(); 74 builder.DisableHttpCache();
(...skipping 16 matching lines...) Expand all
129 91
130 // Temporary storage for the ProxyConfigService, which needs to be created on 92 // Temporary storage for the ProxyConfigService, which needs to be created on
131 // the main thread but cleared on the IO thread. This will be built in the 93 // the main thread but cleared on the IO thread. This will be built in the
132 // constructor and cleared on the IO thread. Due to the usage of this class 94 // constructor and cleared on the IO thread. Due to the usage of this class
133 // this is safe. 95 // this is safe.
134 scoped_ptr<net::ProxyConfigService> proxy_config_service_; 96 scoped_ptr<net::ProxyConfigService> proxy_config_service_;
135 97
136 DISALLOW_COPY_AND_ASSIGN(SimpleURLRequestContextGetter); 98 DISALLOW_COPY_AND_ASSIGN(SimpleURLRequestContextGetter);
137 }; 99 };
138 100
101 // Populates an Assignment using command-line parameters, if provided.
102 // Returns a null Assignment if no parameters were set.
103 // Must be called on the IO thread.
Wez 2016/02/26 18:32:09 nit: s/the/an
Kevin M 2016/02/26 19:57:22 Done.
104
Wez 2016/02/26 18:32:09 nit: Remove this blank line
Kevin M 2016/02/26 19:57:23 Done.
105 Assignment GetCustomAssignment() {
Wez 2016/02/26 18:32:09 So should this be called GetAssignmentFromCommandL
Kevin M 2016/02/26 19:57:23 Done.
106 GURL url(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
107 switches::kEngineEndpoint));
108
109 // Our use of nonstandard URL schemes means the URL parser will fall back to
110 // very conservative parsing logic. It lumps everything after the scheme into
111 // the GURL "path" fragment. We need to trim leading slashes (if present) and
112 // parse the host/port pair from the path ourselves.
113 std::string path = url.path();
Ryan Sleevi 2016/02/25 22:16:25 Ideally you would check .is_empty() / is_valid() /
Kevin M 2016/02/26 00:30:04 Done.
114 if (path.substr(0, 2) == "//") {
115 path = path.erase(0, 2);
116 }
117 std::string host;
118 int port;
119 if (url.is_empty() || !url.is_valid() || !url.has_scheme() ||
120 !net::ParseHostAndPort(path, &host, &port)) {
121 return Assignment();
122 }
123
124 net::IPAddress ip_address;
125 CHECK(ip_address.AssignFromIPLiteral(host)) << "Invalid Assignment host "
126 << host;
127
128 Assignment::TransportProtocol protocol =
129 Assignment::TransportProtocol::UNKNOWN;
130 if (url.SchemeIs(kCustomSSLScheme)) {
131 protocol = Assignment::TransportProtocol::SSL;
132 } else if (url.SchemeIs(kCustomTCPScheme)) {
133 protocol = Assignment::TransportProtocol::TCP;
134 } else if (url.SchemeIs(kCustomQUICScheme)) {
135 protocol = Assignment::TransportProtocol::QUIC;
136 } else {
137 CHECK(false) << "Invalid engine protocol scheme " << url.scheme();
138 }
139
140 scoped_refptr<net::X509Certificate> cert;
141 if (protocol == Assignment::TransportProtocol::SSL ||
142 protocol == Assignment::TransportProtocol::QUIC) {
143 base::FilePath cert_path =
144 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
145 switches::kEngineCertPath);
146 CHECK(!cert_path.empty()) << "Missing required parameter --"
147 << switches::kEngineCertPath << ".";
148 std::string cert_str;
149 CHECK(base::ReadFileToString(cert_path, &cert_str))
150 << "Couldn't read from file: " << cert_path.LossyDisplayName();
151 net::CertificateList cert_list =
152 net::X509Certificate::CreateCertificateListFromBytes(
153 cert_str.data(), cert_str.size(),
154 net::X509Certificate::FORMAT_PEM_CERT_SEQUENCE);
155 CHECK_EQ(1u, cert_list.size())
156 << "Only one cert is allowed in PEM cert list.";
157 cert = std::move(cert_list[0]);
158 }
159
160 Assignment assignment;
161 assignment.transport_protocol = protocol;
162 assignment.ip_endpoint =
163 net::IPEndPoint(ip_address, base::checked_cast<uint16_t>(port));
164 assignment.client_token = kDummyClientToken;
165 assignment.cert = std::move(cert);
166 return assignment;
167 }
168
139 } // namespace 169 } // namespace
140 170
141 Assignment::Assignment() : transport_protocol(TransportProtocol::UNKNOWN) {} 171 Assignment::Assignment() : transport_protocol(TransportProtocol::UNKNOWN) {}
142 172
143 Assignment::~Assignment() {} 173 Assignment::~Assignment() {}
144 174
145 bool Assignment::is_null() const { 175 bool Assignment::is_null() const {
146 return ip_endpoint.address().empty() || ip_endpoint.port() == 0 || 176 return ip_endpoint.address().empty() || ip_endpoint.port() == 0 ||
147 transport_protocol == TransportProtocol::UNKNOWN; 177 transport_protocol == TransportProtocol::UNKNOWN;
148 } 178 }
149 179
150 AssignmentSource::AssignmentSource( 180 AssignmentSource::AssignmentSource(
151 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, 181 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
152 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) 182 : io_task_runner_(std::move(io_task_runner)),
153 : main_task_runner_(main_task_runner), 183 url_request_context_(new SimpleURLRequestContextGetter(io_task_runner_)),
154 url_request_context_(new SimpleURLRequestContextGetter(io_task_runner)) {} 184 weak_factory_(this) {}
155 185
156 AssignmentSource::~AssignmentSource() {} 186 AssignmentSource::~AssignmentSource() {}
157 187
158 void AssignmentSource::GetAssignment(const std::string& client_auth_token, 188 void AssignmentSource::GetAssignment(const std::string& client_auth_token,
159 const AssignmentCallback& callback) { 189 const AssignmentCallback& callback) {
160 DCHECK(main_task_runner_->BelongsToCurrentThread());
161
162 // Cancel any outstanding callback. 190 // Cancel any outstanding callback.
163 if (!callback_.is_null()) { 191 if (!callback_.is_null()) {
164 base::ResetAndReturn(&callback_) 192 base::ResetAndReturn(&callback_)
165 .Run(AssignmentSource::Result::RESULT_SERVER_INTERRUPTED, Assignment()); 193 .Run(AssignmentSource::Result::RESULT_SERVER_INTERRUPTED, Assignment());
166 } 194 }
167 callback_ = AssignmentCallback(callback); 195 callback_ = AssignmentCallback(callback);
168 196
169 Assignment assignment = GetCustomBlimpletAssignment(); 197 // Try to get a custom assignment on the IO thread first.
170 if (!assignment.is_null()) { 198 PostTaskAndReplyWithResult(
Wez 2016/02/26 18:32:09 OT: I <3 PostTaskAndReplyWithResult - so handy!
171 // Post the result so that the behavior of this function is consistent. 199 io_task_runner_.get(), FROM_HERE, base::Bind(&GetCustomAssignment),
172 main_task_runner_->PostTask( 200 base::Bind(&AssignmentSource::OnGetCustomAssignmentDone,
173 FROM_HERE, base::Bind(base::ResetAndReturn(&callback_), 201 weak_factory_.GetWeakPtr(), client_auth_token));
174 AssignmentSource::Result::RESULT_OK, assignment)); 202 }
203
204 void AssignmentSource::OnGetCustomAssignmentDone(
205 const std::string& client_auth_token,
206 Assignment custom_assignment) {
207 // If GetCustomAssignment succeeded, then return the custom assignment
208 // directly.
209 if (!custom_assignment.is_null()) {
210 base::ResetAndReturn(&callback_)
211 .Run(AssignmentSource::RESULT_OK, custom_assignment);
175 return; 212 return;
176 } 213 }
177 214
178 // Call out to the network for a real assignment. Build the network request 215 // Call out to the network for a real assignment. Build the network request
179 // to hit the assigner. 216 // to hit the assigner.
180 url_fetcher_ = net::URLFetcher::Create(GetBlimpAssignerURL(), 217 url_fetcher_ = net::URLFetcher::Create(GetBlimpAssignerURL(),
181 net::URLFetcher::POST, this); 218 net::URLFetcher::POST, this);
182 url_fetcher_->SetRequestContext(url_request_context_.get()); 219 url_fetcher_->SetRequestContext(url_request_context_.get());
183 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | 220 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES |
184 net::LOAD_DO_NOT_SEND_COOKIES); 221 net::LOAD_DO_NOT_SEND_COOKIES);
185 url_fetcher_->AddExtraRequestHeader("Authorization: Bearer " + 222 url_fetcher_->AddExtraRequestHeader("Authorization: Bearer " +
186 client_auth_token); 223 client_auth_token);
187 224
188 // Write the JSON for the request data. 225 // Write the JSON for the request data.
189 base::DictionaryValue dictionary; 226 base::DictionaryValue dictionary;
190 dictionary.SetString(kProtocolVersionKey, blimp::kEngineVersion); 227 dictionary.SetString(kProtocolVersionKey, blimp::kEngineVersion);
191 std::string json; 228 std::string json;
192 base::JSONWriter::Write(dictionary, &json); 229 base::JSONWriter::Write(dictionary, &json);
193 url_fetcher_->SetUploadData("application/json", json); 230 url_fetcher_->SetUploadData("application/json", json);
194
195 url_fetcher_->Start(); 231 url_fetcher_->Start();
196 } 232 }
197 233
198 void AssignmentSource::OnURLFetchComplete(const net::URLFetcher* source) { 234 void AssignmentSource::OnURLFetchComplete(const net::URLFetcher* source) {
199 DCHECK(main_task_runner_->BelongsToCurrentThread());
200 DCHECK(!callback_.is_null()); 235 DCHECK(!callback_.is_null());
201 DCHECK_EQ(url_fetcher_.get(), source); 236 DCHECK_EQ(url_fetcher_.get(), source);
202 237
203 if (!source->GetStatus().is_success()) { 238 if (!source->GetStatus().is_success()) {
204 DVLOG(1) << "Assignment request failed due to network error: " 239 DVLOG(1) << "Assignment request failed due to network error: "
205 << net::ErrorToString(source->GetStatus().error()); 240 << net::ErrorToString(source->GetStatus().error());
206 base::ResetAndReturn(&callback_) 241 base::ResetAndReturn(&callback_)
207 .Run(AssignmentSource::Result::RESULT_NETWORK_FAILURE, Assignment()); 242 .Run(AssignmentSource::Result::RESULT_NETWORK_FAILURE, Assignment());
208 return; 243 return;
209 } 244 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 DCHECK_EQ(net::HTTP_OK, url_fetcher_->GetResponseCode()); 281 DCHECK_EQ(net::HTTP_OK, url_fetcher_->GetResponseCode());
247 282
248 // Grab the response from the assigner request. 283 // Grab the response from the assigner request.
249 std::string response; 284 std::string response;
250 if (!url_fetcher_->GetResponseAsString(&response)) { 285 if (!url_fetcher_->GetResponseAsString(&response)) {
251 base::ResetAndReturn(&callback_) 286 base::ResetAndReturn(&callback_)
252 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment()); 287 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
253 return; 288 return;
254 } 289 }
255 290
256 // Attempt to interpret the response as JSON and treat it as a dictionary. 291 safe_json::SafeJsonParser::Parse(
257 scoped_ptr<base::Value> json = base::JSONReader::Read(response); 292 response, base::Bind(&AssignmentSource::AssignerJSONParseOK,
258 if (!json) { 293 weak_factory_.GetWeakPtr()),
Wez 2016/02/26 18:32:09 nit: This line-wrap looks weird - I'd expect the b
Kevin M 2016/02/26 19:57:23 Yes, this is formatted.
259 base::ResetAndReturn(&callback_) 294 base::Bind(&AssignmentSource::AssignerJSONParseError,
260 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment()); 295 weak_factory_.GetWeakPtr()));
261 return; 296 }
262 }
263 297
298 void AssignmentSource::AssignerJSONParseOK(scoped_ptr<base::Value> json) {
264 const base::DictionaryValue* dict; 299 const base::DictionaryValue* dict;
265 if (!json->GetAsDictionary(&dict)) { 300 if (!json->GetAsDictionary(&dict)) {
266 base::ResetAndReturn(&callback_) 301 base::ResetAndReturn(&callback_)
267 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment()); 302 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
268 return; 303 return;
269 } 304 }
270 305
271 // Validate that all the expected fields are present. 306 // Validate that all the expected fields are present.
272 std::string client_token; 307 std::string client_token;
273 std::string host; 308 std::string host;
274 int port; 309 int port;
275 std::string cert_fingerprint; 310 std::string cert_str;
276 std::string cert;
277 if (!(dict->GetString(kClientTokenKey, &client_token) && 311 if (!(dict->GetString(kClientTokenKey, &client_token) &&
278 dict->GetString(kHostKey, &host) && dict->GetInteger(kPortKey, &port) && 312 dict->GetString(kHostKey, &host) && dict->GetInteger(kPortKey, &port) &&
279 dict->GetString(kCertificateFingerprintKey, &cert_fingerprint) && 313 dict->GetString(kCertificateKey, &cert_str))) {
280 dict->GetString(kCertificateKey, &cert))) {
281 base::ResetAndReturn(&callback_) 314 base::ResetAndReturn(&callback_)
282 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment()); 315 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
283 return; 316 return;
284 } 317 }
285 318
286 net::IPAddress ip_address; 319 net::IPAddress ip_address;
287 if (!ip_address.AssignFromIPLiteral(host)) { 320 if (!ip_address.AssignFromIPLiteral(host)) {
288 base::ResetAndReturn(&callback_) 321 base::ResetAndReturn(&callback_)
289 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment()); 322 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
290 return; 323 return;
291 } 324 }
292 325
293 if (!base::IsValueInRangeForNumericType<uint16_t>(port)) { 326 if (!base::IsValueInRangeForNumericType<uint16_t>(port)) {
294 base::ResetAndReturn(&callback_) 327 base::ResetAndReturn(&callback_)
295 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment()); 328 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
296 return; 329 return;
297 } 330 }
298 331
299 Assignment assignment; 332 net::CertificateList cert_list =
333 net::X509Certificate::CreateCertificateListFromBytes(
334 cert_str.data(), cert_str.size(),
335 net::X509Certificate::FORMAT_PEM_CERT_SEQUENCE);
336 if (cert_list.size() != 1) {
337 base::ResetAndReturn(&callback_)
338 .Run(AssignmentSource::Result::RESULT_INVALID_CERT, Assignment());
339 return;
340 }
341
300 // The assigner assumes SSL-only and all engines it assigns only communicate 342 // The assigner assumes SSL-only and all engines it assigns only communicate
301 // over SSL. 343 // over SSL.
344 Assignment assignment;
302 assignment.transport_protocol = Assignment::TransportProtocol::SSL; 345 assignment.transport_protocol = Assignment::TransportProtocol::SSL;
303 assignment.ip_endpoint = net::IPEndPoint(ip_address, port); 346 assignment.ip_endpoint = net::IPEndPoint(ip_address, port);
304 assignment.client_token = client_token; 347 assignment.client_token = client_token;
305 assignment.certificate = cert; 348 assignment.cert = std::move(cert_list[0]);
306 assignment.certificate_fingerprint = cert_fingerprint;
307 349
308 base::ResetAndReturn(&callback_) 350 base::ResetAndReturn(&callback_)
309 .Run(AssignmentSource::Result::RESULT_OK, assignment); 351 .Run(AssignmentSource::Result::RESULT_OK, assignment);
310 } 352 }
311 353
354 void AssignmentSource::AssignerJSONParseError(const std::string& error) {
355 DLOG(ERROR) << "Error while parsing assigner JSON: " << error;
356 base::ResetAndReturn(&callback_)
357 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
358 }
359
312 } // namespace client 360 } // namespace client
313 } // namespace blimp 361 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698