Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: content/browser/appcache/appcache_url_loader_job.h

Issue 2956373002: Add support for subresource request loads in AppCache for the network service. (Closed)
Patch Set: Address review comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_JOB_H_ 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "content/browser/appcache/appcache_entry.h" 13 #include "content/browser/appcache/appcache_entry.h"
14 #include "content/browser/appcache/appcache_job.h" 14 #include "content/browser/appcache/appcache_job.h"
15 #include "content/browser/appcache/appcache_request_handler.h"
15 #include "content/browser/appcache/appcache_response.h" 16 #include "content/browser/appcache/appcache_response.h"
16 #include "content/browser/appcache/appcache_storage.h" 17 #include "content/browser/appcache/appcache_storage.h"
17 #include "content/browser/loader/url_loader_request_handler.h" 18 #include "content/browser/loader/url_loader_request_handler.h"
18 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
19 #include "content/public/common/resource_request.h" 20 #include "content/public/common/resource_request.h"
20 #include "content/public/common/url_loader.mojom.h" 21 #include "content/public/common/url_loader.mojom.h"
22 #include "mojo/public/cpp/bindings/associated_binding.h"
21 #include "mojo/public/cpp/bindings/binding.h" 23 #include "mojo/public/cpp/bindings/binding.h"
22 #include "mojo/public/cpp/system/data_pipe.h" 24 #include "mojo/public/cpp/system/data_pipe.h"
23 25
24 namespace content { 26 namespace content {
25 27
26 class AppCacheRequest; 28 class AppCacheRequest;
27 class NetToMojoPendingBuffer; 29 class NetToMojoPendingBuffer;
30 class URLLoaderFactoryGetter;
31 struct SubresourceLoadInfo;
32
33 // Holds information about the subresource load request like the routing id,
34 // request id, the client pointer, etc.
35 struct SubresourceLoadInfo {
36 SubresourceLoadInfo();
37 ~SubresourceLoadInfo();
38
39 mojom::URLLoaderAssociatedRequest url_loader_request;
40 int32_t routing_id;
41 int32_t request_id;
42 uint32_t options;
43 ResourceRequest request;
44 mojom::URLLoaderClientPtr client;
45 net::MutableNetworkTrafficAnnotationTag traffic_annotation;
46 };
28 47
29 // AppCacheJob wrapper for a mojom::URLLoader implementation which returns 48 // AppCacheJob wrapper for a mojom::URLLoader implementation which returns
30 // responses stored in the AppCache. 49 // responses stored in the AppCache.
31 class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob, 50 class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob,
32 public AppCacheStorage::Delegate, 51 public AppCacheStorage::Delegate,
33 public mojom::URLLoader { 52 public mojom::URLLoader {
34 public: 53 public:
35 ~AppCacheURLLoaderJob() override; 54 ~AppCacheURLLoaderJob() override;
36 55
37 // Sets up the bindings. 56 // Sets up the bindings.
38 void Start(mojom::URLLoaderRequest request, mojom::URLLoaderClientPtr client); 57 void Start(mojom::URLLoaderRequest request, mojom::URLLoaderClientPtr client);
39 58
40 // AppCacheJob overrides. 59 // AppCacheJob overrides.
41 void Kill() override; 60 void Kill() override;
42 bool IsStarted() const override; 61 bool IsStarted() const override;
43 void DeliverAppCachedResponse(const GURL& manifest_url, 62 void DeliverAppCachedResponse(const GURL& manifest_url,
44 int64_t cache_id, 63 int64_t cache_id,
45 const AppCacheEntry& entry, 64 const AppCacheEntry& entry,
46 bool is_fallback) override; 65 bool is_fallback) override;
47 void DeliverNetworkResponse() override; 66 void DeliverNetworkResponse() override;
48 void DeliverErrorResponse() override; 67 void DeliverErrorResponse() override;
49 const GURL& GetURL() const override; 68 const GURL& GetURL() const override;
50 AppCacheURLLoaderJob* AsURLLoaderJob() override; 69 AppCacheURLLoaderJob* AsURLLoaderJob() override;
51 70
52 // mojom::URLLoader implementation: 71 // mojom::URLLoader implementation:
53 void FollowRedirect() override; 72 void FollowRedirect() override;
54 void SetPriority(net::RequestPriority priority, 73 void SetPriority(net::RequestPriority priority,
55 int32_t intra_priority_value) override; 74 int32_t intra_priority_value) override;
56 75
57 void set_loader_callback(LoaderCallback callback) { 76 void set_main_resource_loader_callback(LoaderCallback callback) {
58 loader_callback_ = std::move(callback); 77 main_resource_loader_callback_ = std::move(callback);
78 }
79
80 // Subresource request load information is passed in the
81 // |subresource_load_info| parameter. This includes the request id, the
82 // client pointer, etc.
83 // |default_url_loader| is used to retrieve the network loader for requests
84 // intended to be sent to the network.
85 void SetSubresourceLoadInfo(
86 std::unique_ptr<SubresourceLoadInfo> subresource_load_info,
87 URLLoaderFactoryGetter* default_url_loader);
88
89 // Ownership of the |handler| is transferred to us via this call. This is
90 // only for subresource requests.
91 void set_request_handler(std::unique_ptr<AppCacheRequestHandler> handler) {
92 sub_resource_handler_ = std::move(handler);
59 } 93 }
60 94
61 protected: 95 protected:
62 // AppCacheJob::Create() creates this instance. 96 // AppCacheJob::Create() creates this instance.
63 friend class AppCacheJob; 97 friend class AppCacheJob;
64 98
65 AppCacheURLLoaderJob(const ResourceRequest& request, 99 AppCacheURLLoaderJob(const ResourceRequest& request,
66 AppCacheStorage* storage); 100 AppCacheStorage* storage);
67 101
68 // AppCacheStorage::Delegate methods 102 // AppCacheStorage::Delegate methods
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 mojom::URLLoaderClientPtr client_info_; 150 mojom::URLLoaderClientPtr client_info_;
117 151
118 // mojo data pipe entities. 152 // mojo data pipe entities.
119 mojo::ScopedDataPipeProducerHandle response_body_stream_; 153 mojo::ScopedDataPipeProducerHandle response_body_stream_;
120 154
121 scoped_refptr<NetToMojoPendingBuffer> pending_write_; 155 scoped_refptr<NetToMojoPendingBuffer> pending_write_;
122 156
123 mojo::SimpleWatcher writable_handle_watcher_; 157 mojo::SimpleWatcher writable_handle_watcher_;
124 158
125 // The Callback to be invoked in the network service land to indicate if 159 // The Callback to be invoked in the network service land to indicate if
126 // the request can be serviced via the AppCache. 160 // the main resource request can be serviced via the AppCache.
127 LoaderCallback loader_callback_; 161 LoaderCallback main_resource_loader_callback_;
162
163 // We own the AppCacheRequestHandler instance for subresource requests.
164 std::unique_ptr<AppCacheRequestHandler> sub_resource_handler_;
165
166 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_;
167
168 // Holds subresource url loader information.
169 std::unique_ptr<SubresourceLoadInfo> subresource_load_info_;
170
171 // Timing information for the most recent request. Its start times are
172 // populated in DeliverAppCachedResponse().
173 net::LoadTimingInfo load_timing_info_;
174
175 // Used for subresource requests which go to the network.
176 mojom::URLLoaderAssociatedPtr network_loader_request_;
177
178 // Binds the subresource URLLoaderClient with us. We can use the regular
179 // binding_ member above when we remove the need for the associated requests
180 // issue with URLLoaderFactory.
181 std::unique_ptr<mojo::AssociatedBinding<mojom::URLLoader>>
182 associated_binding_;
128 183
129 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); 184 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob);
130 }; 185 };
131 186
132 } // namespace content 187 } // namespace content
133 188
134 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ 189 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_subresource_url_factory.cc ('k') | content/browser/appcache/appcache_url_loader_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698