| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 18 #include "google_apis/gcm/base/gcm_util.h" | 19 #include "google_apis/gcm/base/gcm_util.h" |
| 19 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 20 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
| 20 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
| 21 #include "net/http/http_request_headers.h" | 22 #include "net/http/http_request_headers.h" |
| 22 #include "net/http/http_status_code.h" | 23 #include "net/http/http_status_code.h" |
| 23 #include "net/url_request/url_fetcher.h" | 24 #include "net/url_request/url_fetcher.h" |
| 24 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
| 25 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
| 26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 27 | 28 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 144 |
| 144 void RegistrationRequest::Start() { | 145 void RegistrationRequest::Start() { |
| 145 DCHECK(!callback_.is_null()); | 146 DCHECK(!callback_.is_null()); |
| 146 DCHECK(!url_fetcher_.get()); | 147 DCHECK(!url_fetcher_.get()); |
| 147 | 148 |
| 148 url_fetcher_ = | 149 url_fetcher_ = |
| 149 net::URLFetcher::Create(registration_url_, net::URLFetcher::POST, this); | 150 net::URLFetcher::Create(registration_url_, net::URLFetcher::POST, this); |
| 150 url_fetcher_->SetRequestContext(request_context_getter_.get()); | 151 url_fetcher_->SetRequestContext(request_context_getter_.get()); |
| 151 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 152 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 152 net::LOAD_DO_NOT_SAVE_COOKIES); | 153 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 154 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 155 url_fetcher_.get(), data_use_measurement::DataUseUserData::GCM_ENGINE); |
| 153 | 156 |
| 154 std::string extra_headers; | 157 std::string extra_headers; |
| 155 BuildRequestHeaders(&extra_headers); | 158 BuildRequestHeaders(&extra_headers); |
| 156 url_fetcher_->SetExtraRequestHeaders(extra_headers); | 159 url_fetcher_->SetExtraRequestHeaders(extra_headers); |
| 157 | 160 |
| 158 std::string body; | 161 std::string body; |
| 159 BuildRequestBody(&body); | 162 BuildRequestBody(&body); |
| 160 | 163 |
| 161 DVLOG(1) << "Performing registration for: " << request_info_.app_id(); | 164 DVLOG(1) << "Performing registration for: " << request_info_.app_id(); |
| 162 DVLOG(1) << "Registration request: " << body; | 165 DVLOG(1) << "Registration request: " << body; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 // Only REACHED_MAX_RETRIES is reported because the function will skip | 276 // Only REACHED_MAX_RETRIES is reported because the function will skip |
| 274 // reporting count and time when status is not SUCCESS. | 277 // reporting count and time when status is not SUCCESS. |
| 275 DCHECK(custom_request_handler_.get()); | 278 DCHECK(custom_request_handler_.get()); |
| 276 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); | 279 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); |
| 277 } | 280 } |
| 278 | 281 |
| 279 callback_.Run(status, token); | 282 callback_.Run(status, token); |
| 280 } | 283 } |
| 281 | 284 |
| 282 } // namespace gcm | 285 } // namespace gcm |
| OLD | NEW |