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

Unified Diff: content/browser/appcache/appcache_network_service_handler.h

Issue 2874663004: Provide skeleton functionality for AppCache handling in the network service. (Closed)
Patch Set: Created 3 years, 7 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: content/browser/appcache/appcache_network_service_handler.h
diff --git a/content/browser/appcache/appcache_network_service_handler.h b/content/browser/appcache/appcache_network_service_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..98ddd7f63cc87ffa5b8ad4b24bec22db238604f8
--- /dev/null
+++ b/content/browser/appcache/appcache_network_service_handler.h
@@ -0,0 +1,87 @@
+// Copyright (c) 2017 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 CONTENT_BROWSER_APPCACHE_APPCACHE_NETWORK_SERVICE_HANDLER_
+#define CONTENT_BROWSER_APPCACHE_APPCACHE_NETWORK_SERVICE_HANDLER_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "content/browser/appcache/appcache_service_impl.h"
+#include "content/browser/appcache/appcache_storage.h"
+#include "content/common/content_export.h"
+#include "content/common/url_loader_factory.mojom.h"
+#include "content/public/common/resource_type.h"
+
+namespace content {
+class AppCacheEntry;
+class AppCacheHost;
+class AppCacheNavigationHandleCore;
+class AppCacheStorage;
+class ResourceContext;
+struct ResourceRequest;
+
+// This class is instantiated during navigation, to check if the URL being
+// navigated to can be served out of the AppCache.
+// The AppCacheRequestHandler class provides this functionality as well.
+// However it is tightly coupled with the underlying job and the lifetime
+// of that class gets a touch complicated. The AppCacheRequestHandler is
kinuko 2017/05/11 02:14:14 I'm not yet sure how this class and request_handle
ananta 2017/05/11 02:30:24 We are going to reuse the request handler code whe
ananta 2017/05/11 02:32:00 To clarify when a request is served out of the App
+// generally associated with a request and it dies when the request goes away.
+// For this case, we are just checking if the URL can be served out of the
+// cache. If yes, then the plan is to create a URLLoaderFactory which can serve
+// URL requests from the cache.
+// TODO(ananta)
+// Look into whether we can get rid of this class when the overall picture of
+// how AppCache interacts with the network service gets clearer.
+class CONTENT_EXPORT AppCacheNetworkServiceHandler
+ : public AppCacheStorage::Delegate {
+ public:
+ AppCacheNetworkServiceHandler(
+ std::unique_ptr<ResourceRequest> resource_request,
+ ResourceContext* resource_context,
+ AppCacheNavigationHandleCore* navigation_handle_core,
+ ResourceType resource_type,
+ base::Callback<void(mojom::URLLoaderFactoryPtrInfo,
+ std::unique_ptr<ResourceRequest>)> callback);
+
+ ~AppCacheNetworkServiceHandler();
+
+ // Called to start the process of looking up the URL in the AppCache
+ // database,
+ void Start();
+
+ // AppCacheStorage::Delegate methods
+ // The AppCacheNetworkServiceHandler instance is deleted on return from this
+ // function.
+ void OnMainResponseFound(const GURL& url,
+ const AppCacheEntry& entry,
+ const GURL& fallback_url,
+ const AppCacheEntry& fallback_entry,
+ int64_t cache_id,
+ int64_t group_id,
+ const GURL& mainfest_url) override;
+
+ private:
+ std::unique_ptr<ResourceRequest> resource_request_;
+ ResourceContext* resource_context_;
+ ResourceType resource_type_;
+
+ // Callback to invoke when we make a determination on whether the request is
+ // to be served from the cache or network.
+ base::Callback<void(mojom::URLLoaderFactoryPtrInfo,
+ std::unique_ptr<ResourceRequest>)> callback_;
+
+ AppCacheStorage* storage_;
+
+ // The precreated host pointer from the AppCacheNavigationHandleCore class.
+ // The ownership of this pointer stays with the AppCacheNavigationHandleCore
+ // class.
+ AppCacheHost* host_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppCacheNetworkServiceHandler);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_APPCACHE_APPCACHE_NETWORK_SERVICE_HANDLER_

Powered by Google App Engine
This is Rietveld 408576698