| 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/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.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 | 15 |
| 15 class AppCacheJob; | 16 class AppCacheJob; |
| 16 class AppCacheServiceImpl; | 17 class AppCacheServiceImpl; |
| 17 class URLLoaderFactoryGetter; | 18 class URLLoaderFactoryGetter; |
| 18 | 19 |
| 19 // Implements the URLLoaderFactory mojom for AppCache requests. | 20 // Implements the URLLoaderFactory mojom for AppCache requests. |
| 20 class AppCacheURLLoaderFactory : public mojom::URLLoaderFactory { | 21 class AppCacheURLLoaderFactory : public mojom::URLLoaderFactory { |
| 21 public: | 22 public: |
| 22 ~AppCacheURLLoaderFactory() override; | 23 ~AppCacheURLLoaderFactory() override; |
| 23 | 24 |
| 24 // Factory function to create an instance of the factory. | 25 // Factory function to create an instance of the factory. |
| 25 // 1. The |factory_getter| parameter is used to query the network service | 26 // 1. The |factory_getter| parameter is used to query the network service |
| 26 // to pass network requests to. | 27 // to pass network requests to. |
| 27 // Returns a URLLoaderFactoryPtr instance which controls the lifetime of the | 28 // Returns a URLLoaderFactoryPtr instance which controls the lifetime of the |
| 28 // factory. | 29 // factory. |
| 29 static mojom::URLLoaderFactoryPtr CreateURLLoaderFactory( | 30 static mojom::URLLoaderFactoryPtr CreateURLLoaderFactory( |
| 30 URLLoaderFactoryGetter* factory_getter); | 31 URLLoaderFactoryGetter* factory_getter); |
| 31 | 32 |
| 32 // mojom::URLLoaderFactory implementation. | 33 // mojom::URLLoaderFactory implementation. |
| 33 void CreateLoaderAndStart( | 34 void CreateLoaderAndStart( |
| 34 mojom::URLLoaderAssociatedRequest url_loader_request, | 35 mojom::URLLoaderAssociatedRequest url_loader_request, |
| 35 int32_t routing_id, | 36 int32_t routing_id, |
| 36 int32_t request_id, | 37 int32_t request_id, |
| 37 uint32_t options, | 38 uint32_t options, |
| 38 const ResourceRequest& request, | 39 const ResourceRequest& request, |
| 39 mojom::URLLoaderClientPtr client) override; | 40 mojom::URLLoaderClientPtr client, |
| 41 const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) |
| 42 override; |
| 40 void SyncLoad(int32_t routing_id, | 43 void SyncLoad(int32_t routing_id, |
| 41 int32_t request_id, | 44 int32_t request_id, |
| 42 const ResourceRequest& request, | 45 const ResourceRequest& request, |
| 43 SyncLoadCallback callback) override; | 46 SyncLoadCallback callback) override; |
| 44 | 47 |
| 45 private: | 48 private: |
| 46 AppCacheURLLoaderFactory(mojom::URLLoaderFactoryRequest request, | 49 AppCacheURLLoaderFactory(mojom::URLLoaderFactoryRequest request, |
| 47 URLLoaderFactoryGetter* factory_getter); | 50 URLLoaderFactoryGetter* factory_getter); |
| 48 | 51 |
| 49 void OnConnectionError(); | 52 void OnConnectionError(); |
| 50 | 53 |
| 51 // Mojo binding. | 54 // Mojo binding. |
| 52 mojo::Binding<mojom::URLLoaderFactory> binding_; | 55 mojo::Binding<mojom::URLLoaderFactory> binding_; |
| 53 | 56 |
| 54 // Used to retrieve the network service factory to pass unhandled requests to | 57 // Used to retrieve the network service factory to pass unhandled requests to |
| 55 // the network service. | 58 // the network service. |
| 56 scoped_refptr<URLLoaderFactoryGetter> factory_getter_; | 59 scoped_refptr<URLLoaderFactoryGetter> factory_getter_; |
| 57 | 60 |
| 58 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderFactory); | 61 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderFactory); |
| 59 }; | 62 }; |
| 60 | 63 |
| 61 } // namespace content | 64 } // namespace content |
| 62 | 65 |
| 63 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ | 66 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ |
| OLD | NEW |