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

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: Moved the SubresourceLoadInfo structure to the appcache_url_loader_job.h/.cc files. 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/common/resource_request.h" 20 #include "content/common/resource_request.h"
20 #include "content/common/url_loader.mojom.h" 21 #include "content/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.
(...skipping 13 matching lines...) Expand all
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_loader_callback(LoaderCallback callback) {
58 loader_callback_ = std::move(callback); 77 loader_callback_ = std::move(callback);
59 } 78 }
60 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 // |handler| points to the AppCacheRequestHandler instance handling this
84 // request. The job controls the lifetime of the handler.
85 // |default_url_loader| is used to retrieve the network loader for requests
86 // intended to be sent to the network.
87 void SetSubresourceLoadInfo(
88 std::unique_ptr<SubresourceLoadInfo> subresource_load_info,
89 AppCacheRequestHandler* handler,
90 URLLoaderFactoryGetter* default_url_loader);
91
61 protected: 92 protected:
62 // AppCacheJob::Create() creates this instance. 93 // AppCacheJob::Create() creates this instance.
63 friend class AppCacheJob; 94 friend class AppCacheJob;
64 95
65 AppCacheURLLoaderJob(const ResourceRequest& request, 96 AppCacheURLLoaderJob(const ResourceRequest& request,
66 AppCacheStorage* storage); 97 AppCacheStorage* storage);
67 98
68 // AppCacheStorage::Delegate methods 99 // AppCacheStorage::Delegate methods
69 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, 100 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info,
70 int64_t response_id) override; 101 int64_t response_id) override;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 mojo::ScopedDataPipeProducerHandle response_body_stream_; 150 mojo::ScopedDataPipeProducerHandle response_body_stream_;
120 151
121 scoped_refptr<NetToMojoPendingBuffer> pending_write_; 152 scoped_refptr<NetToMojoPendingBuffer> pending_write_;
122 153
123 mojo::SimpleWatcher writable_handle_watcher_; 154 mojo::SimpleWatcher writable_handle_watcher_;
124 155
125 // The Callback to be invoked in the network service land to indicate if 156 // The Callback to be invoked in the network service land to indicate if
126 // the request can be serviced via the AppCache. 157 // the request can be serviced via the AppCache.
127 LoaderCallback loader_callback_; 158 LoaderCallback loader_callback_;
128 159
160 // We own the AppCacheRequestHandler instance for subresource requests.
161 std::unique_ptr<AppCacheRequestHandler> handler_;
162
163 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_;
164
165 // Holds subresource url loader information.
166 std::unique_ptr<SubresourceLoadInfo> subresource_load_info_;
167
168 // Timing information for the most recent request. Its start times are
169 // populated in DeliverAppCachedResponse().
170 net::LoadTimingInfo load_timing_info_;
171
172 // Used for subresource requests which go to the network.
173 mojom::URLLoaderAssociatedPtr network_loader_request_;
174
175 // Binds the subresource URLLoaderClient with us. We can use the regular
176 // binding_ member above when we remove the need for the associated requests
177 // issue with URLLoaderFactory.
178 std::unique_ptr<mojo::AssociatedBinding<mojom::URLLoader>>
179 associated_binding_;
180
129 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); 181 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob);
130 }; 182 };
131 183
132 } // namespace content 184 } // namespace content
133 185
134 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ 186 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698