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

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

Issue 1876983002: Use Chromium BUILD to approximate Blimp protocol version, and check it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Route EndConnection to OnConnectionError notifications 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 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/files/file_util.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/numerics/safe_conversions.h" 15 #include "base/numerics/safe_conversions.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/task_runner_util.h" 17 #include "base/task_runner_util.h"
18 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "blimp/client/app/blimp_client_switches.h" 20 #include "blimp/client/app/blimp_client_switches.h"
21 #include "blimp/common/get_client_token.h" 21 #include "blimp/common/get_client_token.h"
22 #include "blimp/common/protocol_version.h" 22 #include "blimp/common/version_info.h"
23 #include "components/safe_json/safe_json_parser.h" 23 #include "components/safe_json/safe_json_parser.h"
24 #include "net/base/ip_address.h" 24 #include "net/base/ip_address.h"
25 #include "net/base/ip_endpoint.h" 25 #include "net/base/ip_endpoint.h"
26 #include "net/base/load_flags.h" 26 #include "net/base/load_flags.h"
27 #include "net/base/net_errors.h" 27 #include "net/base/net_errors.h"
28 #include "net/http/http_status_code.h" 28 #include "net/http/http_status_code.h"
29 #include "net/proxy/proxy_config_service.h" 29 #include "net/proxy/proxy_config_service.h"
30 #include "net/proxy/proxy_service.h" 30 #include "net/proxy/proxy_service.h"
31 #include "net/url_request/url_fetcher.h" 31 #include "net/url_request/url_fetcher.h"
32 #include "net/url_request/url_request_context.h" 32 #include "net/url_request/url_request_context.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 url_fetcher_ = 236 url_fetcher_ =
237 net::URLFetcher::Create(assigner_endpoint_, net::URLFetcher::POST, this); 237 net::URLFetcher::Create(assigner_endpoint_, net::URLFetcher::POST, this);
238 url_fetcher_->SetRequestContext(url_request_context_.get()); 238 url_fetcher_->SetRequestContext(url_request_context_.get());
239 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | 239 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES |
240 net::LOAD_DO_NOT_SEND_COOKIES); 240 net::LOAD_DO_NOT_SEND_COOKIES);
241 url_fetcher_->AddExtraRequestHeader("Authorization: Bearer " + 241 url_fetcher_->AddExtraRequestHeader("Authorization: Bearer " +
242 client_auth_token); 242 client_auth_token);
243 243
244 // Write the JSON for the request data. 244 // Write the JSON for the request data.
245 base::DictionaryValue dictionary; 245 base::DictionaryValue dictionary;
246 dictionary.SetString(kProtocolVersionKey, blimp::kEngineVersion); 246 dictionary.SetString(kProtocolVersionKey,
247 base::IntToString(GetProtocolVersion()));
247 std::string json; 248 std::string json;
248 base::JSONWriter::Write(dictionary, &json); 249 base::JSONWriter::Write(dictionary, &json);
249 url_fetcher_->SetUploadData("application/json", json); 250 url_fetcher_->SetUploadData("application/json", json);
250 url_fetcher_->Start(); 251 url_fetcher_->Start();
251 } 252 }
252 253
253 void AssignmentSource::OnURLFetchComplete(const net::URLFetcher* source) { 254 void AssignmentSource::OnURLFetchComplete(const net::URLFetcher* source) {
254 DCHECK(!callback_.is_null()); 255 DCHECK(!callback_.is_null());
255 DCHECK_EQ(url_fetcher_.get(), source); 256 DCHECK_EQ(url_fetcher_.get(), source);
256 257
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 372 }
372 373
373 void AssignmentSource::OnJsonParseError(const std::string& error) { 374 void AssignmentSource::OnJsonParseError(const std::string& error) {
374 DLOG(ERROR) << "Error while parsing assigner JSON: " << error; 375 DLOG(ERROR) << "Error while parsing assigner JSON: " << error;
375 base::ResetAndReturn(&callback_) 376 base::ResetAndReturn(&callback_)
376 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment()); 377 .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
377 } 378 }
378 379
379 } // namespace client 380 } // namespace client
380 } // namespace blimp 381 } // namespace blimp
OLDNEW
« no previous file with comments | « no previous file | blimp/client/session/assignment_source_unittest.cc » ('j') | blimp/common/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698