OLD | NEW |
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/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
8 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
9 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/thread_task_runner_handle.h" |
10 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
17 #include "components/favicon/core/favicon_driver_observer.h" | 20 #include "components/favicon/core/favicon_driver_observer.h" |
18 #include "components/favicon/core/favicon_handler.h" | 21 #include "components/favicon/core/favicon_handler.h" |
19 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, | 146 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, |
144 bool icon_url_changed) override { | 147 bool icon_url_changed) override { |
145 OnNotification(); | 148 OnNotification(); |
146 } | 149 } |
147 | 150 |
148 void OnNotification() { | 151 void OnNotification() { |
149 if (!quit_closure_.is_null()) { | 152 if (!quit_closure_.is_null()) { |
150 // We stop waiting based on changes in state to FaviconHandler which occur | 153 // We stop waiting based on changes in state to FaviconHandler which occur |
151 // immediately after OnFaviconUpdated() is called. Post a task to check if | 154 // immediately after OnFaviconUpdated() is called. Post a task to check if |
152 // we can stop waiting. | 155 // we can stop waiting. |
153 base::MessageLoopForUI::current()->PostTask( | 156 base::ThreadTaskRunnerHandle::Get()->PostTask( |
154 FROM_HERE, base::Bind(&PendingTaskWaiter::EndLoopIfCanStopWaiting, | 157 FROM_HERE, base::Bind(&PendingTaskWaiter::EndLoopIfCanStopWaiting, |
155 weak_factory_.GetWeakPtr())); | 158 weak_factory_.GetWeakPtr())); |
156 } | 159 } |
157 } | 160 } |
158 | 161 |
159 void EndLoopIfCanStopWaiting() { | 162 void EndLoopIfCanStopWaiting() { |
160 if (!quit_closure_.is_null() && | 163 if (!quit_closure_.is_null() && |
161 load_stopped_ && | 164 load_stopped_ && |
162 !checker_->HasPendingTasks()) { | 165 !checker_->HasPendingTasks()) { |
163 quit_closure_.Run(); | 166 quit_closure_.Run(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 237 |
235 // A reload ignoring the cache should refetch the favicon from the website. | 238 // A reload ignoring the cache should refetch the favicon from the website. |
236 { | 239 { |
237 PendingTaskWaiter waiter(web_contents(), this); | 240 PendingTaskWaiter waiter(web_contents(), this); |
238 chrome::ExecuteCommand(browser(), IDC_RELOAD_IGNORING_CACHE); | 241 chrome::ExecuteCommand(browser(), IDC_RELOAD_IGNORING_CACHE); |
239 waiter.Wait(); | 242 waiter.Wait(); |
240 } | 243 } |
241 ASSERT_TRUE(delegate->was_requested()); | 244 ASSERT_TRUE(delegate->was_requested()); |
242 EXPECT_TRUE(delegate->bypassed_cache()); | 245 EXPECT_TRUE(delegate->bypassed_cache()); |
243 } | 246 } |
OLD | NEW |