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

Side by Side Diff: android_webview/browser/icon_helper.cc

Issue 1013843002: favor DCHECK_CURRENTLY_ON for better logs in android_webview/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change a few more Created 5 years, 9 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) 2013 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 "android_webview/browser/icon_helper.h" 5 #include "android_webview/browser/icon_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/hash.h" 9 #include "base/hash.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 20 matching lines...) Expand all
31 void IconHelper::SetListener(Listener* listener) { 31 void IconHelper::SetListener(Listener* listener) {
32 listener_ = listener; 32 listener_ = listener;
33 } 33 }
34 34
35 void IconHelper::DownloadFaviconCallback( 35 void IconHelper::DownloadFaviconCallback(
36 int id, 36 int id,
37 int http_status_code, 37 int http_status_code,
38 const GURL& image_url, 38 const GURL& image_url,
39 const std::vector<SkBitmap>& bitmaps, 39 const std::vector<SkBitmap>& bitmaps,
40 const std::vector<gfx::Size>& original_bitmap_sizes) { 40 const std::vector<gfx::Size>& original_bitmap_sizes) {
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 41 DCHECK_CURRENTLY_ON(BrowserThread::UI);
42 if (http_status_code == 404) { 42 if (http_status_code == 404) {
43 MarkUnableToDownloadFavicon(image_url); 43 MarkUnableToDownloadFavicon(image_url);
44 return; 44 return;
45 } 45 }
46 46
47 if (bitmaps.size() == 0) { 47 if (bitmaps.size() == 0) {
48 return; 48 return;
49 } 49 }
50 50
51 // We can protentially have multiple frames of the icon 51 // We can protentially have multiple frames of the icon
52 // in different sizes. We need more fine grain API spec 52 // in different sizes. We need more fine grain API spec
53 // to let clients pick out the frame they want. 53 // to let clients pick out the frame they want.
54 54
55 // TODO(acleung): Pick the best icon to return based on size. 55 // TODO(acleung): Pick the best icon to return based on size.
56 if (listener_) 56 if (listener_)
57 listener_->OnReceivedIcon(image_url, bitmaps[0]); 57 listener_->OnReceivedIcon(image_url, bitmaps[0]);
58 } 58 }
59 59
60 void IconHelper::DidUpdateFaviconURL( 60 void IconHelper::DidUpdateFaviconURL(
61 const std::vector<content::FaviconURL>& candidates) { 61 const std::vector<content::FaviconURL>& candidates) {
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 62 DCHECK_CURRENTLY_ON(BrowserThread::UI);
63 for (std::vector<content::FaviconURL>::const_iterator i = candidates.begin(); 63 for (std::vector<content::FaviconURL>::const_iterator i = candidates.begin();
64 i != candidates.end(); ++i) { 64 i != candidates.end(); ++i) {
65 if (!i->icon_url.is_valid()) 65 if (!i->icon_url.is_valid())
66 continue; 66 continue;
67 67
68 switch(i->icon_type) { 68 switch(i->icon_type) {
69 case content::FaviconURL::FAVICON: 69 case content::FaviconURL::FAVICON:
70 if ((listener_ && !listener_->ShouldDownloadFavicon(i->icon_url)) || 70 if ((listener_ && !listener_->ShouldDownloadFavicon(i->icon_url)) ||
71 WasUnableToDownloadFavicon(i->icon_url)) { 71 WasUnableToDownloadFavicon(i->icon_url)) {
72 break; 72 break;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 bool IconHelper::WasUnableToDownloadFavicon(const GURL& icon_url) const { 111 bool IconHelper::WasUnableToDownloadFavicon(const GURL& icon_url) const {
112 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); 112 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec());
113 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); 113 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end();
114 } 114 }
115 115
116 void IconHelper::ClearUnableToDownloadFavicons() { 116 void IconHelper::ClearUnableToDownloadFavicons() {
117 missing_favicon_urls_.clear(); 117 missing_favicon_urls_.clear();
118 } 118 }
119 119
120 } // namespace android_webview 120 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/aw_resource_context.cc ('k') | android_webview/browser/net/aw_network_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698