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

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

Issue 1097383005: Add possibility to define data callback to BitmapFetcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@r479598_extensions_content_verifier_directories_fail
Patch Set: Clarified how calling Init/Start twice works + fixed android Created 5 years, 6 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
« no previous file with comments | « chrome/browser/image_holder.cc ('k') | chrome/browser/search/suggestions/image_fetcher_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_avatar_downloader.h" 5 #include "chrome/browser/profiles/profile_avatar_downloader.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
(...skipping 17 matching lines...) Expand all
28 fetcher_.reset(new chrome::BitmapFetcher(url, this)); 28 fetcher_.reset(new chrome::BitmapFetcher(url, this));
29 } 29 }
30 30
31 ProfileAvatarDownloader::~ProfileAvatarDownloader() { 31 ProfileAvatarDownloader::~ProfileAvatarDownloader() {
32 } 32 }
33 33
34 void ProfileAvatarDownloader::Start() { 34 void ProfileAvatarDownloader::Start() {
35 // In unit tests, the browser process can return a NULL request context. 35 // In unit tests, the browser process can return a NULL request context.
36 net::URLRequestContextGetter* request_context = 36 net::URLRequestContextGetter* request_context =
37 g_browser_process->system_request_context(); 37 g_browser_process->system_request_context();
38 if (request_context) 38 if (request_context) {
39 fetcher_->Start( 39 fetcher_->Init(
40 request_context, 40 request_context,
41 std::string(), 41 std::string(),
42 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, 42 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
43 net::LOAD_NORMAL); 43 net::LOAD_NORMAL);
44 fetcher_->Start();
45 }
44 } 46 }
45 47
46 // BitmapFetcherDelegate overrides. 48 // BitmapFetcherDelegate overrides.
47 void ProfileAvatarDownloader::OnFetchComplete(const GURL& url, 49 void ProfileAvatarDownloader::OnFetchComplete(const GURL& url,
48 const SkBitmap* bitmap) { 50 const SkBitmap* bitmap) {
49 if (!bitmap || !cache_) 51 if (!bitmap || !cache_)
50 return; 52 return;
51 53
52 // Decode the downloaded bitmap. Ownership of the image is taken by |cache_|. 54 // Decode the downloaded bitmap. Ownership of the image is taken by |cache_|.
53 gfx::Image image = gfx::Image::CreateFrom1xBitmap(*bitmap); 55 gfx::Image image = gfx::Image::CreateFrom1xBitmap(*bitmap);
54 cache_->SaveAvatarImageAtPath(&image, 56 cache_->SaveAvatarImageAtPath(&image,
55 profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index_), 57 profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index_),
56 profiles::GetPathOfHighResAvatarAtIndex(icon_index_), 58 profiles::GetPathOfHighResAvatarAtIndex(icon_index_),
57 profile_path_); 59 profile_path_);
58 } 60 }
OLDNEW
« no previous file with comments | « chrome/browser/image_holder.cc ('k') | chrome/browser/search/suggestions/image_fetcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698