| OLD | NEW |
| 1 // Copyright (c) 2012 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 net::LOAD_DO_NOT_SAVE_COOKIES); | 330 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 331 if (!auth_token_.empty()) { | 331 if (!auth_token_.empty()) { |
| 332 profile_image_fetcher_->SetExtraRequestHeaders( | 332 profile_image_fetcher_->SetExtraRequestHeaders( |
| 333 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str())); | 333 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str())); |
| 334 } | 334 } |
| 335 profile_image_fetcher_->Start(); | 335 profile_image_fetcher_->Start(); |
| 336 } else if (source == profile_image_fetcher_.get()) { | 336 } else if (source == profile_image_fetcher_.get()) { |
| 337 VLOG(1) << "Decoding the image..."; | 337 VLOG(1) << "Decoding the image..."; |
| 338 scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder( | 338 scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder( |
| 339 this, data, ImageDecoder::DEFAULT_CODEC); | 339 this, data, ImageDecoder::DEFAULT_CODEC); |
| 340 image_decoder->Start(); | 340 scoped_refptr<base::MessageLoopProxy> task_runner = |
| 341 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
| 342 image_decoder->Start(task_runner); |
| 341 } | 343 } |
| 342 } | 344 } |
| 343 | 345 |
| 344 void ProfileDownloader::OnImageDecoded(const ImageDecoder* decoder, | 346 void ProfileDownloader::OnImageDecoded(const ImageDecoder* decoder, |
| 345 const SkBitmap& decoded_image) { | 347 const SkBitmap& decoded_image) { |
| 346 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 348 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 347 int image_size = delegate_->GetDesiredImageSideLength(); | 349 int image_size = delegate_->GetDesiredImageSideLength(); |
| 348 profile_picture_ = skia::ImageOperations::Resize( | 350 profile_picture_ = skia::ImageOperations::Resize( |
| 349 decoded_image, | 351 decoded_image, |
| 350 skia::ImageOperations::RESIZE_BEST, | 352 skia::ImageOperations::RESIZE_BEST, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 auth_token_ = access_token; | 395 auth_token_ = access_token; |
| 394 StartFetchingImage(); | 396 StartFetchingImage(); |
| 395 } | 397 } |
| 396 | 398 |
| 397 // Callback for OAuth2AccessTokenFetcher on failure. | 399 // Callback for OAuth2AccessTokenFetcher on failure. |
| 398 void ProfileDownloader::OnGetTokenFailure(const GoogleServiceAuthError& error) { | 400 void ProfileDownloader::OnGetTokenFailure(const GoogleServiceAuthError& error) { |
| 399 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed"; | 401 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed"; |
| 400 delegate_->OnProfileDownloadFailure( | 402 delegate_->OnProfileDownloadFailure( |
| 401 this, ProfileDownloaderDelegate::TOKEN_ERROR); | 403 this, ProfileDownloaderDelegate::TOKEN_ERROR); |
| 402 } | 404 } |
| OLD | NEW |