Index: content/browser/appcache/appcache_url_loader_job.h |
diff --git a/content/browser/appcache/appcache_url_loader_job.h b/content/browser/appcache/appcache_url_loader_job.h |
index 3d526c9b05fb7057ccd68a405db3bca390ba4f5b..bf993b555022a0e713dbe29a3b68c502d4e14529 100644 |
--- a/content/browser/appcache/appcache_url_loader_job.h |
+++ b/content/browser/appcache/appcache_url_loader_job.h |
@@ -6,30 +6,39 @@ |
#define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ |
#include "base/logging.h" |
+#include "base/memory/ref_counted.h" |
#include "base/strings/string16.h" |
+#include "base/time/time.h" |
+#include "content/browser/appcache/appcache_entry.h" |
#include "content/browser/appcache/appcache_job.h" |
+#include "content/browser/appcache/appcache_response.h" |
+#include "content/browser/appcache/appcache_storage.h" |
#include "content/common/content_export.h" |
+#include "content/common/resource_request.h" |
+#include "content/common/url_loader.mojom.h" |
+#include "mojo/public/cpp/bindings/associated_binding.h" |
+#include "mojo/public/cpp/system/data_pipe.h" |
+ |
+namespace net { |
+class IOBuffer; |
+} // namespace net |
namespace content { |
-class AppCacheHost; |
class AppCacheRequest; |
-class AppCacheStorage; |
+class URLLoaderFactoryGetter; |
// AppCacheJob wrapper for a mojom::URLLoader implementation which returns |
// responses stored in the AppCache. |
-class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob { |
+class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob, |
+ public AppCacheStorage::Delegate, |
+ public mojom::URLLoader { |
public: |
~AppCacheURLLoaderJob() override; |
// AppCacheJob overrides. |
void Kill() override; |
bool IsStarted() const override; |
- bool IsWaiting() const override; |
- bool IsDeliveringAppCacheResponse() const override; |
- bool IsDeliveringNetworkResponse() const override; |
- bool IsDeliveringErrorResponse() const override; |
- bool IsCacheEntryNotFound() const override; |
void DeliverAppCachedResponse(const GURL& manifest_url, |
int64_t cache_id, |
const AppCacheEntry& entry, |
@@ -37,14 +46,93 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob { |
void DeliverNetworkResponse() override; |
void DeliverErrorResponse() override; |
const GURL& GetURL() const override; |
+ AppCacheURLLoaderJob* AsURLLoaderJob() override; |
+ |
+ // mojom::URLLoader implementation: |
+ void FollowRedirect() override; |
+ void SetPriority(net::RequestPriority priority, |
+ int32_t intra_priority_value) override; |
+ |
+ // Binds to the client endpoint. |
+ void BindEndpoints(const ResourceRequest& request, |
+ mojom::URLLoaderAssociatedRequest url_loader_request, |
+ int32_t routing_id, |
+ int32_t request_id, |
+ mojom::URLLoaderClientPtrInfo client_info); |
+ |
+ void SetURLLoaderFactoryGetter( |
+ URLLoaderFactoryGetter* url_loader_factory_getter); |
protected: |
// AppCacheJob::Create() creates this instance. |
friend class AppCacheJob; |
- AppCacheURLLoaderJob(); |
+ AppCacheURLLoaderJob(const ResourceRequest& request, |
+ AppCacheStorage* storage); |
+ |
+ // AppCacheStorage::Delegate methods |
+ void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, |
+ int64_t response_id) override; |
+ void OnCacheLoaded(AppCache* cache, int64_t cache_id) override; |
+ |
+ // AppCacheResponseReader completion callback |
+ void OnReadComplete(int result); |
+ |
+ void OnConnectionError(); |
+ |
+ // Helper to send the AppCacheResponseInfo to the URLLoaderClient. |
+ void SendResponseInfo(); |
+ |
+ // The current request. |
+ ResourceRequest request_; |
+ |
+ AppCacheStorage* storage_; |
+ |
+ // The response details. |
+ scoped_refptr<AppCacheResponseInfo> info_; |
+ |
+ // Used to read the cache. |
+ std::unique_ptr<AppCacheResponseReader> reader_; |
+ |
+ // Time when the request started. |
+ base::TimeTicks start_time_tick_; |
+ |
+ // The AppCache manifest URL. |
+ GURL manifest_url_; |
+ |
+ // The AppCache id. |
+ int64_t cache_id_; |
+ |
+ AppCacheEntry entry_; |
+ |
+ // Set to true if we are loading fallback content. |
+ bool is_fallback_; |
+ |
+ // The buffer used to read AppCache data. |
+ scoped_refptr<net::IOBuffer> buffer_; |
+ |
+ // The data pipe used to transfer AppCache data to the client. |
+ mojo::DataPipe data_pipe_; |
+ |
+ // Binds the URLLoaderClient with us. |
+ mojo::AssociatedBinding<mojom::URLLoader> binding_; |
+ |
+ // The URLLoaderClient pointer. We call this interface with notifications |
+ // about the URL load |
+ mojom::URLLoaderClientPtr client_info_; |
+ |
+ // URLLoader proxy for the network service. |
+ mojom::URLLoaderAssociatedPtr url_loader_network_; |
+ |
+ // Routing id of the request. This is 0 for navigation requests. For |
+ // subresource requests it is non zero. |
+ int routing_id_; |
+ |
+ // Request id. |
+ int request_id_; |
- GURL url_; |
+ // Getter for the network service URL loader. |
+ scoped_refptr<URLLoaderFactoryGetter> url_loader_factory_getter_; |
DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); |
}; |