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