OLD | NEW |
(Empty) | |
| 1 // Copyright 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_URL_LOADER_FACTORY_H_ |
| 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "content/common/content_export.h" |
| 10 #include "content/common/url_loader_factory.mojom.h" |
| 11 #include "mojo/public/cpp/bindings/strong_binding_set.h" |
| 12 #include "url/gurl.h" |
| 13 |
| 14 namespace content { |
| 15 class ChromeAppCacheService; |
| 16 class URLLoaderFactoryGetter; |
| 17 |
| 18 // Implements the URLLoaderFactory mojom for AppCache requests. |
| 19 class CONTENT_EXPORT AppCacheURLLoaderFactory : public mojom::URLLoaderFactory { |
| 20 public: |
| 21 ~AppCacheURLLoaderFactory() override; |
| 22 |
| 23 // Factory function to create an instance of the factory. |
| 24 // The |appcache_service| parameter is used to query the underlying |
| 25 // AppCacheStorage instance to check if we can service requests from the |
| 26 // AppCache. We pass unhandled requests to the network service retrieved from |
| 27 // the |factory_getter|. |
| 28 static void CreateURLLoaderFactory(mojom::URLLoaderFactoryRequest request, |
| 29 ChromeAppCacheService* appcache_service, |
| 30 URLLoaderFactoryGetter* factory_getter); |
| 31 |
| 32 // mojom::URLLoaderFactory implementation. |
| 33 void CreateLoaderAndStart( |
| 34 mojom::URLLoaderAssociatedRequest url_loader_request, |
| 35 int32_t routing_id, |
| 36 int32_t request_id, |
| 37 uint32_t options, |
| 38 const ResourceRequest& request, |
| 39 mojom::URLLoaderClientPtr client) override; |
| 40 void SyncLoad(int32_t routing_id, |
| 41 int32_t request_id, |
| 42 const ResourceRequest& request, |
| 43 SyncLoadCallback callback) override; |
| 44 |
| 45 private: |
| 46 AppCacheURLLoaderFactory(ChromeAppCacheService* appcache_service, |
| 47 URLLoaderFactoryGetter* factory_getter); |
| 48 |
| 49 // Used to query AppCacheStorage to see if a request can be served out of the |
| 50 /// AppCache. |
| 51 scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 52 |
| 53 // Used to retrieve the network service factory to pass unhandled requests to |
| 54 // the network service. |
| 55 scoped_refptr<URLLoaderFactoryGetter> factory_getter_; |
| 56 |
| 57 mojo::StrongBindingSet<mojom::URLLoaderFactory> loader_factory_bindings_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderFactory); |
| 60 }; |
| 61 |
| 62 } // namespace content |
| 63 |
| 64 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ |
OLD | NEW |