| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "google_apis/gcm/engine/registration_request.h" | 5 #include "google_apis/gcm/engine/registration_request.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 14 #include "google_apis/gcm/base/gcm_util.h" | 15 #include "google_apis/gcm/base/gcm_util.h" |
| 15 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 16 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
| 16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 17 #include "net/http/http_request_headers.h" | 18 #include "net/http/http_request_headers.h" |
| 18 #include "net/http/http_status_code.h" | 19 #include "net/http/http_status_code.h" |
| 19 #include "net/url_request/url_fetcher.h" | 20 #include "net/url_request/url_fetcher.h" |
| 20 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
| 21 #include "net/url_request/url_request_status.h" | 22 #include "net/url_request/url_request_status.h" |
| 22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 23 | 24 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 111 } |
| 111 | 112 |
| 112 RegistrationRequest::~RegistrationRequest() {} | 113 RegistrationRequest::~RegistrationRequest() {} |
| 113 | 114 |
| 114 void RegistrationRequest::Start() { | 115 void RegistrationRequest::Start() { |
| 115 DCHECK(!callback_.is_null()); | 116 DCHECK(!callback_.is_null()); |
| 116 DCHECK(!url_fetcher_.get()); | 117 DCHECK(!url_fetcher_.get()); |
| 117 | 118 |
| 118 url_fetcher_ = | 119 url_fetcher_ = |
| 119 net::URLFetcher::Create(registration_url_, net::URLFetcher::POST, this); | 120 net::URLFetcher::Create(registration_url_, net::URLFetcher::POST, this); |
| 121 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 122 url_fetcher_.get(), data_use_measurement::DataUseUserData::GOOGLE_APIS); |
| 120 url_fetcher_->SetRequestContext(request_context_getter_.get()); | 123 url_fetcher_->SetRequestContext(request_context_getter_.get()); |
| 121 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 124 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 122 net::LOAD_DO_NOT_SAVE_COOKIES); | 125 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 123 | 126 |
| 124 std::string extra_headers; | 127 std::string extra_headers; |
| 125 BuildRequestHeaders(&extra_headers); | 128 BuildRequestHeaders(&extra_headers); |
| 126 url_fetcher_->SetExtraRequestHeaders(extra_headers); | 129 url_fetcher_->SetExtraRequestHeaders(extra_headers); |
| 127 | 130 |
| 128 std::string body; | 131 std::string body; |
| 129 BuildRequestBody(&body); | 132 BuildRequestBody(&body); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 // Only REACHED_MAX_RETRIES is reported because the function will skip | 251 // Only REACHED_MAX_RETRIES is reported because the function will skip |
| 249 // reporting count and time when status is not SUCCESS. | 252 // reporting count and time when status is not SUCCESS. |
| 250 DCHECK(custom_request_handler_.get()); | 253 DCHECK(custom_request_handler_.get()); |
| 251 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); | 254 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); |
| 252 } | 255 } |
| 253 | 256 |
| 254 callback_.Run(status, token); | 257 callback_.Run(status, token); |
| 255 } | 258 } |
| 256 | 259 |
| 257 } // namespace gcm | 260 } // namespace gcm |
| OLD | NEW |