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

Side by Side Diff: chrome/browser/chromeos/login/profile_image_downloader.cc

Issue 8360003: [cros] OOBE: add histograms for Profile image fetching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/login/profile_image_downloader.h" 5 #include "chrome/browser/chromeos/login/profile_image_downloader.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 ProfileManager::GetDefaultProfile()->GetRequestContext()); 146 ProfileManager::GetDefaultProfile()->GetRequestContext());
147 if (!auth_token_.empty()) { 147 if (!auth_token_.empty()) {
148 user_entry_fetcher_->set_extra_request_headers( 148 user_entry_fetcher_->set_extra_request_headers(
149 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str())); 149 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str()));
150 } 150 }
151 user_entry_fetcher_->Start(); 151 user_entry_fetcher_->Start();
152 } 152 }
153 153
154 ProfileImageDownloader::~ProfileImageDownloader() {} 154 ProfileImageDownloader::~ProfileImageDownloader() {}
155 155
156 void ProfileImageDownloader::OnURLFetchComplete( 156 void ProfileImageDownloader::OnURLFetchComplete(const URLFetcher* source) {
157 const URLFetcher* source,
158 const GURL& url,
159 const net::URLRequestStatus& status,
160 int response_code,
161 const net::ResponseCookies& cookies,
162 const std::string& data) {
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
164 if (response_code != 200) { 158
165 LOG(ERROR) << "Response code is " << response_code; 159 const std::string& data = source->GetResponseStringRef();
166 LOG(ERROR) << "Url is " << url.spec(); 160
161 if (source->response_code() != 200) {
162 LOG(ERROR) << "Response code is " << source->response_code();
163 LOG(ERROR) << "Url is " << source->url().spec();
167 LOG(ERROR) << "Data is " << data; 164 LOG(ERROR) << "Data is " << data;
168 if (delegate_) 165 if (delegate_)
169 delegate_->OnDownloadFailure(); 166 delegate_->OnDownloadFailure();
170 return; 167 return;
171 } 168 }
172 169
173 if (source == user_entry_fetcher_.get()) { 170 if (source == user_entry_fetcher_.get()) {
174 std::string image_url = GetProfileImageURL(data); 171 std::string image_url = GetProfileImageURL(data);
175 if (image_url.empty()) { 172 if (image_url.empty()) {
176 if (delegate_) 173 if (delegate_)
177 delegate_->OnDownloadFailure(); 174 delegate_->OnDownloadFailure();
178 return; 175 return;
179 } 176 }
180 VLOG(1) << "Fetching profile image..."; 177 VLOG(1) << "Fetching profile image from " << image_url;
181 profile_image_fetcher_.reset( 178 profile_image_fetcher_.reset(
182 new URLFetcher(GURL(image_url), URLFetcher::GET, this)); 179 new URLFetcher(GURL(image_url), URLFetcher::GET, this));
183 profile_image_fetcher_->set_request_context( 180 profile_image_fetcher_->set_request_context(
184 ProfileManager::GetDefaultProfile()->GetRequestContext()); 181 ProfileManager::GetDefaultProfile()->GetRequestContext());
185 if (!auth_token_.empty()) { 182 if (!auth_token_.empty()) {
186 profile_image_fetcher_->set_extra_request_headers( 183 profile_image_fetcher_->set_extra_request_headers(
187 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str())); 184 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str()));
188 } 185 }
189 profile_image_fetcher_->Start(); 186 profile_image_fetcher_->Start();
190 } else if (source == profile_image_fetcher_.get()) { 187 } else if (source == profile_image_fetcher_.get()) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } else { 227 } else {
231 if (token_details->service() == GaiaConstants::kPicasaService) { 228 if (token_details->service() == GaiaConstants::kPicasaService) {
232 LOG(WARNING) << "ProfileImageDownloader: token request failed"; 229 LOG(WARNING) << "ProfileImageDownloader: token request failed";
233 if (delegate_) 230 if (delegate_)
234 delegate_->OnDownloadFailure(); 231 delegate_->OnDownloadFailure();
235 } 232 }
236 } 233 }
237 } 234 }
238 235
239 } // namespace chromeos 236 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/profile_image_downloader.h ('k') | chrome/browser/chromeos/login/user_image_screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698