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

Side by Side Diff: chrome/browser/favicon/content_favicon_driver_browsertest.cc

Issue 1407353012: Refactor FaviconDriver::OnFaviconAvailable() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@initial_simplify
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/favicon/content/content_favicon_driver.h" 5 #include "components/favicon/content/content_favicon_driver.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/scoped_observer.h" 10 #include "base/scoped_observer.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 void Observe(int type, 135 void Observe(int type,
136 const content::NotificationSource& source, 136 const content::NotificationSource& source,
137 const content::NotificationDetails& details) override { 137 const content::NotificationDetails& details) override {
138 if (type == content::NOTIFICATION_LOAD_STOP) 138 if (type == content::NOTIFICATION_LOAD_STOP)
139 load_stopped_ = true; 139 load_stopped_ = true;
140 140
141 OnNotification(); 141 OnNotification();
142 } 142 }
143 143
144 // favicon::Favicon 144 // favicon::Favicon
145 void OnFaviconAvailable(const gfx::Image& image) override {}
146 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, 145 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver,
147 bool icon_url_changed) override { 146 NotificationIconType notification_icon_type,
147 const GURL& icon_url,
148 bool icon_url_changed,
149 const gfx::Image& image) override {
148 OnNotification(); 150 OnNotification();
149 } 151 }
150 152
151 void OnNotification() { 153 void OnNotification() {
152 if (!quit_closure_.is_null()) { 154 if (!quit_closure_.is_null()) {
153 // We stop waiting based on changes in state to FaviconHandler which occur 155 // We stop waiting based on changes in state to FaviconHandler which occur
154 // immediately after OnFaviconUpdated() is called. Post a task to check if 156 // immediately after OnFaviconUpdated() is called. Post a task to check if
155 // we can stop waiting. 157 // we can stop waiting.
156 base::ThreadTaskRunnerHandle::Get()->PostTask( 158 base::ThreadTaskRunnerHandle::Get()->PostTask(
157 FROM_HERE, base::Bind(&PendingTaskWaiter::EndLoopIfCanStopWaiting, 159 FROM_HERE, base::Bind(&PendingTaskWaiter::EndLoopIfCanStopWaiting,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 239
238 // A reload ignoring the cache should refetch the favicon from the website. 240 // A reload ignoring the cache should refetch the favicon from the website.
239 { 241 {
240 PendingTaskWaiter waiter(web_contents(), this); 242 PendingTaskWaiter waiter(web_contents(), this);
241 chrome::ExecuteCommand(browser(), IDC_RELOAD_IGNORING_CACHE); 243 chrome::ExecuteCommand(browser(), IDC_RELOAD_IGNORING_CACHE);
242 waiter.Wait(); 244 waiter.Wait();
243 } 245 }
244 ASSERT_TRUE(delegate->was_requested()); 246 ASSERT_TRUE(delegate->was_requested());
245 EXPECT_TRUE(delegate->bypassed_cache()); 247 EXPECT_TRUE(delegate->bypassed_cache());
246 } 248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698