Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1805)

Unified Diff: chrome/browser/android/offline_pages/offline_page_request_interceptor.h

Issue 2245733004: Serve offline page for online URL on disconnected or bad networks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix junit test Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/offline_pages/offline_page_request_interceptor.h
diff --git a/chrome/browser/android/offline_pages/offline_page_request_interceptor.h b/chrome/browser/android/offline_pages/offline_page_request_interceptor.h
new file mode 100644
index 0000000000000000000000000000000000000000..8d0f18e9f1bd5cfefa524bfe2e67c7b4d6d3e3e0
--- /dev/null
+++ b/chrome/browser/android/offline_pages/offline_page_request_interceptor.h
@@ -0,0 +1,42 @@
+// 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_INTERCEPTOR_H_
+#define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_INTERCEPTOR_H_
+
+#include "base/macros.h"
+#include "net/url_request/url_request_interceptor.h"
+
+namespace net {
+class NetworkDelegate;
+class URLRequest;
+class URLRequestJob;
+}
+
+namespace offline_pages {
+
+// An interceptor to hijack requests and potentially service them based on
+// their offline information. Created one per profile.
+class OfflinePageRequestInterceptor : public net::URLRequestInterceptor {
+ public:
+ // |profile_id|, which identifies the profile, is passed as a void* to ensure
+ // it's not accidently used on the IO thread.
+ explicit OfflinePageRequestInterceptor(void* profile_id);
+ ~OfflinePageRequestInterceptor() override;
+
+ private:
+ // Overrides from net::URLRequestInterceptor:
+ net::URLRequestJob* MaybeInterceptRequest(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const override;
+
+ // The profile for processing offline pages.
+ void* const profile_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(OfflinePageRequestInterceptor);
+};
+
+} // namespace offline_pages
+
+#endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_INTERCEPTOR_H_

Powered by Google App Engine
This is Rietveld 408576698