| Index: chrome/browser/android/offline_pages/offline_page_request_handler.h
|
| diff --git a/chrome/browser/android/offline_pages/offline_page_request_handler.h b/chrome/browser/android/offline_pages/offline_page_request_handler.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d171dcfd1f79772a05404f8b5b6c512f40ff080d
|
| --- /dev/null
|
| +++ b/chrome/browser/android/offline_pages/offline_page_request_handler.h
|
| @@ -0,0 +1,69 @@
|
| +// Copyright 2016 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_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_HANDLER_H_
|
| +#define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_HANDLER_H_
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/supports_user_data.h"
|
| +#include "chrome/browser/android/offline_pages/offline_page_request_redirect_job.h"
|
| +#include "content/public/common/resource_type.h"
|
| +
|
| +namespace net {
|
| +class NetworkDelegate;
|
| +class URLRequest;
|
| +class URLRequestInterceptor;
|
| +}
|
| +
|
| +namespace offline_pages {
|
| +
|
| +// Class for servicing requests based on their offline information. Created one
|
| +// per URLRequest and attached to each request.
|
| +class OfflinePageRequestHandler :
|
| + public base::SupportsUserData::Data,
|
| + public OfflinePageRequestRedirectJob::Delegate {
|
| + public:
|
| + // Attaches a newly created handler if the given |request| needs to
|
| + // be handled by offline pages.
|
| + static void InitializeHandler(net::URLRequest* request,
|
| + content::ResourceType resource_type);
|
| +
|
| + // Returns the handler attached to |request|. This may return null
|
| + // if no handler is attached.
|
| + static OfflinePageRequestHandler* GetHandler(net::URLRequest* request);
|
| +
|
| + // Creates a protocol interceptor for offline pages.
|
| + static std::unique_ptr<net::URLRequestInterceptor> CreateInterceptor(
|
| + void* profile_id);
|
| +
|
| + ~OfflinePageRequestHandler() override;
|
| +
|
| + // OfflinePageRequestRedirectJob::Delegate overrides:
|
| + void OnPrepareToRestart() override;
|
| +
|
| + net::URLRequestJob* MaybeCreateJob(net::URLRequest* request,
|
| + net::NetworkDelegate* network_delegate,
|
| + void* profile_id);
|
| +
|
| + private:
|
| + OfflinePageRequestHandler();
|
| +
|
| + // Invoked from UI thread.
|
| + void GetRedirectUrl(const GURL& url, void* profile_id);
|
| +
|
| + base::WeakPtr<OfflinePageRequestRedirectJob> redirect_job_;
|
| +
|
| + // True if the next time this request is started, the request should be
|
| + // serviced from the default handler.
|
| + bool use_default_ = false;
|
| +
|
| + base::WeakPtrFactory<OfflinePageRequestHandler> weak_ptr_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(OfflinePageRequestHandler);
|
| +};
|
| +
|
| +} // namespace offline_pages
|
| +
|
| +#endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_HANDLER_H_
|
|
|