Commit 11e14a7c authored by Robert Ogden's avatar Robert Ogden Committed by Commit Bot

Remove PreviewsLitePageNavigationThrottleManager

Bug: 1005295
Change-Id: Ie301aae1507a6fa0f020fe302386458d924c4256
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1811959
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698653}
parent 9a28a770
......@@ -1378,7 +1378,6 @@ jumbo_split_static_library("browser") {
"previews/previews_lite_page_infobar_delegate.h",
"previews/previews_lite_page_navigation_throttle.cc",
"previews/previews_lite_page_navigation_throttle.h",
"previews/previews_lite_page_navigation_throttle_manager.h",
"previews/previews_lite_page_predictor.cc",
"previews/previews_lite_page_predictor.h",
"previews/previews_lite_page_redirect_url_loader.cc",
......
......@@ -20,7 +20,6 @@
#include "chrome/browser/data_reduction_proxy/data_reduction_proxy_chrome_settings_factory.h"
#include "chrome/browser/previews/previews_lite_page_decider.h"
#include "chrome/browser/previews/previews_lite_page_navigation_throttle.h"
#include "chrome/browser/previews/previews_lite_page_navigation_throttle_manager.h"
#include "chrome/browser/previews/previews_lite_page_url_loader_interceptor.h"
#include "chrome/browser/previews/previews_offline_helper.h"
#include "chrome/browser/previews/previews_service.h"
......
......@@ -18,7 +18,6 @@
#include "base/values.h"
#include "chrome/browser/availability/availability_prober.h"
#include "chrome/browser/previews/previews_https_notification_infobar_decider.h"
#include "chrome/browser/previews/previews_lite_page_navigation_throttle_manager.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
#include "net/http/http_request_headers.h"
......@@ -35,12 +34,9 @@ namespace user_prefs {
class PrefRegistrySyncable;
}
// This class ensures that the feature is enabled and the
// current Profile is not incognito before handing off the real legwork of the
// triggering decision to |PreviewsLitePageNavigationThrottle|.
// This class manages the triggering logic for Lite Page Redirect previews.
class PreviewsLitePageDecider
: public AvailabilityProber::Delegate,
public PreviewsLitePageNavigationThrottleManager,
public PreviewsHTTPSNotificationInfoBarDecider,
public data_reduction_proxy::DataReductionProxySettingsObserver {
public:
......@@ -78,20 +74,47 @@ class PreviewsLitePageDecider
bool NeedsToNotifyUser() override;
void NotifyUser(content::WebContents* web_contents) override;
// PreviewsLitePageNavigationThrottleManager:
void SetServerUnavailableFor(base::TimeDelta retry_after) override;
bool IsServerUnavailable() override;
void AddSingleBypass(std::string url) override;
bool CheckSingleBypass(std::string url) override;
uint64_t GeneratePageID() override;
// Used to notify that the Previews Server should not be sent anymore requests
// until after the given duration.
void SetServerUnavailableFor(base::TimeDelta retry_after);
// Returns true if a Preview should not be triggered because the server is
// unavailable.
bool IsServerUnavailable();
// Informs that the given URL should be bypassed one time.
void AddSingleBypass(std::string url);
// Queries if the given URL should be bypassed one time, returning true if
// yes.
bool CheckSingleBypass(std::string url);
// Generates a new page id for a request to the previews server.
uint64_t GeneratePageID();
// Reports data savings to Data Saver. Only the difference in |original_bytes|
// and |network_bytes| will be updated in the data saver calls.
void ReportDataSavings(int64_t network_bytes,
int64_t original_bytes,
const std::string& host) override;
void BlacklistBypassedHost(const std::string& host,
base::TimeDelta duration) override;
bool HostBlacklistedFromBypass(const std::string& host) override;
bool IsServerReachableByProbe() override;
bool IsServerProbeResultAvailable() override;
const std::string& host);
// Blacklists the given |host| for the given |duration| in the server
// bypass blacklist for LitePageRedirects.
void BlacklistBypassedHost(const std::string& host, base::TimeDelta duration);
// Returns true if the given |host| is blacklisted in the server bypass
// blacklist.
bool HostBlacklistedFromBypass(const std::string& host);
// Returns true if the Preview server is reachable on the network according to
// a network probe. This will return the result of the most recent probe,
// either from this session or a previous cached session's.
bool IsServerReachableByProbe();
// Returns true if a Preview server probe has completed for the current
// network ID. This is session-agnostic because cached values from previous
// sessions will be used if they exist for the current network ID.
bool IsServerProbeResultAvailable();
// data_reduction_proxy::DataReductionProxySettingsObserver:
void OnProxyRequestHeadersChanged(
......
......@@ -105,7 +105,7 @@ GURL PreviewsLitePageNavigationThrottle::GetPreviewsURLForURL(
previews::PreviewsUserData::ServerLitePageInfo*
PreviewsLitePageNavigationThrottle::GetOrCreateServerLitePageInfo(
content::NavigationHandle* navigation_handle,
PreviewsLitePageNavigationThrottleManager* manager) {
PreviewsLitePageDecider* decider) {
PreviewsUITabHelper* ui_tab_helper =
PreviewsUITabHelper::FromWebContents(navigation_handle->GetWebContents());
if (!ui_tab_helper)
......@@ -146,7 +146,7 @@ PreviewsLitePageNavigationThrottle::GetOrCreateServerLitePageInfo(
// The page id may not be set in some corner cases (like forward navigation),
// so make sure it gets set here.
if (info->page_id == 0U)
info->page_id = manager->GeneratePageID();
info->page_id = decider->GeneratePageID();
return info;
}
......@@ -13,7 +13,7 @@ namespace content {
class BrowserContext;
} // namespace content
class PreviewsLitePageNavigationThrottleManager;
class PreviewsLitePageDecider;
// If the given URL is a LitePage Preview URL, this returns true but does not
// change the |url|. This will set |update_virtual_url_with_url| on
......@@ -41,9 +41,8 @@ class PreviewsLitePageNavigationThrottle {
// initialized with metadata from navigation_handle() and |this| that is owned
// by the PreviewsUserData associated with navigation_handle().
static previews::PreviewsUserData::ServerLitePageInfo*
GetOrCreateServerLitePageInfo(
content::NavigationHandle* navigation_handle,
PreviewsLitePageNavigationThrottleManager* manager);
GetOrCreateServerLitePageInfo(content::NavigationHandle* navigation_handle,
PreviewsLitePageDecider* manager);
DISALLOW_COPY_AND_ASSIGN(PreviewsLitePageNavigationThrottle);
};
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_PREVIEWS_PREVIEWS_LITE_PAGE_NAVIGATION_THROTTLE_MANAGER_H_
#define CHROME_BROWSER_PREVIEWS_PREVIEWS_LITE_PAGE_NAVIGATION_THROTTLE_MANAGER_H_
#include <stdint.h>
#include "base/time/time.h"
// This interface specifies the interaction that a
// |PreviewsLitePageNavigationThrottle| has with it's state manager. This class
// tracks the state of the Navigation Throttle since a single instance of the
// navigation throttle can be very short lived, and therefore is not aware of
// any actions taken by its predecessor.
class PreviewsLitePageNavigationThrottleManager {
public:
// Used to notify that the Previews Server should not be sent anymore requests
// until after the given duration.
virtual void SetServerUnavailableFor(base::TimeDelta retry_after) = 0;
// Returns true if a Preview should not be triggered because the server is
// unavailable.
virtual bool IsServerUnavailable() = 0;
// Returns true if a Preview server probe has completed for the current
// network ID. This is session-agnostic because cached values from previous
// sessions will be used if they exist for the current network ID.
virtual bool IsServerProbeResultAvailable() = 0;
// Returns true if the Preview server is reachable on the network according to
// a network probe. This will return the result of the most recent probe,
// either from this session or a previous cached session's.
virtual bool IsServerReachableByProbe() = 0;
// Informs the manager that the given URL should be bypassed one time.
virtual void AddSingleBypass(std::string url) = 0;
// Queries the manager if the given URL should be bypassed one time, returning
// true if yes.
virtual bool CheckSingleBypass(std::string url) = 0;
// Generates a new page id for a request to the previews server.
virtual uint64_t GeneratePageID() = 0;
// Reports data savings to Data Saver. Only the difference in |original_bytes|
// and |network_bytes| will be updated in the data saver calls.
virtual void ReportDataSavings(int64_t network_bytes,
int64_t original_bytes,
const std::string& host) = 0;
// Blacklists the given |host| for the given |duration| in the server
// bypass blacklist for LitePageRedirects.
virtual void BlacklistBypassedHost(const std::string& host,
base::TimeDelta duration) = 0;
// Returns true if the given |host| is blacklisted in the server bypass
// blacklist.
virtual bool HostBlacklistedFromBypass(const std::string& host) = 0;
};
#endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_LITE_PAGE_NAVIGATION_THROTTLE_MANAGER_H_
......@@ -21,7 +21,6 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "chrome/browser/previews/previews_lite_page_decider.h"
#include "chrome/browser/previews/previews_lite_page_navigation_throttle_manager.h"
#include "chrome/browser/previews/previews_lite_page_url_loader_interceptor.h"
#include "chrome/browser/previews/previews_service.h"
#include "chrome/browser/previews/previews_service_factory.h"
......
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