| OLD | NEW |
| 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 Loading... |
| 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_) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |