| Index: chrome/browser/android/offline_pages/offline_page_request_redirect_job.h
|
| diff --git a/chrome/browser/android/offline_pages/offline_page_request_redirect_job.h b/chrome/browser/android/offline_pages/offline_page_request_redirect_job.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ad393decb7ea2ec3eb11ba8c52e154a2503b4b7a
|
| --- /dev/null
|
| +++ b/chrome/browser/android/offline_pages/offline_page_request_redirect_job.h
|
| @@ -0,0 +1,62 @@
|
| +// 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_REDIRECT_JOB_H_
|
| +#define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_REDIRECT_JOB_H_
|
| +
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "net/url_request/url_request_job.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace offline_pages {
|
| +
|
| +// A request job that handles the redirection between online URL and offline
|
| +// URL when the offline copy exists.
|
| +class OfflinePageRequestRedirectJob : public net::URLRequestJob {
|
| + public:
|
| + class Delegate {
|
| + public:
|
| + virtual ~Delegate() {}
|
| +
|
| + // Will be invoked before the request is restarted. The caller can use this
|
| + // opportunity to set a sepcific state in order to prevent the request from
|
| + // being intercepted.
|
| + virtual void OnPrepareToRestart() = 0;
|
| + };
|
| +
|
| + OfflinePageRequestRedirectJob(net::URLRequest* request,
|
| + net::NetworkDelegate* network_delegate,
|
| + Delegate* delegate);
|
| + ~OfflinePageRequestRedirectJob() override;
|
| +
|
| + // net::URLRequestJob overrides:
|
| + void Start() override;
|
| + void Kill() override;
|
| + bool IsRedirectResponse(GURL* location, int* http_status_code) override;
|
| +
|
| + base::WeakPtr<OfflinePageRequestRedirectJob> GetWeakPtr();
|
| + void FallbackToDefault();
|
| + void SetRedirectURL(const GURL& url);
|
| +
|
| + private:
|
| + enum class State {
|
| + NOT_DETERMINED,
|
| + FALLBACK_TO_DEFAULT,
|
| + DO_REDIRECT
|
| + };
|
| +
|
| + void MaybeStartRequest();
|
| +
|
| + Delegate* delegate_; // Not owned.
|
| + bool is_started_;
|
| + State state_;
|
| + GURL redirect_url_;
|
| + base::WeakPtrFactory<OfflinePageRequestRedirectJob> weak_ptr_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(OfflinePageRequestRedirectJob);
|
| +};
|
| +
|
| +} // namespace offline_pages
|
| +
|
| +#endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_REDIRECT_JOB_H_
|
|
|