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 "content/common/url_loader_factory.mojom.h" | 10 #include "content/common/url_loader_factory.mojom.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
11 #include "net/traffic_annotation/network_traffic_annotation.h" | 12 #include "net/traffic_annotation/network_traffic_annotation.h" |
12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
17 class AppCacheHost; | |
16 class AppCacheJob; | 18 class AppCacheJob; |
17 class AppCacheServiceImpl; | 19 class AppCacheServiceImpl; |
18 class URLLoaderFactoryGetter; | 20 class URLLoaderFactoryGetter; |
19 | 21 |
22 // Holds information about the subresource load request like the routing id, | |
23 // request id, the client pointer, etc. | |
24 struct SubresourceLoadInfo { | |
jam
2017/06/30 01:31:15
nit: why is this in this header if it's not refere
ananta
2017/06/30 01:39:06
It is populated in the factory cc file. I thought
ananta
2017/06/30 01:53:42
I moved it to the appcache_url_loader_job.h/.cc fi
| |
25 SubresourceLoadInfo(); | |
26 ~SubresourceLoadInfo(); | |
27 | |
28 mojom::URLLoaderAssociatedRequest url_loader_request; | |
29 int32_t routing_id; | |
30 int32_t request_id; | |
31 uint32_t options; | |
32 ResourceRequest request; | |
33 mojom::URLLoaderClientPtr client; | |
34 net::MutableNetworkTrafficAnnotationTag traffic_annotation; | |
35 }; | |
36 | |
20 // Implements the URLLoaderFactory mojom for AppCache subresource requests. | 37 // Implements the URLLoaderFactory mojom for AppCache subresource requests. |
21 class AppCacheSubresourceURLFactory : public mojom::URLLoaderFactory { | 38 class AppCacheSubresourceURLFactory : public mojom::URLLoaderFactory { |
22 public: | 39 public: |
23 ~AppCacheSubresourceURLFactory() override; | 40 ~AppCacheSubresourceURLFactory() override; |
24 | 41 |
25 // Factory function to create an instance of the factory. | 42 // Factory function to create an instance of the factory. |
26 // 1. The |factory_getter| parameter is used to query the network service | 43 // 1. The |factory_getter| parameter is used to query the network service |
27 // to pass network requests to. | 44 // to pass network requests to. |
45 // 2. The |frame_tree_node_id| parameter contains the FrameTreeNodeId for the | |
46 // frame. | |
47 // Returns the AppCacheSubresourceURLFactory instance. The URLLoaderFactoryPtr | |
48 // is returned in the |loader_factory| parameter. | |
28 // Returns a URLLoaderFactoryPtr instance which controls the lifetime of the | 49 // Returns a URLLoaderFactoryPtr instance which controls the lifetime of the |
29 // factory. | 50 // factory. |
30 static mojom::URLLoaderFactoryPtr CreateURLLoaderFactory( | 51 static AppCacheSubresourceURLFactory* CreateURLLoaderFactory( |
31 URLLoaderFactoryGetter* factory_getter); | 52 URLLoaderFactoryGetter* factory_getter, |
53 base::WeakPtr<AppCacheHost> host, | |
54 mojom::URLLoaderFactoryPtr* loader_factory); | |
32 | 55 |
33 // mojom::URLLoaderFactory implementation. | 56 // mojom::URLLoaderFactory implementation. |
34 void CreateLoaderAndStart( | 57 void CreateLoaderAndStart( |
35 mojom::URLLoaderAssociatedRequest url_loader_request, | 58 mojom::URLLoaderAssociatedRequest url_loader_request, |
36 int32_t routing_id, | 59 int32_t routing_id, |
37 int32_t request_id, | 60 int32_t request_id, |
38 uint32_t options, | 61 uint32_t options, |
39 const ResourceRequest& request, | 62 const ResourceRequest& request, |
40 mojom::URLLoaderClientPtr client, | 63 mojom::URLLoaderClientPtr client, |
41 const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) | 64 const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) |
42 override; | 65 override; |
43 void SyncLoad(int32_t routing_id, | 66 void SyncLoad(int32_t routing_id, |
44 int32_t request_id, | 67 int32_t request_id, |
45 const ResourceRequest& request, | 68 const ResourceRequest& request, |
46 SyncLoadCallback callback) override; | 69 SyncLoadCallback callback) override; |
47 | 70 |
48 private: | 71 private: |
49 AppCacheSubresourceURLFactory(mojom::URLLoaderFactoryRequest request, | 72 AppCacheSubresourceURLFactory(mojom::URLLoaderFactoryRequest request, |
50 URLLoaderFactoryGetter* factory_getter); | 73 URLLoaderFactoryGetter* factory_getter, |
74 base::WeakPtr<AppCacheHost> host); | |
51 | 75 |
52 void OnConnectionError(); | 76 void OnConnectionError(); |
53 | 77 |
54 // Mojo binding. | 78 // Mojo binding. |
55 mojo::Binding<mojom::URLLoaderFactory> binding_; | 79 mojo::Binding<mojom::URLLoaderFactory> binding_; |
56 | 80 |
57 // Used to retrieve the network service factory to pass unhandled requests to | 81 // Used to retrieve the network service factory to pass unhandled requests to |
58 // the network service. | 82 // the network service. |
59 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_; | 83 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_; |
60 | 84 |
85 base::WeakPtr<AppCacheHost> appcache_host_; | |
86 | |
61 DISALLOW_COPY_AND_ASSIGN(AppCacheSubresourceURLFactory); | 87 DISALLOW_COPY_AND_ASSIGN(AppCacheSubresourceURLFactory); |
62 }; | 88 }; |
63 | 89 |
64 } // namespace content | 90 } // namespace content |
65 | 91 |
66 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ | 92 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ |
OLD | NEW |