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