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

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

Issue 2902653002: Get main frame and subframe AppCache loads to work. (Closed)
Patch Set: Another attempt at fixing redness Created 3 years, 6 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/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/time/time.h"
12 #include "content/browser/appcache/appcache_entry.h"
10 #include "content/browser/appcache/appcache_job.h" 13 #include "content/browser/appcache/appcache_job.h"
14 #include "content/browser/appcache/appcache_response.h"
15 #include "content/browser/appcache/appcache_storage.h"
11 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/common/resource_request.h"
18 #include "content/common/url_loader.mojom.h"
19 #include "mojo/public/cpp/bindings/associated_binding.h"
20 #include "mojo/public/cpp/system/data_pipe.h"
21
22 namespace net {
23 class IOBuffer;
24 } // namespace net
12 25
13 namespace content { 26 namespace content {
14 27
15 class AppCacheHost;
16 class AppCacheRequest; 28 class AppCacheRequest;
17 class AppCacheStorage; 29 class URLLoaderFactoryGetter;
18 30
19 // AppCacheJob wrapper for a mojom::URLLoader implementation which returns 31 // AppCacheJob wrapper for a mojom::URLLoader implementation which returns
20 // responses stored in the AppCache. 32 // responses stored in the AppCache.
21 class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob { 33 class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob,
34 public AppCacheStorage::Delegate,
35 public mojom::URLLoader {
22 public: 36 public:
23 ~AppCacheURLLoaderJob() override; 37 ~AppCacheURLLoaderJob() override;
24 38
25 // AppCacheJob overrides. 39 // AppCacheJob overrides.
26 void Kill() override; 40 void Kill() override;
27 bool IsStarted() const override; 41 bool IsStarted() const override;
28 bool IsWaiting() const override;
29 bool IsDeliveringAppCacheResponse() const override;
30 bool IsDeliveringNetworkResponse() const override;
31 bool IsDeliveringErrorResponse() const override;
32 bool IsCacheEntryNotFound() const override;
33 void DeliverAppCachedResponse(const GURL& manifest_url, 42 void DeliverAppCachedResponse(const GURL& manifest_url,
34 int64_t cache_id, 43 int64_t cache_id,
35 const AppCacheEntry& entry, 44 const AppCacheEntry& entry,
36 bool is_fallback) override; 45 bool is_fallback) override;
37 void DeliverNetworkResponse() override; 46 void DeliverNetworkResponse() override;
38 void DeliverErrorResponse() override; 47 void DeliverErrorResponse() override;
39 const GURL& GetURL() const override; 48 const GURL& GetURL() const override;
49 AppCacheURLLoaderJob* AsURLLoaderJob() override;
50
51 // mojom::URLLoader implementation:
52 void FollowRedirect() override;
53 void SetPriority(net::RequestPriority priority,
54 int32_t intra_priority_value) override;
55
56 // Binds to the client endpoint.
57 void BindEndpoints(const ResourceRequest& request,
58 mojom::URLLoaderAssociatedRequest url_loader_request,
59 int32_t routing_id,
60 int32_t request_id,
61 mojom::URLLoaderClientPtrInfo client_info);
62
63 void SetURLLoaderFactoryGetter(
64 URLLoaderFactoryGetter* url_loader_factory_getter);
40 65
41 protected: 66 protected:
42 // AppCacheJob::Create() creates this instance. 67 // AppCacheJob::Create() creates this instance.
43 friend class AppCacheJob; 68 friend class AppCacheJob;
44 69
45 AppCacheURLLoaderJob(); 70 AppCacheURLLoaderJob(const ResourceRequest& request,
71 AppCacheStorage* storage);
46 72
47 GURL url_; 73 // AppCacheStorage::Delegate methods
74 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info,
75 int64_t response_id) override;
76 void OnCacheLoaded(AppCache* cache, int64_t cache_id) override;
77
78 // AppCacheResponseReader completion callback
79 void OnReadComplete(int result);
80
81 void OnConnectionError();
82
83 // Helper to send the AppCacheResponseInfo to the URLLoaderClient.
84 void SendResponseInfo();
85
86 // The current request.
87 ResourceRequest request_;
88
89 AppCacheStorage* storage_;
90
91 // The response details.
92 scoped_refptr<AppCacheResponseInfo> info_;
93
94 // Used to read the cache.
95 std::unique_ptr<AppCacheResponseReader> reader_;
96
97 // Time when the request started.
98 base::TimeTicks start_time_tick_;
99
100 // The AppCache manifest URL.
101 GURL manifest_url_;
102
103 // The AppCache id.
104 int64_t cache_id_;
105
106 AppCacheEntry entry_;
107
108 // Set to true if we are loading fallback content.
109 bool is_fallback_;
110
111 // The buffer used to read AppCache data.
112 scoped_refptr<net::IOBuffer> buffer_;
113
114 // The data pipe used to transfer AppCache data to the client.
115 mojo::DataPipe data_pipe_;
116
117 // Binds the URLLoaderClient with us.
118 std::unique_ptr<mojo::AssociatedBinding<mojom::URLLoader>> binding_;
119
120 // The URLLoaderClient pointer. We call this interface with notifications
121 // about the URL load
122 mojom::URLLoaderClientPtr client_info_;
123
124 // URLLoader proxy for the network service.
125 mojom::URLLoaderAssociatedPtr url_loader_network_;
126
127 // Routing id of the request. This is 0 for navigation requests. For
128 // subresource requests it is non zero.
129 int routing_id_;
130
131 // Request id.
132 int request_id_;
133
134 // Getter for the network service URL loader.
135 scoped_refptr<URLLoaderFactoryGetter> url_loader_factory_getter_;
48 136
49 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); 137 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob);
50 }; 138 };
51 139
52 } // namespace content 140 } // namespace content
53 141
54 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ 142 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698