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

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 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"
11 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/common/resource_request.h"
18
19 namespace net {
20 class IOBuffer;
21 } // namespace net
12 22
13 namespace content { 23 namespace content {
14 24
15 class AppCacheHost; 25 class AppCacheHost;
16 class AppCacheRequest; 26 class AppCacheRequest;
17 class AppCacheStorage; 27 class AppCacheStorage;
18 28
19 // AppCacheJob wrapper for a mojom::URLLoader implementation which returns 29 // AppCacheJob wrapper for a mojom::URLLoader implementation which returns
20 // responses stored in the AppCache. 30 // responses stored in the AppCache.
21 class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob { 31 class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob,
michaeln 2017/06/02 01:18:00 To make fewer moving parts, would it make sense to
ananta 2017/06/03 01:55:55 The class implements the URLLoader mojom. The fact
32 public AppCacheStorage::Delegate {
22 public: 33 public:
34 class Delegate {
35 public:
36 // Generally called when we don't have an AppCache response for the
37 // ongoing request.
38 virtual void SendNetworkResponse() {}
39
40 // Called when we want to send out an error response to the client.
41 virtual void SendErrorResponse() {}
42
43 // Called when we have a valid response from the AppCache.
44 virtual void HandleAppCacheResponseStart(
45 AppCacheResponseInfo* response_info) {}
46
47 // Called when we have valid AppCache data to send to the client.
48 virtual void HandleAppCacheData(net::IOBuffer* buffer, int buffer_fsize) {}
49 };
50
23 ~AppCacheURLLoaderJob() override; 51 ~AppCacheURLLoaderJob() override;
24 52
25 // AppCacheJob overrides. 53 // AppCacheJob overrides.
26 void Kill() override; 54 void Kill() override;
27 bool IsStarted() const override; 55 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, 56 void DeliverAppCachedResponse(const GURL& manifest_url,
34 int64_t cache_id, 57 int64_t cache_id,
35 const AppCacheEntry& entry, 58 const AppCacheEntry& entry,
36 bool is_fallback) override; 59 bool is_fallback) override;
37 void DeliverNetworkResponse() override; 60 void DeliverNetworkResponse() override;
38 void DeliverErrorResponse() override; 61 void DeliverErrorResponse() override;
39 const GURL& GetURL() const override; 62 const GURL& GetURL() const override;
63 AppCacheURLLoaderJob* AsURLLoaderJob() override;
64
65 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
40 66
41 protected: 67 protected:
42 // AppCacheJob::Create() creates this instance. 68 // AppCacheJob::Create() creates this instance.
43 friend class AppCacheJob; 69 friend class AppCacheJob;
44 70
45 AppCacheURLLoaderJob(); 71 AppCacheURLLoaderJob(const ResourceRequest& request,
72 AppCacheStorage* storage);
46 73
47 GURL url_; 74 // AppCacheStorage::Delegate methods
75 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info,
76 int64_t response_id) override;
77 void OnCacheLoaded(AppCache* cache, int64_t cache_id) override;
78
79 // AppCacheResponseReader completion callback
80 void OnReadComplete(int result);
81
82 // The current request.
83 ResourceRequest request_;
84
85 // The delegate is invoked when we have data to report from the AppCache,
86 // or if the request is to be sent directly to the n/w, etc.
87 Delegate* delegate_;
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_;
48 113
49 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); 114 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob);
50 }; 115 };
51 116
52 } // namespace content 117 } // namespace content
53 118
54 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ 119 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698