OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_NETWORK_SERVICE_HANDLER_ | |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_NETWORK_SERVICE_HANDLER_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "content/browser/appcache/appcache_service_impl.h" | |
12 #include "content/browser/appcache/appcache_storage.h" | |
13 #include "content/common/content_export.h" | |
14 #include "content/common/url_loader_factory.mojom.h" | |
15 #include "content/public/common/resource_type.h" | |
16 | |
17 namespace content { | |
18 class AppCacheEntry; | |
19 class AppCacheHost; | |
20 class AppCacheNavigationHandleCore; | |
21 class AppCacheStorage; | |
22 class ResourceContext; | |
23 struct ResourceRequest; | |
24 | |
25 // This class is instantiated during navigation, to check if the URL being | |
26 // navigated to can be served out of the AppCache. | |
27 // The AppCacheRequestHandler class provides this functionality as well. | |
28 // However it is tightly coupled with the underlying job and the lifetime | |
29 // 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
| |
30 // generally associated with a request and it dies when the request goes away. | |
31 // For this case, we are just checking if the URL can be served out of the | |
32 // cache. If yes, then the plan is to create a URLLoaderFactory which can serve | |
33 // URL requests from the cache. | |
34 // TODO(ananta) | |
35 // Look into whether we can get rid of this class when the overall picture of | |
36 // how AppCache interacts with the network service gets clearer. | |
37 class CONTENT_EXPORT AppCacheNetworkServiceHandler | |
38 : public AppCacheStorage::Delegate { | |
39 public: | |
40 AppCacheNetworkServiceHandler( | |
41 std::unique_ptr<ResourceRequest> resource_request, | |
42 ResourceContext* resource_context, | |
43 AppCacheNavigationHandleCore* navigation_handle_core, | |
44 ResourceType resource_type, | |
45 base::Callback<void(mojom::URLLoaderFactoryPtrInfo, | |
46 std::unique_ptr<ResourceRequest>)> callback); | |
47 | |
48 ~AppCacheNetworkServiceHandler(); | |
49 | |
50 // Called to start the process of looking up the URL in the AppCache | |
51 // database, | |
52 void Start(); | |
53 | |
54 // AppCacheStorage::Delegate methods | |
55 // The AppCacheNetworkServiceHandler instance is deleted on return from this | |
56 // function. | |
57 void OnMainResponseFound(const GURL& url, | |
58 const AppCacheEntry& entry, | |
59 const GURL& fallback_url, | |
60 const AppCacheEntry& fallback_entry, | |
61 int64_t cache_id, | |
62 int64_t group_id, | |
63 const GURL& mainfest_url) override; | |
64 | |
65 private: | |
66 std::unique_ptr<ResourceRequest> resource_request_; | |
67 ResourceContext* resource_context_; | |
68 ResourceType resource_type_; | |
69 | |
70 // Callback to invoke when we make a determination on whether the request is | |
71 // to be served from the cache or network. | |
72 base::Callback<void(mojom::URLLoaderFactoryPtrInfo, | |
73 std::unique_ptr<ResourceRequest>)> callback_; | |
74 | |
75 AppCacheStorage* storage_; | |
76 | |
77 // The precreated host pointer from the AppCacheNavigationHandleCore class. | |
78 // The ownership of this pointer stays with the AppCacheNavigationHandleCore | |
79 // class. | |
80 AppCacheHost* host_; | |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(AppCacheNetworkServiceHandler); | |
83 }; | |
84 | |
85 } // namespace content | |
86 | |
87 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_NETWORK_SERVICE_HANDLER_ | |
OLD | NEW |