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

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: Address next round of review comments 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"
16 #include "content/browser/loader/url_loader_request_handler.h"
11 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/common/resource_request.h"
19 #include "content/common/url_loader.mojom.h"
20 #include "mojo/public/cpp/bindings/binding.h"
21 #include "mojo/public/cpp/system/data_pipe.h"
12 22
13 namespace content { 23 namespace content {
14 24
15 class AppCacheHost;
16 class AppCacheRequest; 25 class AppCacheRequest;
17 class AppCacheStorage; 26 class NetToMojoPendingBuffer;
18 27
19 // AppCacheJob wrapper for a mojom::URLLoader implementation which returns 28 // AppCacheJob wrapper for a mojom::URLLoader implementation which returns
20 // responses stored in the AppCache. 29 // responses stored in the AppCache.
21 class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob { 30 class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob,
31 public AppCacheStorage::Delegate,
32 public mojom::URLLoader {
22 public: 33 public:
23 ~AppCacheURLLoaderJob() override; 34 ~AppCacheURLLoaderJob() override;
24 35
36 // Sets up the bindings.
37 void Start(mojom::URLLoaderRequest request,
38 mojom::URLLoaderClientPtr client);
39
25 // AppCacheJob overrides. 40 // AppCacheJob overrides.
26 void Kill() override; 41 void Kill() override;
27 bool IsStarted() const override; 42 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, 43 void DeliverAppCachedResponse(const GURL& manifest_url,
34 int64_t cache_id, 44 int64_t cache_id,
35 const AppCacheEntry& entry, 45 const AppCacheEntry& entry,
36 bool is_fallback) override; 46 bool is_fallback) override;
37 void DeliverNetworkResponse() override; 47 void DeliverNetworkResponse() override;
38 void DeliverErrorResponse() override; 48 void DeliverErrorResponse() override;
39 const GURL& GetURL() const override; 49 const GURL& GetURL() const override;
50 AppCacheURLLoaderJob* AsURLLoaderJob() override;
51
52 // mojom::URLLoader implementation:
53 void FollowRedirect() override;
54 void SetPriority(net::RequestPriority priority,
55 int32_t intra_priority_value) override;
56
57 void set_loader_callback(LoaderCallback callback) {
58 loader_callback_ = std::move(callback);
59 }
40 60
41 protected: 61 protected:
42 // AppCacheJob::Create() creates this instance. 62 // AppCacheJob::Create() creates this instance.
43 friend class AppCacheJob; 63 friend class AppCacheJob;
44 64
45 AppCacheURLLoaderJob(); 65 AppCacheURLLoaderJob(const ResourceRequest& request,
66 AppCacheStorage* storage);
46 67
47 GURL url_; 68 // AppCacheStorage::Delegate methods
69 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info,
70 int64_t response_id) override;
71 void OnCacheLoaded(AppCache* cache, int64_t cache_id) override;
michaeln 2017/06/09 19:59:54 the OnCacheLoaded method isn't needed in this clas
ananta 2017/06/09 20:39:33 Thanks done.
72
73 // AppCacheResponseReader completion callback
74 void OnReadComplete(int result);
75
76 void OnConnectionError();
77
78 // Helper to send the AppCacheResponseInfo to the URLLoaderClient.
79 void SendResponseInfo();
80
81 // Helper function to read the data from the AppCache.
82 void ReadMore();
83
84 // Callback invoked when the data pipe can be written to.
85 void OnResponseBodyStreamReady(MojoResult result);
86
87 // Notifies the client about request completion.
88 void NotifyCompleted(int error_code);
89
90 // The current request.
91 ResourceRequest request_;
92
93 AppCacheStorage* storage_;
94
95 // The response details.
96 scoped_refptr<AppCacheResponseInfo> info_;
97
98 // Used to read the cache.
99 std::unique_ptr<AppCacheResponseReader> reader_;
100
101 // Time when the request started.
102 base::TimeTicks start_time_tick_;
103
104 // The AppCache manifest URL.
105 GURL manifest_url_;
106
107 // The AppCache id.
108 int64_t cache_id_;
109
110 AppCacheEntry entry_;
111
112 // Set to true if we are loading fallback content.
113 bool is_fallback_;
114
115 // The data pipe used to transfer AppCache data to the client.
116 mojo::DataPipe data_pipe_;
117
118 // Binds the URLLoaderClient with us.
119 mojo::Binding<mojom::URLLoader> binding_;
120
121 // The URLLoaderClient pointer. We call this interface with notifications
122 // about the URL load
123 mojom::URLLoaderClientPtr client_info_;
124
125 // mojo data pipe entities.
126 mojo::ScopedDataPipeProducerHandle response_body_stream_;
127
128 scoped_refptr<NetToMojoPendingBuffer> pending_write_;
129
130 mojo::SimpleWatcher writable_handle_watcher_;
131
132 // The Callback to be invoked in the network service land to indicate if
133 // the request can be serviced via the AppCache.
134 LoaderCallback loader_callback_;
48 135
49 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); 136 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob);
50 }; 137 };
51 138
52 } // namespace content 139 } // namespace content
53 140
54 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ 141 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698