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

Side by Side Diff: chrome/browser/profiles/profile_downloader.cc

Issue 10695058: Ignore partial profile image downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/profiles/profile_downloader.h" 5 #include "chrome/browser/profiles/profile_downloader.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/common/net/gaia/oauth2_access_token_fetcher.h" 24 #include "chrome/common/net/gaia/oauth2_access_token_fetcher.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/notification_details.h" 26 #include "content/public/browser/notification_details.h"
27 #include "content/public/browser/notification_observer.h" 27 #include "content/public/browser/notification_observer.h"
28 #include "content/public/browser/notification_registrar.h" 28 #include "content/public/browser/notification_registrar.h"
29 #include "content/public/browser/notification_source.h" 29 #include "content/public/browser/notification_source.h"
30 #include "content/public/browser/notification_types.h" 30 #include "content/public/browser/notification_types.h"
31 #include "googleurl/src/gurl.h" 31 #include "googleurl/src/gurl.h"
32 #include "net/base/load_flags.h" 32 #include "net/base/load_flags.h"
33 #include "net/url_request/url_fetcher.h" 33 #include "net/url_request/url_fetcher.h"
34 #include "net/url_request/url_request_status.h"
34 #include "skia/ext/image_operations.h" 35 #include "skia/ext/image_operations.h"
35 36
36 using content::BrowserThread; 37 using content::BrowserThread;
37 38
38 namespace { 39 namespace {
39 40
40 // Template for optional authorization header when using an OAuth access token. 41 // Template for optional authorization header when using an OAuth access token.
41 const char kAuthorizationHeader[] = 42 const char kAuthorizationHeader[] =
42 "Authorization: Bearer %s"; 43 "Authorization: Bearer %s";
43 44
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 service->GetOAuth2LoginRefreshToken(), 273 service->GetOAuth2LoginRefreshToken(),
273 scopes); 274 scopes);
274 } 275 }
275 276
276 ProfileDownloader::~ProfileDownloader() {} 277 ProfileDownloader::~ProfileDownloader() {}
277 278
278 void ProfileDownloader::OnURLFetchComplete(const net::URLFetcher* source) { 279 void ProfileDownloader::OnURLFetchComplete(const net::URLFetcher* source) {
279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
280 std::string data; 281 std::string data;
281 source->GetResponseAsString(&data); 282 source->GetResponseAsString(&data);
282 if (source->GetResponseCode() != 200) { 283 if (source->GetStatus().status() != net::URLRequestStatus::SUCCESS ||
283 DVLOG(1) << "Response code is " << source->GetResponseCode(); 284 source->GetResponseCode() != 200) {
284 DVLOG(1) << "Url is " << source->GetURL().spec(); 285 LOG(WARNING) << "Fetching profile data failed";
285 DVLOG(1) << "Data is " << data; 286 DVLOG(1) << " Status: " << source->GetStatus().status();
287 DVLOG(1) << " Error: " << source->GetStatus().error();
288 DVLOG(1) << " Response code: " << source->GetResponseCode();
289 DVLOG(1) << " Url: " << source->GetURL().spec();
286 delegate_->OnProfileDownloadFailure(this); 290 delegate_->OnProfileDownloadFailure(this);
287 return; 291 return;
288 } 292 }
289 293
290 if (source == user_entry_fetcher_.get()) { 294 if (source == user_entry_fetcher_.get()) {
291 std::string image_url; 295 std::string image_url;
292 if (!GetProfileNameAndImageURL(data, &profile_full_name_, &image_url, 296 if (!GetProfileNameAndImageURL(data, &profile_full_name_, &image_url,
293 delegate_->GetDesiredImageSideLength())) { 297 delegate_->GetDesiredImageSideLength())) {
294 delegate_->OnProfileDownloadFailure(this); 298 delegate_->OnProfileDownloadFailure(this);
295 return; 299 return;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 void ProfileDownloader::OnGetTokenSuccess(const std::string& access_token) { 384 void ProfileDownloader::OnGetTokenSuccess(const std::string& access_token) {
381 auth_token_ = access_token; 385 auth_token_ = access_token;
382 StartFetchingImage(); 386 StartFetchingImage();
383 } 387 }
384 388
385 // Callback for OAuth2AccessTokenFetcher on failure. 389 // Callback for OAuth2AccessTokenFetcher on failure.
386 void ProfileDownloader::OnGetTokenFailure(const GoogleServiceAuthError& error) { 390 void ProfileDownloader::OnGetTokenFailure(const GoogleServiceAuthError& error) {
387 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed"; 391 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed";
388 delegate_->OnProfileDownloadFailure(this); 392 delegate_->OnProfileDownloadFailure(this);
389 } 393 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698