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_SUBRESOURCE_URL_FACTORY_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_SUBRESOURCE_URL_FACTORY_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_SUBRESOURCE_URL_FACTORY_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_SUBRESOURCE_URL_FACTORY_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "content/common/content_export.h" | |
11 #include "content/public/common/url_loader_factory.mojom.h" | 10 #include "content/public/common/url_loader_factory.mojom.h" |
12 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
13 #include "net/traffic_annotation/network_traffic_annotation.h" | 12 #include "net/traffic_annotation/network_traffic_annotation.h" |
14 #include "url/gurl.h" | 13 #include "url/gurl.h" |
15 | 14 |
16 namespace content { | 15 namespace content { |
17 | 16 |
18 class AppCacheHost; | 17 class AppCacheHost; |
19 class AppCacheJob; | 18 class AppCacheJob; |
20 class AppCacheServiceImpl; | 19 class AppCacheServiceImpl; |
21 class URLLoaderFactoryGetter; | 20 class URLLoaderFactoryGetter; |
22 | 21 |
23 // Implements the URLLoaderFactory mojom for AppCache subresource requests. | 22 // Implements the URLLoaderFactory mojom for AppCache subresource requests. |
24 class CONTENT_EXPORT AppCacheSubresourceURLFactory | 23 class AppCacheSubresourceURLFactory : public mojom::URLLoaderFactory { |
25 : public mojom::URLLoaderFactory { | |
26 public: | 24 public: |
27 ~AppCacheSubresourceURLFactory() override; | 25 ~AppCacheSubresourceURLFactory() override; |
28 | 26 |
29 // Factory function to create an instance of the factory. | 27 // Factory function to create an instance of the factory. |
30 // 1. The |factory_getter| parameter is used to query the network service | 28 // 1. The |factory_getter| parameter is used to query the network service |
31 // to pass network requests to. | 29 // to pass network requests to. |
32 // 2. The |host| parameter contains the appcache host instance. This is used | 30 // 2. The |host| parameter contains the appcache host instance. This is used |
33 // to create the AppCacheRequestHandler instances for handling subresource | 31 // to create the AppCacheRequestHandler instances for handling subresource |
34 // requests. | 32 // requests. |
35 // Returns the AppCacheSubresourceURLFactory instance. The URLLoaderFactoryPtr | 33 // Returns the AppCacheSubresourceURLFactory instance. The URLLoaderFactoryPtr |
(...skipping 12 matching lines...) Expand all Loading... |
48 const ResourceRequest& request, | 46 const ResourceRequest& request, |
49 mojom::URLLoaderClientPtr client, | 47 mojom::URLLoaderClientPtr client, |
50 const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) | 48 const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) |
51 override; | 49 override; |
52 void SyncLoad(int32_t routing_id, | 50 void SyncLoad(int32_t routing_id, |
53 int32_t request_id, | 51 int32_t request_id, |
54 const ResourceRequest& request, | 52 const ResourceRequest& request, |
55 SyncLoadCallback callback) override; | 53 SyncLoadCallback callback) override; |
56 | 54 |
57 private: | 55 private: |
58 friend class AppCacheNetworkServiceBrowserTest; | |
59 | |
60 AppCacheSubresourceURLFactory(mojom::URLLoaderFactoryRequest request, | 56 AppCacheSubresourceURLFactory(mojom::URLLoaderFactoryRequest request, |
61 URLLoaderFactoryGetter* factory_getter, | 57 URLLoaderFactoryGetter* factory_getter, |
62 base::WeakPtr<AppCacheHost> host); | 58 base::WeakPtr<AppCacheHost> host); |
63 | 59 |
64 void OnConnectionError(); | 60 void OnConnectionError(); |
65 | 61 |
66 // Notifies the |client| if there is a failure. The |error_code| contains the | |
67 // actual error. | |
68 void NotifyError(mojom::URLLoaderClientPtr client, int error_code); | |
69 | |
70 // Mojo binding. | 62 // Mojo binding. |
71 mojo::Binding<mojom::URLLoaderFactory> binding_; | 63 mojo::Binding<mojom::URLLoaderFactory> binding_; |
72 | 64 |
73 // Used to retrieve the network service factory to pass unhandled requests to | 65 // Used to retrieve the network service factory to pass unhandled requests to |
74 // the network service. | 66 // the network service. |
75 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_; | 67 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_; |
76 | 68 |
77 base::WeakPtr<AppCacheHost> appcache_host_; | 69 base::WeakPtr<AppCacheHost> appcache_host_; |
78 | 70 |
79 DISALLOW_COPY_AND_ASSIGN(AppCacheSubresourceURLFactory); | 71 DISALLOW_COPY_AND_ASSIGN(AppCacheSubresourceURLFactory); |
80 }; | 72 }; |
81 | 73 |
82 } // namespace content | 74 } // namespace content |
83 | 75 |
84 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ | 76 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ |
OLD | NEW |