| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 DVLOG(1) << " Error: " << source->GetStatus().error(); | 360 DVLOG(1) << " Error: " << source->GetStatus().error(); |
| 361 DVLOG(1) << " Response code: " << source->GetResponseCode(); | 361 DVLOG(1) << " Response code: " << source->GetResponseCode(); |
| 362 DVLOG(1) << " Url: " << source->GetURL().spec(); | 362 DVLOG(1) << " Url: " << source->GetURL().spec(); |
| 363 delegate_->OnProfileDownloadFailure(this, network_error ? | 363 delegate_->OnProfileDownloadFailure(this, network_error ? |
| 364 ProfileDownloaderDelegate::NETWORK_ERROR : | 364 ProfileDownloaderDelegate::NETWORK_ERROR : |
| 365 ProfileDownloaderDelegate::SERVICE_ERROR); | 365 ProfileDownloaderDelegate::SERVICE_ERROR); |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 | 368 |
| 369 VLOG(1) << "Decoding the image..."; | 369 VLOG(1) << "Decoding the image..."; |
| 370 scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder( | |
| 371 this, data, ImageDecoder::DEFAULT_CODEC); | |
| 372 scoped_refptr<base::MessageLoopProxy> task_runner = | 370 scoped_refptr<base::MessageLoopProxy> task_runner = |
| 373 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 371 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
| 374 image_decoder->Start(task_runner); | 372 ImageDecoder::GetInstance()->Start(this, data, ImageDecoder::DEFAULT_CODEC, |
| 373 task_runner, false); |
| 375 } | 374 } |
| 376 | 375 |
| 377 void ProfileDownloader::OnImageDecoded(const ImageDecoder* decoder, | 376 void ProfileDownloader::OnImageDecoded(const SkBitmap& decoded_image) { |
| 378 const SkBitmap& decoded_image) { | |
| 379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 377 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 380 int image_size = delegate_->GetDesiredImageSideLength(); | 378 int image_size = delegate_->GetDesiredImageSideLength(); |
| 381 profile_picture_ = skia::ImageOperations::Resize( | 379 profile_picture_ = skia::ImageOperations::Resize( |
| 382 decoded_image, | 380 decoded_image, |
| 383 skia::ImageOperations::RESIZE_BEST, | 381 skia::ImageOperations::RESIZE_BEST, |
| 384 image_size, | 382 image_size, |
| 385 image_size); | 383 image_size); |
| 386 picture_status_ = PICTURE_SUCCESS; | 384 picture_status_ = PICTURE_SUCCESS; |
| 387 delegate_->OnProfileDownloadSuccess(this); | 385 delegate_->OnProfileDownloadSuccess(this); |
| 388 } | 386 } |
| 389 | 387 |
| 390 void ProfileDownloader::OnDecodeImageFailed(const ImageDecoder* decoder) { | 388 void ProfileDownloader::OnDecodeImageFailed() { |
| 391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 389 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 392 delegate_->OnProfileDownloadFailure( | 390 delegate_->OnProfileDownloadFailure( |
| 393 this, ProfileDownloaderDelegate::IMAGE_DECODE_FAILED); | 391 this, ProfileDownloaderDelegate::IMAGE_DECODE_FAILED); |
| 394 } | 392 } |
| 395 | 393 |
| 396 void ProfileDownloader::OnRefreshTokenAvailable(const std::string& account_id) { | 394 void ProfileDownloader::OnRefreshTokenAvailable(const std::string& account_id) { |
| 397 ProfileOAuth2TokenService* service = | 395 ProfileOAuth2TokenService* service = |
| 398 ProfileOAuth2TokenServiceFactory::GetForProfile( | 396 ProfileOAuth2TokenServiceFactory::GetForProfile( |
| 399 delegate_->GetBrowserProfile()); | 397 delegate_->GetBrowserProfile()); |
| 400 if (account_id != account_id_) | 398 if (account_id != account_id_) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 420 void ProfileDownloader::OnGetTokenFailure( | 418 void ProfileDownloader::OnGetTokenFailure( |
| 421 const OAuth2TokenService::Request* request, | 419 const OAuth2TokenService::Request* request, |
| 422 const GoogleServiceAuthError& error) { | 420 const GoogleServiceAuthError& error) { |
| 423 DCHECK_EQ(request, oauth2_access_token_request_.get()); | 421 DCHECK_EQ(request, oauth2_access_token_request_.get()); |
| 424 oauth2_access_token_request_.reset(); | 422 oauth2_access_token_request_.reset(); |
| 425 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed:" | 423 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed:" |
| 426 << error.ToString(); | 424 << error.ToString(); |
| 427 delegate_->OnProfileDownloadFailure( | 425 delegate_->OnProfileDownloadFailure( |
| 428 this, ProfileDownloaderDelegate::TOKEN_ERROR); | 426 this, ProfileDownloaderDelegate::TOKEN_ERROR); |
| 429 } | 427 } |
| OLD | NEW |