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") { ...@@ -1378,7 +1378,6 @@ jumbo_split_static_library("browser") {
"previews/previews_lite_page_infobar_delegate.h", "previews/previews_lite_page_infobar_delegate.h",
"previews/previews_lite_page_navigation_throttle.cc", "previews/previews_lite_page_navigation_throttle.cc",
"previews/previews_lite_page_navigation_throttle.h", "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.cc",
"previews/previews_lite_page_predictor.h", "previews/previews_lite_page_predictor.h",
"previews/previews_lite_page_redirect_url_loader.cc", "previews/previews_lite_page_redirect_url_loader.cc",
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "chrome/browser/data_reduction_proxy/data_reduction_proxy_chrome_settings_factory.h" #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_decider.h"
#include "chrome/browser/previews/previews_lite_page_navigation_throttle.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_lite_page_url_loader_interceptor.h"
#include "chrome/browser/previews/previews_offline_helper.h" #include "chrome/browser/previews/previews_offline_helper.h"
#include "chrome/browser/previews/previews_service.h" #include "chrome/browser/previews/previews_service.h"
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/availability/availability_prober.h" #include "chrome/browser/availability/availability_prober.h"
#include "chrome/browser/previews/previews_https_notification_infobar_decider.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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
...@@ -35,12 +34,9 @@ namespace user_prefs { ...@@ -35,12 +34,9 @@ namespace user_prefs {
class PrefRegistrySyncable; class PrefRegistrySyncable;
} }
// This class ensures that the feature is enabled and the // This class manages the triggering logic for Lite Page Redirect previews.
// current Profile is not incognito before handing off the real legwork of the
// triggering decision to |PreviewsLitePageNavigationThrottle|.
class PreviewsLitePageDecider class PreviewsLitePageDecider
: public AvailabilityProber::Delegate, : public AvailabilityProber::Delegate,
public PreviewsLitePageNavigationThrottleManager,
public PreviewsHTTPSNotificationInfoBarDecider, public PreviewsHTTPSNotificationInfoBarDecider,
public data_reduction_proxy::DataReductionProxySettingsObserver { public data_reduction_proxy::DataReductionProxySettingsObserver {
public: public:
...@@ -78,20 +74,47 @@ class PreviewsLitePageDecider ...@@ -78,20 +74,47 @@ class PreviewsLitePageDecider
bool NeedsToNotifyUser() override; bool NeedsToNotifyUser() override;
void NotifyUser(content::WebContents* web_contents) override; void NotifyUser(content::WebContents* web_contents) override;
// PreviewsLitePageNavigationThrottleManager: // Used to notify that the Previews Server should not be sent anymore requests
void SetServerUnavailableFor(base::TimeDelta retry_after) override; // until after the given duration.
bool IsServerUnavailable() override; void SetServerUnavailableFor(base::TimeDelta retry_after);
void AddSingleBypass(std::string url) override;
bool CheckSingleBypass(std::string url) override; // Returns true if a Preview should not be triggered because the server is
uint64_t GeneratePageID() override; // 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, void ReportDataSavings(int64_t network_bytes,
int64_t original_bytes, int64_t original_bytes,
const std::string& host) override; const std::string& host);
void BlacklistBypassedHost(const std::string& host,
base::TimeDelta duration) override; // Blacklists the given |host| for the given |duration| in the server
bool HostBlacklistedFromBypass(const std::string& host) override; // bypass blacklist for LitePageRedirects.
bool IsServerReachableByProbe() override; void BlacklistBypassedHost(const std::string& host, base::TimeDelta duration);
bool IsServerProbeResultAvailable() override;
// 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: // data_reduction_proxy::DataReductionProxySettingsObserver:
void OnProxyRequestHeadersChanged( void OnProxyRequestHeadersChanged(
......
...@@ -105,7 +105,7 @@ GURL PreviewsLitePageNavigationThrottle::GetPreviewsURLForURL( ...@@ -105,7 +105,7 @@ GURL PreviewsLitePageNavigationThrottle::GetPreviewsURLForURL(
previews::PreviewsUserData::ServerLitePageInfo* previews::PreviewsUserData::ServerLitePageInfo*
PreviewsLitePageNavigationThrottle::GetOrCreateServerLitePageInfo( PreviewsLitePageNavigationThrottle::GetOrCreateServerLitePageInfo(
content::NavigationHandle* navigation_handle, content::NavigationHandle* navigation_handle,
PreviewsLitePageNavigationThrottleManager* manager) { PreviewsLitePageDecider* decider) {
PreviewsUITabHelper* ui_tab_helper = PreviewsUITabHelper* ui_tab_helper =
PreviewsUITabHelper::FromWebContents(navigation_handle->GetWebContents()); PreviewsUITabHelper::FromWebContents(navigation_handle->GetWebContents());
if (!ui_tab_helper) if (!ui_tab_helper)
...@@ -146,7 +146,7 @@ PreviewsLitePageNavigationThrottle::GetOrCreateServerLitePageInfo( ...@@ -146,7 +146,7 @@ PreviewsLitePageNavigationThrottle::GetOrCreateServerLitePageInfo(
// The page id may not be set in some corner cases (like forward navigation), // The page id may not be set in some corner cases (like forward navigation),
// so make sure it gets set here. // so make sure it gets set here.
if (info->page_id == 0U) if (info->page_id == 0U)
info->page_id = manager->GeneratePageID(); info->page_id = decider->GeneratePageID();
return info; return info;
} }
...@@ -13,7 +13,7 @@ namespace content { ...@@ -13,7 +13,7 @@ namespace content {
class BrowserContext; class BrowserContext;
} // namespace content } // namespace content
class PreviewsLitePageNavigationThrottleManager; class PreviewsLitePageDecider;
// If the given URL is a LitePage Preview URL, this returns true but does not // 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 // change the |url|. This will set |update_virtual_url_with_url| on
...@@ -41,9 +41,8 @@ class PreviewsLitePageNavigationThrottle { ...@@ -41,9 +41,8 @@ class PreviewsLitePageNavigationThrottle {
// initialized with metadata from navigation_handle() and |this| that is owned // initialized with metadata from navigation_handle() and |this| that is owned
// by the PreviewsUserData associated with navigation_handle(). // by the PreviewsUserData associated with navigation_handle().
static previews::PreviewsUserData::ServerLitePageInfo* static previews::PreviewsUserData::ServerLitePageInfo*
GetOrCreateServerLitePageInfo( GetOrCreateServerLitePageInfo(content::NavigationHandle* navigation_handle,
content::NavigationHandle* navigation_handle, PreviewsLitePageDecider* manager);
PreviewsLitePageNavigationThrottleManager* manager);
DISALLOW_COPY_AND_ASSIGN(PreviewsLitePageNavigationThrottle); 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 @@ ...@@ -21,7 +21,6 @@
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/previews/previews_lite_page_decider.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_lite_page_url_loader_interceptor.h"
#include "chrome/browser/previews/previews_service.h" #include "chrome/browser/previews/previews_service.h"
#include "chrome/browser/previews/previews_service_factory.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