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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 RegistrationRequest::~RegistrationRequest() {} | 119 RegistrationRequest::~RegistrationRequest() {} |
120 | 120 |
121 void RegistrationRequest::Start() { | 121 void RegistrationRequest::Start() { |
122 DCHECK(!callback_.is_null()); | 122 DCHECK(!callback_.is_null()); |
123 DCHECK(request_info_.android_id != 0UL); | 123 DCHECK(request_info_.android_id != 0UL); |
124 DCHECK(request_info_.security_token != 0UL); | 124 DCHECK(request_info_.security_token != 0UL); |
125 DCHECK(0 < request_info_.sender_ids.size() && | 125 DCHECK(0 < request_info_.sender_ids.size() && |
126 request_info_.sender_ids.size() <= kMaxSenders); | 126 request_info_.sender_ids.size() <= kMaxSenders); |
127 | 127 |
128 DCHECK(!url_fetcher_.get()); | 128 DCHECK(!url_fetcher_.get()); |
129 url_fetcher_.reset(net::URLFetcher::Create( | 129 url_fetcher_ = |
130 registration_url_, net::URLFetcher::POST, this)); | 130 net::URLFetcher::Create(registration_url_, net::URLFetcher::POST, this); |
131 url_fetcher_->SetRequestContext(request_context_getter_.get()); | 131 url_fetcher_->SetRequestContext(request_context_getter_.get()); |
132 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 132 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
133 net::LOAD_DO_NOT_SAVE_COOKIES); | 133 net::LOAD_DO_NOT_SAVE_COOKIES); |
134 | 134 |
135 std::string android_id = base::Uint64ToString(request_info_.android_id); | 135 std::string android_id = base::Uint64ToString(request_info_.android_id); |
136 std::string auth_header = | 136 std::string auth_header = |
137 std::string(net::HttpRequestHeaders::kAuthorization) + ": " + | 137 std::string(net::HttpRequestHeaders::kAuthorization) + ": " + |
138 kLoginHeader + " " + android_id + ":" + | 138 kLoginHeader + " " + android_id + ":" + |
139 base::Uint64ToString(request_info_.security_token); | 139 base::Uint64ToString(request_info_.security_token); |
140 url_fetcher_->SetExtraRequestHeaders(auth_header); | 140 url_fetcher_->SetExtraRequestHeaders(auth_header); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 if (status == SUCCESS) { | 261 if (status == SUCCESS) { |
262 UMA_HISTOGRAM_COUNTS("GCM.RegistrationRetryCount", | 262 UMA_HISTOGRAM_COUNTS("GCM.RegistrationRetryCount", |
263 backoff_entry_.failure_count()); | 263 backoff_entry_.failure_count()); |
264 UMA_HISTOGRAM_TIMES("GCM.RegistrationCompleteTime", | 264 UMA_HISTOGRAM_TIMES("GCM.RegistrationCompleteTime", |
265 base::TimeTicks::Now() - request_start_time_); | 265 base::TimeTicks::Now() - request_start_time_); |
266 } | 266 } |
267 callback_.Run(status, token); | 267 callback_.Run(status, token); |
268 } | 268 } |
269 | 269 |
270 } // namespace gcm | 270 } // namespace gcm |
OLD | NEW |