Commit 7975ab47 authored by Dave Schuyler's avatar Dave Schuyler Committed by Commit Bot

[Omnibox] Move bitmap fetcher cancel

This CL moves when the bitmap fetcher request is canceled. This change
is being made to reduce noise in a future CL (where the request_id_ will
be a collection of request IDs rather than just one). Along the way,
several presubmit warnings are addressed.

The overall intention is make a future CL clearer (less noisy).

Bug: None
Change-Id: I8455f7921c85b3bd9824e06355b7c1c068fec5b2
Reviewed-on: https://chromium-review.googlesource.com/1011284Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Dave Schuyler <dschuyler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550699}
parent f0a94e7a
......@@ -6,7 +6,9 @@
#include <stddef.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
......@@ -269,15 +271,16 @@ void ChromeOmniboxClient::OnResultChanged(
const AutocompleteResult& result,
bool default_match_changed,
const BitmapFetchedCallback& on_bitmap_fetched) {
BitmapFetcherService* image_service =
BitmapFetcherServiceFactory::GetForBrowserContext(profile_);
if (!image_service) {
return;
}
image_service->CancelRequest(request_id_);
const auto match = std::find_if(
result.begin(), result.end(),
[](const AutocompleteMatch& current) { return !!current.answer; });
if (match != result.end()) {
BitmapFetcherService* image_service =
BitmapFetcherServiceFactory::GetForBrowserContext(profile_);
if (image_service) {
image_service->CancelRequest(request_id_);
// TODO(jdonnelly, rhalavati): Create a helper function with Callback to
// create annotation and pass it to image_service, merging this annotation
// and the one in
......@@ -321,11 +324,10 @@ void ChromeOmniboxClient::OnResultChanged(
request_id_ = image_service->RequestImage(
match->answer->second_line().image_url(),
new AnswerImageObserver(
base::Bind(&ChromeOmniboxClient::OnBitmapFetched,
base::BindRepeating(&ChromeOmniboxClient::OnBitmapFetched,
base::Unretained(this), on_bitmap_fetched)),
traffic_annotation);
}
}
}
gfx::Image ChromeOmniboxClient::GetFaviconForPageUrl(
......@@ -414,7 +416,7 @@ void ChromeOmniboxClient::OnURLOpenedFromOmnibox(OmniboxLog* log) {
}
void ChromeOmniboxClient::OnBookmarkLaunched() {
RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_OMNIBOX);
RecordBookmarkLaunch(nullptr, BOOKMARK_LAUNCH_LOCATION_OMNIBOX);
}
void ChromeOmniboxClient::DiscardNonCommittedNavigations() {
......
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