| 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..3a1e125738d0209930808ddd977c135afcfacec9 100644
|
| --- a/content/browser/appcache/appcache_url_loader_job.h
|
| +++ b/content/browser/appcache/appcache_url_loader_job.h
|
| @@ -6,30 +6,40 @@
|
| #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_
|
|
|
| #include "base/logging.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/weak_ptr.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/browser/loader/url_loader_request_handler.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/binding.h"
|
| +#include "mojo/public/cpp/system/data_pipe.h"
|
|
|
| namespace content {
|
|
|
| -class AppCacheHost;
|
| class AppCacheRequest;
|
| -class AppCacheStorage;
|
| +class NetToMojoPendingBuffer;
|
|
|
| // 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;
|
|
|
| + // Sets up the bindings.
|
| + void Start(mojom::URLLoaderRequest request, mojom::URLLoaderClientPtr client);
|
| +
|
| // 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 +47,90 @@ 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;
|
| +
|
| + void set_loader_callback(LoaderCallback callback) {
|
| + loader_callback_ = std::move(callback);
|
| + }
|
|
|
| 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;
|
| +
|
| + // AppCacheResponseReader completion callback
|
| + void OnReadComplete(int result);
|
| +
|
| + void OnConnectionError();
|
| +
|
| + // Helper to send the AppCacheResponseInfo to the URLLoaderClient.
|
| + void SendResponseInfo();
|
| +
|
| + // Helper function to read the data from the AppCache.
|
| + void ReadMore();
|
| +
|
| + // Callback invoked when the data pipe can be written to.
|
| + void OnResponseBodyStreamReady(MojoResult result);
|
| +
|
| + // Notifies the client about request completion.
|
| + void NotifyCompleted(int error_code);
|
| +
|
| + // The current request.
|
| + ResourceRequest request_;
|
| +
|
| + base::WeakPtr<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 data pipe used to transfer AppCache data to the client.
|
| + mojo::DataPipe data_pipe_;
|
| +
|
| + // Binds the URLLoaderClient with us.
|
| + mojo::Binding<mojom::URLLoader> binding_;
|
| +
|
| + // The URLLoaderClient pointer. We call this interface with notifications
|
| + // about the URL load
|
| + mojom::URLLoaderClientPtr client_info_;
|
| +
|
| + // mojo data pipe entities.
|
| + mojo::ScopedDataPipeProducerHandle response_body_stream_;
|
| +
|
| + scoped_refptr<NetToMojoPendingBuffer> pending_write_;
|
| +
|
| + mojo::SimpleWatcher writable_handle_watcher_;
|
|
|
| - GURL url_;
|
| + // The Callback to be invoked in the network service land to indicate if
|
| + // the request can be serviced via the AppCache.
|
| + LoaderCallback loader_callback_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob);
|
| };
|
|
|