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

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

Issue 8375039: Create a content::UrlFetcher interface that lives in content/public/common and convert users to i... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 9 years, 1 month 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/image_downloader.h" 5 #include "chrome/browser/chromeos/login/image_downloader.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 11 matching lines...) Expand all
22 const char kAuthorizationHeader[] = "Authorization: GoogleLogin auth=%s"; 22 const char kAuthorizationHeader[] = "Authorization: GoogleLogin auth=%s";
23 23
24 } // namespace 24 } // namespace
25 25
26 ImageDownloader::ImageDownloader(ImageDecoder::Delegate* delegate, 26 ImageDownloader::ImageDownloader(ImageDecoder::Delegate* delegate,
27 const GURL& image_url, 27 const GURL& image_url,
28 const std::string& auth_token) 28 const std::string& auth_token)
29 : delegate_(delegate) { 29 : delegate_(delegate) {
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
31 image_fetcher_.reset(new URLFetcher(GURL(image_url), URLFetcher::GET, this)); 31 image_fetcher_.reset(new URLFetcher(GURL(image_url), URLFetcher::GET, this));
32 image_fetcher_->set_request_context( 32 image_fetcher_->SetRequestContext(
33 ProfileManager::GetDefaultProfile()->GetRequestContext()); 33 ProfileManager::GetDefaultProfile()->GetRequestContext());
34 if (!auth_token.empty()) { 34 if (!auth_token.empty()) {
35 image_fetcher_->set_extra_request_headers( 35 image_fetcher_->SetExtraRequestHeaders(
36 base::StringPrintf(kAuthorizationHeader, auth_token.c_str())); 36 base::StringPrintf(kAuthorizationHeader, auth_token.c_str()));
37 } 37 }
38 image_fetcher_->Start(); 38 image_fetcher_->Start();
39 } 39 }
40 40
41 ImageDownloader::~ImageDownloader() {} 41 ImageDownloader::~ImageDownloader() {}
42 42
43 void ImageDownloader::OnURLFetchComplete(const URLFetcher* source) { 43 void ImageDownloader::OnURLFetchComplete(const content::URLFetcher* source) {
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
45 std::string data; 45 std::string data;
46 source->GetResponseAsString(&data); 46 source->GetResponseAsString(&data);
47 if (source->response_code() != 200) { 47 if (source->GetResponseCode() != 200) {
48 LOG(ERROR) << "Response code is " << source->response_code(); 48 LOG(ERROR) << "Response code is " << source->GetResponseCode();
49 LOG(ERROR) << "Url is " << source->url().spec(); 49 LOG(ERROR) << "Url is " << source->GetUrl().spec();
50 LOG(ERROR) << "Data is " << data; 50 LOG(ERROR) << "Data is " << data;
51 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 51 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
52 return; 52 return;
53 } 53 }
54 54
55 VLOG(1) << "Decoding the image..."; 55 VLOG(1) << "Decoding the image...";
56 scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder(delegate_, data); 56 scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder(delegate_, data);
57 image_decoder->Start(); 57 image_decoder->Start();
58 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 58 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
59 } 59 }
60 60
61 } // namespace chromeos 61 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/image_downloader.h ('k') | chrome/browser/chromeos/login/issue_response_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698