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 "url/gurl.h" | 11 #include "url/gurl.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 class AppCacheHost; | |
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 { |
michaeln
2017/05/24 00:59:32
How about we make this class specific to MainResou
ananta
2017/05/24 02:14:03
This class exposes mojo methods because it impleme
| |
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|. The |renderer_process_id| parameter identfies the |
28 // renderer process id. In the browser this is -1. | |
27 static void CreateURLLoaderFactory(mojom::URLLoaderFactoryRequest request, | 29 static void CreateURLLoaderFactory(mojom::URLLoaderFactoryRequest request, |
28 ChromeAppCacheService* appcache_service, | 30 ChromeAppCacheService* appcache_service, |
29 URLLoaderFactoryGetter* factory_getter); | 31 URLLoaderFactoryGetter* factory_getter, |
32 int renderer_process_id); | |
33 | |
34 // TODO(ananta) | |
35 // Get rid of this method once we change the browser side navigation code to | |
36 // not use URLLoaderFactories. | |
37 static void SetAppCacheHost(AppCacheHost* host); | |
30 | 38 |
31 // mojom::URLLoaderFactory implementation. | 39 // mojom::URLLoaderFactory implementation. |
32 void CreateLoaderAndStart( | 40 void CreateLoaderAndStart( |
33 mojom::URLLoaderAssociatedRequest url_loader_request, | 41 mojom::URLLoaderAssociatedRequest url_loader_request, |
34 int32_t routing_id, | 42 int32_t routing_id, |
35 int32_t request_id, | 43 int32_t request_id, |
36 uint32_t options, | 44 uint32_t options, |
37 const ResourceRequest& request, | 45 const ResourceRequest& request, |
38 mojom::URLLoaderClientPtr client) override; | 46 mojom::URLLoaderClientPtr client) override; |
39 void SyncLoad(int32_t routing_id, | 47 void SyncLoad(int32_t routing_id, |
40 int32_t request_id, | 48 int32_t request_id, |
41 const ResourceRequest& request, | 49 const ResourceRequest& request, |
42 SyncLoadCallback callback) override; | 50 SyncLoadCallback callback) override; |
43 | 51 |
44 private: | 52 private: |
45 AppCacheURLLoaderFactory(ChromeAppCacheService* appcache_service, | 53 AppCacheURLLoaderFactory(ChromeAppCacheService* appcache_service, |
46 URLLoaderFactoryGetter* factory_getter); | 54 URLLoaderFactoryGetter* factory_getter, |
55 int renderer_process_id); | |
47 | 56 |
48 // Used to query AppCacheStorage to see if a request can be served out of the | 57 // Used to query AppCacheStorage to see if a request can be served out of the |
49 /// AppCache. | 58 /// AppCache. |
50 scoped_refptr<ChromeAppCacheService> appcache_service_; | 59 scoped_refptr<ChromeAppCacheService> appcache_service_; |
51 | 60 |
52 // Used to retrieve the network service factory to pass unhandled requests to | 61 // Used to retrieve the network service factory to pass unhandled requests to |
53 // the network service. | 62 // the network service. |
54 scoped_refptr<URLLoaderFactoryGetter> factory_getter_; | 63 scoped_refptr<URLLoaderFactoryGetter> factory_getter_; |
55 | 64 |
65 // The process id of the renderer. -1 in the browser. | |
66 int renderer_process_id_; | |
michaeln
2017/05/24 00:59:32
If AppCacheURLLoaderFactory is a per-storagepartit
ananta
2017/05/24 02:14:03
Needs to be revisited after kinuko's changes come
jam
2017/05/24 15:29:02
Since you're not passing a factoryptr to the rende
| |
67 | |
56 mojo::StrongBindingSet<mojom::URLLoaderFactory> loader_factory_bindings_; | 68 mojo::StrongBindingSet<mojom::URLLoaderFactory> loader_factory_bindings_; |
57 | 69 |
58 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderFactory); | 70 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderFactory); |
59 }; | 71 }; |
60 | 72 |
61 } // namespace content | 73 } // namespace content |
62 | 74 |
63 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ | 75 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ |
OLD | NEW |