Commit 019667bd authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Avoid races in HistoryMenuBridge.

BUG=916749

Change-Id: Ideb4f53009923138676063e2186332c0b4d147a2
Reviewed-on: https://chromium-review.googlesource.com/c/1393021Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619460}
parent 38882290
...@@ -140,6 +140,10 @@ class HistoryMenuBridgeTest : public CocoaProfileTest { ...@@ -140,6 +140,10 @@ class HistoryMenuBridgeTest : public CocoaProfileTest {
bridge_->GotFaviconData(item, image_result); bridge_->GotFaviconData(item, image_result);
} }
void CancelFaviconRequest(HistoryMenuBridge::HistoryItem* item) {
bridge_->CancelFaviconRequest(item);
}
std::unique_ptr<MockBridge> bridge_; std::unique_ptr<MockBridge> bridge_;
}; };
...@@ -347,6 +351,9 @@ TEST_F(HistoryMenuBridgeTest, GetFaviconForHistoryItem) { ...@@ -347,6 +351,9 @@ TEST_F(HistoryMenuBridgeTest, GetFaviconForHistoryItem) {
// Make sure the item was modified properly. // Make sure the item was modified properly.
EXPECT_TRUE(item.icon_requested); EXPECT_TRUE(item.icon_requested);
EXPECT_NE(base::CancelableTaskTracker::kBadTaskId, item.icon_task_id); EXPECT_NE(base::CancelableTaskTracker::kBadTaskId, item.icon_task_id);
// Cancel the request.
CancelFaviconRequest(&item);
} }
TEST_F(HistoryMenuBridgeTest, GotFaviconData) { TEST_F(HistoryMenuBridgeTest, GotFaviconData) {
...@@ -360,6 +367,9 @@ TEST_F(HistoryMenuBridgeTest, GotFaviconData) { ...@@ -360,6 +367,9 @@ TEST_F(HistoryMenuBridgeTest, GotFaviconData) {
item.menu_item.reset([[NSMenuItem alloc] init]); item.menu_item.reset([[NSMenuItem alloc] init]);
GetFaviconForHistoryItem(&item); GetFaviconForHistoryItem(&item);
// Cancel the request so there will be no race.
CancelFaviconRequest(&item);
// Pretend to be called back. // Pretend to be called back.
favicon_base::FaviconImageResult image_result; favicon_base::FaviconImageResult image_result;
image_result.image = gfx::Image::CreateFrom1xBitmap(bitmap); image_result.image = gfx::Image::CreateFrom1xBitmap(bitmap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment