Chromium Code Reviews| 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..73182c52e31c5ddf3f5ab66083bda251fafb7b65 100644 |
| --- a/content/browser/appcache/appcache_url_loader_job.h |
| +++ b/content/browser/appcache/appcache_url_loader_job.h |
| @@ -6,30 +6,44 @@ |
| #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/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 URLLoaderFactoryGetter; |
| +class NetToMojoIOBuffer; |
| +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(int routing_id, |
| + int request_id, |
|
michaeln
2017/06/09 01:48:30
the id's aren't needed yet
ananta
2017/06/09 04:48:19
Removed
|
| + 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 +51,110 @@ 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 SetURLLoaderFactoryGetter( |
| + URLLoaderFactoryGetter* url_loader_factory_getter); |
| + |
| + 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; |
| + 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(); |
| + |
| + // 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_; |
| + |
| + AppCacheStorage* storage_; |
|
michaeln
2017/06/09 01:48:30
this rawptr could become dangling, we need to be c
ananta
2017/06/09 04:48:19
Set it to nullptr in DeliverErrorResponse() like t
|
| + |
| + // 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<NetToMojoIOBuffer> buffer_; |
| + |
| + // 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_; |
| + |
| + // URLLoader proxy for the network service. |
| + mojom::URLLoaderAssociatedPtr url_loader_network_; |
|
michaeln
2017/06/09 01:48:30
since we don't need this yet, i'd vote to remove i
ananta
2017/06/09 04:48:19
Done.
|
| + |
| + // Routing id of the request. This is 0 for navigation requests. For |
| + // subresource requests it is non zero. |
| + int routing_id_; |
|
michaeln
2017/06/09 01:48:30
ditto
ananta
2017/06/09 04:48:19
Done.
|
| + |
| + // Request id. |
| + int request_id_; |
| + |
| + // Getter for the network service URL loader. |
| + scoped_refptr<URLLoaderFactoryGetter> url_loader_factory_getter_; |
|
michaeln
2017/06/09 01:48:30
ditto
ananta
2017/06/09 04:48:19
Done.
|
| + |
| + // 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); |
| }; |