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

Unified Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 1059743003: Remove NOTIFICATION_FAVICON_UPDATED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@get-active-title
Patch Set: Address comment Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/favicon/favicon_tab_helper_browsertest.cc ('k') | components/favicon/core/favicon_driver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prerender/prerender_browsertest.cc
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index 8f68a2dc039c40e30e4cfabba1c170aea5e9e8f2..ddddae42e78ec0d776581ad2f92e4d845febf003 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -14,6 +14,7 @@
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
#include "base/run_loop.h"
+#include "base/scoped_observer.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -66,6 +67,7 @@
#include "chrome/test/base/test_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
+#include "components/favicon/core/favicon_driver_observer.h"
#include "components/variations/entropy_provider.h"
#include "components/variations/variations_associated_data.h"
#include "content/public/browser/browser_message_filter.h"
@@ -131,6 +133,40 @@ namespace prerender {
namespace {
+class FaviconUpdateWatcher : public favicon::FaviconDriverObserver {
+ public:
+ explicit FaviconUpdateWatcher(content::WebContents* web_contents)
+ : seen_(false), running_(false), scoped_observer_(this) {
+ scoped_observer_.Add(FaviconTabHelper::FromWebContents(web_contents));
+ }
+
+ void Wait() {
+ if (seen_)
+ return;
+
+ running_ = true;
+ message_loop_runner_ = new content::MessageLoopRunner;
+ message_loop_runner_->Run();
+ }
+
+ private:
+ void OnFaviconAvailable(const gfx::Image& image) override {}
+ void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver,
+ bool icon_url_changed) override {
+ seen_ = true;
+ if (!running_)
+ return;
+
+ message_loop_runner_->Quit();
+ running_ = false;
+ }
+
+ bool seen_;
+ bool running_;
+ ScopedObserver<FaviconTabHelper, FaviconUpdateWatcher> scoped_observer_;
+ scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
+};
jochen (gone - plz use gerrit) 2015/04/07 19:03:25 nit. DISALLOW_COPY_AND_ASSIGN()
+
class MockNetworkChangeNotifierWIFI : public NetworkChangeNotifier {
public:
ConnectionType GetCurrentConnectionType() const override {
@@ -3146,9 +3182,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderFavicon) {
if (!FaviconTabHelper::FromWebContents(
GetActiveWebContents())->FaviconIsValid()) {
// If the favicon has not been set yet, wait for it to be.
- content::WindowedNotificationObserver favicon_update_watcher(
- chrome::NOTIFICATION_FAVICON_UPDATED,
- content::Source<WebContents>(GetActiveWebContents()));
+ FaviconUpdateWatcher favicon_update_watcher(GetActiveWebContents());
favicon_update_watcher.Wait();
}
EXPECT_TRUE(FaviconTabHelper::FromWebContents(
« no previous file with comments | « chrome/browser/favicon/favicon_tab_helper_browsertest.cc ('k') | components/favicon/core/favicon_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698