Commit 997ffda4 authored by inglorion's avatar inglorion Committed by Commit Bot

Revert "[Previews] Add offline check before HintsFetch."

This reverts commit
b58c0181 (crrev.com/c/1715505).

Reason for revert: causes crashes in browser_tests (crbug.com/988887).

Bug: 988887
Change-Id: Iacb009a129c66c905b15b4f81544d3ad25706de6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1725323
Auto-Submit: Bob Haarman <inglorion@chromium.org>
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Reviewed-by: default avatarRobert Ogden <robertogden@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682162}
parent f9900b73
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include "components/previews/core/previews_switches.h" #include "components/previews/core/previews_switches.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "content/public/test/network_connection_change_simulator.h"
#include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h" #include "net/test/embedded_test_server/http_response.h"
#include "services/network/public/cpp/network_quality_tracker.h" #include "services/network/public/cpp/network_quality_tracker.h"
...@@ -169,11 +168,6 @@ class HintsFetcherDisabledBrowserTest : public InProcessBrowserTest { ...@@ -169,11 +168,6 @@ class HintsFetcherDisabledBrowserTest : public InProcessBrowserTest {
run_loop.Run(); run_loop.Run();
} }
void SetNetworkConnectionOffline() {
content::NetworkConnectionChangeSimulator().SetConnectionType(
network::mojom::ConnectionType::CONNECTION_NONE);
}
// Seeds the Site Engagement Service with two HTTP and two HTTPS sites for the // Seeds the Site Engagement Service with two HTTP and two HTTPS sites for the
// current profile. // current profile.
void SeedSiteEngagementService() { void SeedSiteEngagementService() {
...@@ -658,30 +652,3 @@ IN_PROC_BROWSER_TEST_F( ...@@ -658,30 +652,3 @@ IN_PROC_BROWSER_TEST_F(
optimization_guide::HintCacheStore::StoreEntryType::kComponentHint), optimization_guide::HintCacheStore::StoreEntryType::kComponentHint),
0); 0);
} }
IN_PROC_BROWSER_TEST_F(
HintsFetcherBrowserTest,
DISABLE_ON_WIN_MAC_CHROMESOS(HintsFetcherNetworkOffline)) {
const base::HistogramTester* histogram_tester = GetHistogramTester();
GURL url = https_url();
base::CommandLine::ForCurrentProcess()->RemoveSwitch(
optimization_guide::switches::kFetchHintsOverride);
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kFetchHintsOverrideTimer);
// Set the network to be offline.
SetNetworkConnectionOffline();
// Set the blacklist state to initialized so the sites in the engagement
// service will be used and not blacklisted on the first GetTopHosts
// request.
SetTopHostBlacklistState(optimization_guide::prefs::
HintsFetcherTopHostBlacklistState::kInitialized);
// Whitelist NoScript for https_url()'s' host.
SetUpComponentUpdateHints(https_url());
// No HintsFetch should occur because the connection is offline.
histogram_tester->ExpectTotalCount(
"OptimizationGuide.HintsFetcher.GetHintsRequest.HostCount", 0);
}
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
assert(!is_ios, "Optimization Guide is not available on iOS.")
static_library("optimization_guide") { static_library("optimization_guide") {
sources = [ sources = [
"bloom_filter.cc", "bloom_filter.cc",
...@@ -44,7 +42,6 @@ static_library("optimization_guide") { ...@@ -44,7 +42,6 @@ static_library("optimization_guide") {
"//components/leveldb_proto", "//components/leveldb_proto",
"//components/optimization_guide/proto:optimization_guide_proto", "//components/optimization_guide/proto:optimization_guide_proto",
"//components/prefs", "//components/prefs",
"//content/public/browser",
"//google_apis", "//google_apis",
"//net:net", "//net:net",
"//services/network/public/cpp", "//services/network/public/cpp",
......
include_rules = [ include_rules = [
"+components/leveldb_proto", "+components/leveldb_proto",
"+components/prefs", "+components/prefs",
"+content/public/browser",
"+google_apis", "+google_apis",
"+net", "+net",
"+services/network", "+services/network",
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "components/optimization_guide/optimization_guide_features.h" #include "components/optimization_guide/optimization_guide_features.h"
#include "components/optimization_guide/proto/hints.pb.h" #include "components/optimization_guide/proto/hints.pb.h"
#include "content/public/browser/network_service_instance.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/base/url_util.h" #include "net/base/url_util.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h" #include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h" #include "services/network/public/cpp/simple_url_loader.h"
...@@ -42,11 +42,6 @@ bool HintsFetcher::FetchOptimizationGuideServiceHints( ...@@ -42,11 +42,6 @@ bool HintsFetcher::FetchOptimizationGuideServiceHints(
HintsFetchedCallback hints_fetched_callback) { HintsFetchedCallback hints_fetched_callback) {
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
if (content::GetNetworkConnectionTracker()->IsOffline()) {
std::move(hints_fetched_callback_).Run(base::nullopt);
return false;
}
if (url_loader_) if (url_loader_)
return false; return false;
......
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