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

Side by Side Diff: chrome/browser/dom_ui/dom_ui_favicon_source.cc

Issue 3060024: Partially revert r53873 (and the valgrind suppression for it). (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/dom_ui/dom_ui_favicon_source.h" 5 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "chrome/browser/chrome_thread.h" 9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/profile.h" 10 #include "chrome/browser/profile.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "grit/app_resources.h" 12 #include "grit/app_resources.h"
13 13
14 DOMUIFavIconSource::DOMUIFavIconSource(Profile* profile) 14 DOMUIFavIconSource::DOMUIFavIconSource(Profile* profile)
15 : DataSource(chrome::kChromeUIFavIconHost, MessageLoop::current()), 15 : DataSource(chrome::kChromeUIFavIconHost, MessageLoop::current()),
16 profile_(profile) { 16 profile_(profile) {
17 } 17 }
18 18
19 DOMUIFavIconSource::~DOMUIFavIconSource() { 19 DOMUIFavIconSource::~DOMUIFavIconSource() {
20 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
21 } 20 }
22 21
23 void DOMUIFavIconSource::StartDataRequest(const std::string& path, 22 void DOMUIFavIconSource::StartDataRequest(const std::string& path,
24 bool is_off_the_record, 23 bool is_off_the_record,
25 int request_id) { 24 int request_id) {
26 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
27 FaviconService* favicon_service = 25 FaviconService* favicon_service =
28 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 26 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
29 if (favicon_service) { 27 if (favicon_service) {
30 FaviconService::Handle handle; 28 FaviconService::Handle handle;
31 if (path.size() > 8 && path.substr(0, 8) == "iconurl/") { 29 if (path.size() > 8 && path.substr(0, 8) == "iconurl/") {
32 handle = favicon_service->GetFavicon( 30 handle = favicon_service->GetFavicon(
33 GURL(path.substr(8)), 31 GURL(path.substr(8)),
34 &cancelable_consumer_, 32 &cancelable_consumer_,
35 NewCallback(this, &DOMUIFavIconSource::OnFavIconDataAvailable)); 33 NewCallback(this, &DOMUIFavIconSource::OnFavIconDataAvailable));
36 } else { 34 } else {
(...skipping 14 matching lines...) Expand all
51 // drag the image they get no extension. 49 // drag the image they get no extension.
52 return "image/png"; 50 return "image/png";
53 } 51 }
54 52
55 void DOMUIFavIconSource::OnFavIconDataAvailable( 53 void DOMUIFavIconSource::OnFavIconDataAvailable(
56 FaviconService::Handle request_handle, 54 FaviconService::Handle request_handle,
57 bool know_favicon, 55 bool know_favicon,
58 scoped_refptr<RefCountedMemory> data, 56 scoped_refptr<RefCountedMemory> data,
59 bool expired, 57 bool expired,
60 GURL icon_url) { 58 GURL icon_url) {
61 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
62 FaviconService* favicon_service = 59 FaviconService* favicon_service =
63 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 60 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
64 int request_id = cancelable_consumer_.GetClientData(favicon_service, 61 int request_id = cancelable_consumer_.GetClientData(favicon_service,
65 request_handle); 62 request_handle);
66 63
67 if (know_favicon && data.get() && data->size()) { 64 if (know_favicon && data.get() && data->size()) {
68 // Forward the data along to the networking system. 65 // Forward the data along to the networking system.
69 SendResponse(request_id, data); 66 SendResponse(request_id, data);
70 } else { 67 } else {
71 if (!default_favicon_.get()) { 68 if (!default_favicon_.get()) {
72 default_favicon_ = 69 default_favicon_ =
73 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 70 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
74 IDR_DEFAULT_FAVICON); 71 IDR_DEFAULT_FAVICON);
75 } 72 }
76 73
77 SendResponse(request_id, default_favicon_); 74 SendResponse(request_id, default_favicon_);
78 } 75 }
79 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698