Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into master.lion
  • Loading branch information
bluebox authored and bluebox committed Oct 25, 2020
2 parents b306f5e + a073e77 commit ffa21d9
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 44 deletions.
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling devtools-frontend
# and whatever else without interference from each other.
'devtools_frontend_revision': 'a0a498d917bc08c6c5f17556232aeda86e961bef',
'devtools_frontend_revision': '754b80c7bb21908da53324853fb970a7c4949c15',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling libprotobuf-mutator
# and whatever else without interference from each other.
Expand Down Expand Up @@ -1569,7 +1569,7 @@ deps = {
Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'),

'src-internal': {
'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@3f101db86c969209e06dc21c635a985354df4bbd',
'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@06a6dc30f016ef338d7bf8985b76afe0befabc09',
'condition': 'checkout_src_internal',
},

Expand Down
2 changes: 1 addition & 1 deletion build/fuchsia/linux.sdk.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20201024.2.1
0.20201024.3.1
2 changes: 1 addition & 1 deletion build/fuchsia/mac.sdk.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20201024.2.1
0.20201024.3.1
2 changes: 1 addition & 1 deletion chrome/VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAJOR=88
MINOR=0
BUILD=4303
BUILD=4304
PATCH=0
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ bool SearchPrefetchOnlyFetchDefaultMatch() {
return base::GetFieldTrialParamByFeatureAsBool(
kSearchPrefetchServicePrefetching, "only_prefetch_default_match", false);
}

bool SearchPrefetchShouldCancelUneededInflightRequests() {
return base::GetFieldTrialParamByFeatureAsBool(
kSearchPrefetchServicePrefetching, "cancel_inflight_unneeded", true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ base::TimeDelta SearchPrefetchErrorBackoffDuration();
// Nothing is prefetched if the default match is not prefetchable.
bool SearchPrefetchOnlyFetchDefaultMatch();

// When a request is inflight, but no longer shows up in the match list, whether
// the request is canceled or allowed to finish.
bool SearchPrefetchShouldCancelUneededInflightRequests();

#endif // CHROME_BROWSER_PREFETCH_SEARCH_PREFETCH_FIELD_TRIAL_SETTINGS_H_
44 changes: 44 additions & 0 deletions chrome/browser/prefetch/search_prefetch/search_prefetch_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ SearchPrefetchService::PrefetchRequest::TakePrefetchResponse() {
return std::move(prefetch_response_container_);
}

void SearchPrefetchService::PrefetchRequest::CancelPrefetch() {
DCHECK_EQ(current_status_, SearchPrefetchStatus::kInFlight);
current_status_ = SearchPrefetchStatus::kRequestCancelled;

simple_loader_.reset();
}

SearchPrefetchService::SearchPrefetchService(Profile* profile)
: profile_(profile) {
DCHECK(!profile_->IsOffTheRecord());
Expand Down Expand Up @@ -255,6 +262,43 @@ void SearchPrefetchService::OnResultChanged(
const auto& result = controller->result();
const auto* default_match = result.default_match();

// Cancel Unneeded prefetch requests.
if (SearchPrefetchShouldCancelUneededInflightRequests()) {
auto* template_url_service =
TemplateURLServiceFactory::GetForProfile(profile_);
if (!template_url_service)
return;

// Since we limit the number of prefetches in the map, this should be fast
// despite the two loops.
for (const auto& kv_pair : prefetches_) {
const auto& search_terms = kv_pair.first;
auto& prefetch_request = kv_pair.second;
if (prefetch_request->current_status() !=
SearchPrefetchStatus::kInFlight) {
continue;
}
bool should_cancel_request = true;
for (const auto& match : result) {
base::string16 match_search_terms;
template_url_service->GetDefaultSearchProvider()
->ExtractSearchTermsFromURL(
match.destination_url,
template_url_service->search_terms_data(), &match_search_terms);

if (search_terms == match_search_terms) {
should_cancel_request = false;
break;
}
}

// Cancel the inflight request and mark it as canceled.
if (should_cancel_request) {
prefetch_request->CancelPrefetch();
}
}
}

// One arm of the experiment only prefetches the top match when it is default.
if (SearchPrefetchOnlyFetchDefaultMatch()) {
if (default_match && BaseSearchProvider::ShouldPrefetch(*default_match)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ enum class SearchPrefetchStatus {
kSuccessfullyCompleted = 2,
// The request hit an error and cannot be served.
kRequestFailed = 3,
// The request was cancelled before completion.
kRequestCancelled = 4,
};

class SearchPrefetchService : public KeyedService {
Expand Down Expand Up @@ -74,6 +76,9 @@ class SearchPrefetchService : public KeyedService {
// Starts the network request to prefetch |prefetch_url_|.
void StartPrefetchRequest(Profile* profile);

// Cancels the on-going prefetch and marks the status appropriately.
void CancelPrefetch();

SearchPrefetchStatus current_status() const { return current_status_; }

const GURL& prefetch_url() const { return prefetch_url_; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,12 @@ class SearchPrefetchBaseBrowserTest : public InProcessBrowserTest {
// the third is descriptions, fifth is an extra data dictionary. The
// google:clientdata contains "phi" which is the prefetch index (i.e., which
// suggest can be prefetched).
std::string content = "";
std::string content = R"([
"empty",
["empty", "porgs"],
["", ""],
[],
{}])";

if (request.GetURL().spec().find(kOmniboxSuggestPrefetchQuery) !=
std::string::npos) {
Expand Down Expand Up @@ -725,6 +730,70 @@ IN_PROC_BROWSER_TEST_F(SearchPrefetchServiceEnabledBrowserTest,
EXPECT_TRUE(base::Contains(inner_html, "prefetch"));
}

IN_PROC_BROWSER_TEST_F(SearchPrefetchServiceEnabledBrowserTest,
RemovingMatchCancelsInFlight) {
set_should_hang_requests(true);
auto* search_prefetch_service =
SearchPrefetchServiceFactory::GetForProfile(browser()->profile());
std::string search_terms = kOmniboxSuggestPrefetchQuery;

// Trigger an omnibox suggest fetch that has a prefetch hint.
AutocompleteInput input(
base::ASCIIToUTF16(search_terms), metrics::OmniboxEventProto::BLANK,
ChromeAutocompleteSchemeClassifier(browser()->profile()));
LocationBar* location_bar = browser()->window()->GetLocationBar();
OmniboxView* omnibox = location_bar->GetOmniboxView();
AutocompleteController* autocomplete_controller =
omnibox->model()->autocomplete_controller();

// Prevent the stop timer from killing the hints fetch early.
autocomplete_controller->SetStartStopTimerDurationForTesting(
base::TimeDelta::FromSeconds(10));
autocomplete_controller->Start(input);

ui_test_utils::WaitForAutocompleteDone(browser());
EXPECT_TRUE(autocomplete_controller->done());

WaitUntilStatusChangesTo(base::ASCIIToUTF16(search_terms),
SearchPrefetchStatus::kInFlight);
auto prefetch_status =
search_prefetch_service->GetSearchPrefetchStatusForTesting(
base::ASCIIToUTF16(search_terms));
ASSERT_TRUE(prefetch_status.has_value());
EXPECT_EQ(SearchPrefetchStatus::kInFlight, prefetch_status.value());

// Change the autocomplete to demote "porgs", but keep it as a match by using
// the default returned suggest list.
AutocompleteInput empty_input(
base::ASCIIToUTF16("empty"), metrics::OmniboxEventProto::BLANK,
ChromeAutocompleteSchemeClassifier(browser()->profile()));
autocomplete_controller->Start(empty_input);
ui_test_utils::WaitForAutocompleteDone(browser());
EXPECT_TRUE(autocomplete_controller->done());

WaitForDuration(base::TimeDelta::FromMilliseconds(100));
prefetch_status = search_prefetch_service->GetSearchPrefetchStatusForTesting(
base::ASCIIToUTF16(search_terms));
ASSERT_TRUE(prefetch_status.has_value());
EXPECT_EQ(SearchPrefetchStatus::kInFlight, prefetch_status.value());

// Change the autocomplete to remove "porgs" entirely.
AutocompleteInput other_input(
base::ASCIIToUTF16(kOmniboxSuggestNonPrefetchQuery),
metrics::OmniboxEventProto::BLANK,
ChromeAutocompleteSchemeClassifier(browser()->profile()));
autocomplete_controller->Start(other_input);
ui_test_utils::WaitForAutocompleteDone(browser());
EXPECT_TRUE(autocomplete_controller->done());

WaitUntilStatusChangesTo(base::ASCIIToUTF16(search_terms),
SearchPrefetchStatus::kRequestCancelled);
prefetch_status = search_prefetch_service->GetSearchPrefetchStatusForTesting(
base::ASCIIToUTF16(search_terms));
ASSERT_TRUE(prefetch_status.has_value());
EXPECT_EQ(SearchPrefetchStatus::kRequestCancelled, prefetch_status.value());
}

class SearchPrefetchServiceZeroCacheTimeBrowserTest
: public SearchPrefetchBaseBrowserTest {
public:
Expand Down
2 changes: 1 addition & 1 deletion chrome/build/linux.pgo.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
chrome-linux-master-1603560761-17d72f8640dc7847ade4cf9bfef5e8e7c2746b8c.profdata
chrome-linux-master-1603583489-aa627a5dd933144f589179af31a0aa634346b6c2.profdata
2 changes: 1 addition & 1 deletion chrome/build/win32.pgo.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
chrome-win32-master-1603518904-1592805c889ead1272d00ba94d0fcbf34fb14a49.profdata
chrome-win32-master-1603540106-f9997f455c401b6699b57b30de616e21c0c02270.profdata
2 changes: 1 addition & 1 deletion chrome/build/win64.pgo.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
chrome-win64-master-1603528486-21f512eebe46ab3a0db135fd2a5ef210d142a29c.profdata
chrome-win64-master-1603551129-db90a4722cc0b0a38570ed85a830a87d0465f9e9.profdata
35 changes: 0 additions & 35 deletions testing/buildbot/chromium.linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -4286,41 +4286,6 @@
},
"test_id_prefix": "ninja://content/test:fuchsia_telemetry_gpu_integration_test/"
},
{
"args": [
"maps",
"--show-stdout",
"--browser=web-engine-shell",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--git-revision=${got_revision}"
],
"isolate_name": "fuchsia_telemetry_gpu_integration_test",
"merge": {
"args": [],
"script": "//testing/merge_scripts/standard_isolated_script_merge.py"
},
"name": "maps_tests",
"precommit_args": [
"--gerrit-issue=${patch_issue}",
"--gerrit-patchset=${patch_set}",
"--buildbucket-id=${buildbucket_build_id}"
],
"should_retry_with_patch": false,
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"kvm": "1",
"os": "Ubuntu-16.04"
}
],
"idempotent": false,
"service_account": "[email protected]"
},
"test_id_prefix": "ninja://content/test:fuchsia_telemetry_gpu_integration_test/"
},
{
"args": [
"pixel",
Expand Down
5 changes: 5 additions & 0 deletions testing/buildbot/test_suite_exceptions.pyl
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,11 @@
},
},
},
'maps_tests': {
'remove_from': [
'Fuchsia x64' # https://crbug.com/1058255
],
},
'media_unittests': {
'modifications': {
'android-inverse-fieldtrials-pie-x86-fyi-rel': {
Expand Down

0 comments on commit ffa21d9

Please sign in to comment.