chromium/components/error_page/content/browser/net_error_auto_reloader.h

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_ERROR_PAGE_CONTENT_BROWSER_NET_ERROR_AUTO_RELOADER_H_
#define COMPONENTS_ERROR_PAGE_CONTENT_BROWSER_NET_ERROR_AUTO_RELOADER_H_

#include <stddef.h>

#include <memory>
#include <optional>
#include <set>

#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "net/base/net_errors.h"
#include "services/network/public/cpp/network_connection_tracker.h"
#include "services/network/public/mojom/network_change_manager.mojom.h"
#include "url/gurl.h"

namespace content {
class NavigationHandle;
class NavigationThrottle;
class WebContents;
}  // namespace content

namespace error_page {

// This class implements support for automatic reload attempts with backoff
// whenever a WebContents' main frame lands on common network error pages. This
// excludes errors that aren't connectivity related since a reload doesn't
// generally fix them (e.g. SSL errors or when the client blocked the request).
// To use this behavior as a Content embedder, simply call the static
// `MaybeCreateNavigationThrottle()` method from within your implementation of
// ContentBrowserClient::CreateThrottlesForNavigation.
class NetErrorAutoReloader
    : public content::WebContentsObserver,
      public content::WebContentsUserData<NetErrorAutoReloader>,
      public network::NetworkConnectionTracker::NetworkConnectionObserver {};

}  // namespace error_page

#endif  // COMPONENTS_ERROR_PAGE_CONTENT_BROWSER_NET_ERROR_AUTO_RELOADER_H_