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/location.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 const gfx::Image& image) override { | 140 const gfx::Image& image) override { |
141 OnNotification(); | 141 OnNotification(); |
142 } | 142 } |
143 | 143 |
144 void OnNotification() { | 144 void OnNotification() { |
145 if (!quit_closure_.is_null()) { | 145 if (!quit_closure_.is_null()) { |
146 // We stop waiting based on changes in state to FaviconHandler which occur | 146 // We stop waiting based on changes in state to FaviconHandler which occur |
147 // immediately after OnFaviconUpdated() is called. Post a task to check if | 147 // immediately after OnFaviconUpdated() is called. Post a task to check if |
148 // we can stop waiting. | 148 // we can stop waiting. |
149 base::ThreadTaskRunnerHandle::Get()->PostTask( | 149 base::ThreadTaskRunnerHandle::Get()->PostTask( |
150 FROM_HERE, base::Bind(&PendingTaskWaiter::EndLoopIfCanStopWaiting, | 150 FROM_HERE, base::BindOnce(&PendingTaskWaiter::EndLoopIfCanStopWaiting, |
151 weak_factory_.GetWeakPtr())); | 151 weak_factory_.GetWeakPtr())); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 void EndLoopIfCanStopWaiting() { | 155 void EndLoopIfCanStopWaiting() { |
156 if (!quit_closure_.is_null() && | 156 if (!quit_closure_.is_null() && |
157 load_stopped_ && | 157 load_stopped_ && |
158 !checker_->HasPendingTasks()) { | 158 !checker_->HasPendingTasks()) { |
159 quit_closure_.Run(); | 159 quit_closure_.Run(); |
160 } | 160 } |
161 } | 161 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 // A reload ignoring the cache should refetch the favicon from the website. | 233 // A reload ignoring the cache should refetch the favicon from the website. |
234 { | 234 { |
235 PendingTaskWaiter waiter(web_contents(), this); | 235 PendingTaskWaiter waiter(web_contents(), this); |
236 chrome::ExecuteCommand(browser(), IDC_RELOAD_BYPASSING_CACHE); | 236 chrome::ExecuteCommand(browser(), IDC_RELOAD_BYPASSING_CACHE); |
237 waiter.Wait(); | 237 waiter.Wait(); |
238 } | 238 } |
239 ASSERT_TRUE(delegate->was_requested()); | 239 ASSERT_TRUE(delegate->was_requested()); |
240 EXPECT_TRUE(delegate->bypassed_cache()); | 240 EXPECT_TRUE(delegate->bypassed_cache()); |
241 } | 241 } |
OLD | NEW |