Commit b9693954 authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

AppCache: Merge AppCacheJob and AppCacheURLLoaderJob.

AppCacheURLLoaderJob is the only subclass of AppCacheJob. This is a
vestige of the Network Service migration, which introduced the
AppCacheJob base class with two implementations.

This CL merges AppCacheJob and AppCacheURLLoaderJob, and renames the
result to AppCacheURLLoader. The new name is more appropriate in a
Network Service-only world, and removes the potential for confusion
with AppCacheUpdateJob.

The following replaces were done mechanically over the entire
repository:
* AppCacheURLLoaderJob -> AppCacheURLLoader
* AppCacheJob -> AppCacheURLLoader
* appcache_url_loader_job.h -> appcache_url_loader.h
* appcache_job.h -> appcache_url_loader.h
* GetDerivedWeakPtr -> GetWeakPtr
* appcache_url_loader_job -> appcache_url_loader

AppCacheJob::AsURLLoaderJob() was removed, as it became a no-op after
the class merger. The mechanical replaces above removed
AppCacheURLLoaderJob::GetDerivedWeakPtr(), which became a synonym for
GetWeakPtr().

When relevant, job / Job was replaced with loader / Loader in local
variable names and method names.

This CL does not introduce any functional change.

Change-Id: I5a508a8dcb14ec77da05dd345d280ea27fa12fa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066298
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743485}
parent f0b6e056
...@@ -394,8 +394,6 @@ jumbo_source_set("browser") { ...@@ -394,8 +394,6 @@ jumbo_source_set("browser") {
"appcache/appcache_host.h", "appcache/appcache_host.h",
"appcache/appcache_internals_ui.cc", "appcache/appcache_internals_ui.cc",
"appcache/appcache_internals_ui.h", "appcache/appcache_internals_ui.h",
"appcache/appcache_job.cc",
"appcache/appcache_job.h",
"appcache/appcache_manifest_parser.cc", "appcache/appcache_manifest_parser.cc",
"appcache/appcache_manifest_parser.h", "appcache/appcache_manifest_parser.h",
"appcache/appcache_namespace.cc", "appcache/appcache_namespace.cc",
...@@ -430,8 +428,8 @@ jumbo_source_set("browser") { ...@@ -430,8 +428,8 @@ jumbo_source_set("browser") {
"appcache/appcache_update_url_fetcher.h", "appcache/appcache_update_url_fetcher.h",
"appcache/appcache_update_url_loader_request.cc", "appcache/appcache_update_url_loader_request.cc",
"appcache/appcache_update_url_loader_request.h", "appcache/appcache_update_url_loader_request.h",
"appcache/appcache_url_loader_job.cc", "appcache/appcache_url_loader.cc",
"appcache/appcache_url_loader_job.h", "appcache/appcache_url_loader.h",
"appcache/appcache_working_set.cc", "appcache/appcache_working_set.cc",
"appcache/appcache_working_set.h", "appcache/appcache_working_set.h",
"appcache/chrome_appcache_service.cc", "appcache/chrome_appcache_service.cc",
......
// Copyright (c) 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/appcache/appcache_job.h"
#include "base/command_line.h"
#include "content/browser/appcache/appcache_request.h"
#include "content/browser/appcache/appcache_response.h"
#include "content/browser/appcache/appcache_url_loader_job.h"
#include "content/public/common/content_features.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
namespace content {
AppCacheJob::~AppCacheJob() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
AppCacheURLLoaderJob* AppCacheJob::AsURLLoaderJob() {
return nullptr;
}
AppCacheJob::AppCacheJob()
: cache_entry_not_found_(false),
delivery_type_(DeliveryType::kAwaitingDeliverCall) {}
void AppCacheJob::InitializeRangeRequestInfo(
const net::HttpRequestHeaders& headers) {
std::string value;
std::vector<net::HttpByteRange> ranges;
if (!headers.GetHeader(net::HttpRequestHeaders::kRange, &value) ||
!net::HttpUtil::ParseRangeHeader(value, &ranges)) {
return;
}
// If multiple ranges are requested, we play dumb and
// return the entire response with 200 OK.
if (ranges.size() == 1U)
range_requested_ = ranges[0];
}
void AppCacheJob::SetupRangeResponse() {
DCHECK(is_range_request() && reader_.get() && IsDeliveringAppCacheResponse());
int resource_size = static_cast<int>(info_->response_data_size());
if (resource_size < 0 || !range_requested_.ComputeBounds(resource_size)) {
range_requested_ = net::HttpByteRange();
return;
}
DCHECK(range_requested_.IsValid());
int offset = static_cast<int>(range_requested_.first_byte_position());
int length = static_cast<int>(range_requested_.last_byte_position() -
range_requested_.first_byte_position() + 1);
// Tell the reader about the range to read.
reader_->SetReadRange(offset, length);
// Make a copy of the full response headers and fix them up
// for the range we'll be returning.
range_response_info_ =
std::make_unique<net::HttpResponseInfo>(info_->http_response_info());
net::HttpResponseHeaders* headers = range_response_info_->headers.get();
headers->UpdateWithNewRange(range_requested_, resource_size,
true /* replace status line */);
}
} // namespace content
// Copyright (c) 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_
#define CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_
#include <memory>
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "base/strings/string16.h"
#include "content/common/content_export.h"
#include "net/http/http_byte_range.h"
#include "url/gurl.h"
namespace net {
class HttpRequestHeaders;
class HttpResponseInfo;
}
namespace content {
class AppCacheEntry;
class AppCacheResponseInfo;
class AppCacheResponseReader;
class AppCacheURLLoaderJob;
// Interface for an AppCache job. This is used to send data stored in the
// AppCache to networking consumers.
// Subclasses implement this interface to wrap custom job objects like
// URLRequestJob, URLLoaderJob, etc to ensure that these dependencies stay out
// of the AppCache code.
class CONTENT_EXPORT AppCacheJob {
public:
enum class DeliveryType {
kAwaitingDeliverCall,
kAppCached,
kNetwork,
kError,
};
virtual ~AppCacheJob();
// True if the job was started.
virtual bool IsStarted() const = 0;
// True if the job is waiting for instructions.
bool IsWaiting() const {
return delivery_type_ == DeliveryType::kAwaitingDeliverCall;
}
// True if the job is delivering a response from the cache.
bool IsDeliveringAppCacheResponse() const {
return delivery_type_ == DeliveryType::kAppCached;
}
// Returns true if the job is delivering a response from the network.
bool IsDeliveringNetworkResponse() const {
return delivery_type_ == DeliveryType::kNetwork;
}
// Returns true if the job is delivering an error response.
bool IsDeliveringErrorResponse() const {
return delivery_type_ == DeliveryType::kError;
}
// Returns true if the cache entry was not found in the cache.
bool IsCacheEntryNotFound() const { return cache_entry_not_found_; }
// Informs the job of what response it should deliver. Only one of these
// methods should be called, and only once per job. A job will sit idle and
// wait indefinitely until one of the deliver methods is called.
virtual void DeliverAppCachedResponse(const GURL& manifest_url,
int64_t cache_id,
const AppCacheEntry& entry,
bool is_fallback) = 0;
// Informs the job that it should deliver the response from the network. This
// is generally controlled by the entries in the manifest file.
virtual void DeliverNetworkResponse() = 0;
// Informs the job that it should deliver an error response.
virtual void DeliverErrorResponse() = 0;
// Returns a weak pointer reference to the job.
virtual base::WeakPtr<AppCacheJob> GetWeakPtr() = 0;
// Returns the underlying ApppCacheURLLoaderJob if any. This only applies to
// AppCaches loaded via the URLRequest mechanism.
virtual AppCacheURLLoaderJob* AsURLLoaderJob();
void set_delivery_type(DeliveryType delivery_type) {
delivery_type_ = delivery_type;
}
protected:
AppCacheJob();
bool is_range_request() const { return range_requested_.IsValid(); }
void InitializeRangeRequestInfo(const net::HttpRequestHeaders& headers);
void SetupRangeResponse();
SEQUENCE_CHECKER(sequence_checker_);
// Set to true if the AppCache entry is not found.
bool cache_entry_not_found_;
// The jobs delivery status.
DeliveryType delivery_type_;
// Byte range request if any.
net::HttpByteRange range_requested_;
std::unique_ptr<net::HttpResponseInfo> range_response_info_;
// The response details.
scoped_refptr<AppCacheResponseInfo> info_;
// Used to read the cache.
std::unique_ptr<AppCacheResponseReader> reader_;
DISALLOW_COPY_AND_ASSIGN(AppCacheJob);
};
} // namespace content
#endif // CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_
...@@ -82,8 +82,8 @@ class CONTENT_EXPORT AppCacheRequest { ...@@ -82,8 +82,8 @@ class CONTENT_EXPORT AppCacheRequest {
protected: protected:
friend class AppCacheRequestHandler; friend class AppCacheRequestHandler;
// Enables the AppCacheJob to call GetResourceRequest(). // Enables the AppCacheURLLoader to call GetResourceRequest().
friend class AppCacheJob; friend class AppCacheURLLoader;
// Returns the underlying ResourceRequest. // Returns the underlying ResourceRequest.
network::ResourceRequest* GetResourceRequest() { return &request_; } network::ResourceRequest* GetResourceRequest() { return &request_; }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "content/browser/appcache/appcache_entry.h" #include "content/browser/appcache/appcache_entry.h"
#include "content/browser/appcache/appcache_host.h" #include "content/browser/appcache/appcache_host.h"
#include "content/browser/appcache/appcache_request_handler.h"
#include "content/browser/appcache/appcache_service_impl.h" #include "content/browser/appcache/appcache_service_impl.h"
#include "content/browser/loader/navigation_loader_interceptor.h" #include "content/browser/loader/navigation_loader_interceptor.h"
#include "content/browser/loader/single_request_url_loader_factory.h" #include "content/browser/loader/single_request_url_loader_factory.h"
...@@ -31,7 +30,7 @@ class URLRequest; ...@@ -31,7 +30,7 @@ class URLRequest;
} // namespace net } // namespace net
namespace content { namespace content {
class AppCacheJob; class AppCacheURLLoader;
class AppCacheSubresourceURLFactory; class AppCacheSubresourceURLFactory;
class AppCacheRequest; class AppCacheRequest;
class AppCacheRequestHandlerTest; class AppCacheRequestHandlerTest;
...@@ -136,9 +135,9 @@ class CONTENT_EXPORT AppCacheRequestHandler ...@@ -136,9 +135,9 @@ class CONTENT_EXPORT AppCacheRequestHandler
void DeliverNetworkResponse(); void DeliverNetworkResponse();
void DeliverErrorResponse(); void DeliverErrorResponse();
// Helper method to create an AppCacheJob and populate job_. // Helper method to create an AppCacheURLLoader and populate job_.
// Caller takes ownership of returned value. // Caller takes ownership of returned value.
std::unique_ptr<AppCacheJob> CreateJob( std::unique_ptr<AppCacheURLLoader> CreateLoader(
net::NetworkDelegate* network_delegate); net::NetworkDelegate* network_delegate);
// Helper to retrieve a pointer to the storage object. // Helper to retrieve a pointer to the storage object.
...@@ -150,11 +149,11 @@ class CONTENT_EXPORT AppCacheRequestHandler ...@@ -150,11 +149,11 @@ class CONTENT_EXPORT AppCacheRequestHandler
// These are called on each request intercept opportunity, by the various // These are called on each request intercept opportunity, by the various
// MaybeCreateLoader methods in the public API. // MaybeCreateLoader methods in the public API.
AppCacheJob* MaybeLoadResource(net::NetworkDelegate* network_delegate); AppCacheURLLoader* MaybeLoadResource(net::NetworkDelegate* network_delegate);
AppCacheJob* MaybeLoadFallbackForRedirect( AppCacheURLLoader* MaybeLoadFallbackForRedirect(
net::NetworkDelegate* network_delegate, net::NetworkDelegate* network_delegate,
const GURL& location); const GURL& location);
AppCacheJob* MaybeLoadFallbackForResponse( AppCacheURLLoader* MaybeLoadFallbackForResponse(
net::NetworkDelegate* network_delegate); net::NetworkDelegate* network_delegate);
void GetExtraResponseInfo(int64_t* cache_id, GURL* manifest_url); void GetExtraResponseInfo(int64_t* cache_id, GURL* manifest_url);
...@@ -162,7 +161,7 @@ class CONTENT_EXPORT AppCacheRequestHandler ...@@ -162,7 +161,7 @@ class CONTENT_EXPORT AppCacheRequestHandler
// Main-resource loading ------------------------------------- // Main-resource loading -------------------------------------
// Frame and SharedWorker main resources are handled here. // Frame and SharedWorker main resources are handled here.
std::unique_ptr<AppCacheJob> MaybeLoadMainResource( std::unique_ptr<AppCacheURLLoader> MaybeLoadMainResource(
net::NetworkDelegate* network_delegate); net::NetworkDelegate* network_delegate);
// AppCacheStorage::Delegate methods // AppCacheStorage::Delegate methods
...@@ -187,7 +186,7 @@ class CONTENT_EXPORT AppCacheRequestHandler ...@@ -187,7 +186,7 @@ class CONTENT_EXPORT AppCacheRequestHandler
// Sub-resource loading ------------------------------------- // Sub-resource loading -------------------------------------
// Dedicated worker and all manner of sub-resources are handled here. // Dedicated worker and all manner of sub-resources are handled here.
std::unique_ptr<AppCacheJob> MaybeLoadSubResource( std::unique_ptr<AppCacheURLLoader> MaybeLoadSubResource(
net::NetworkDelegate* network_delegate); net::NetworkDelegate* network_delegate);
void ContinueMaybeLoadSubResource(); void ContinueMaybeLoadSubResource();
...@@ -236,7 +235,7 @@ class CONTENT_EXPORT AppCacheRequestHandler ...@@ -236,7 +235,7 @@ class CONTENT_EXPORT AppCacheRequestHandler
// 1) Before request has started a job. // 1) Before request has started a job.
// 2) Request is not being handled by appcache. // 2) Request is not being handled by appcache.
// 3) Request has been cancelled, and the job killed. // 3) Request has been cancelled, and the job killed.
base::WeakPtr<AppCacheJob> job_; base::WeakPtr<AppCacheURLLoader> loader_;
// Cached information about the response being currently served by the // Cached information about the response being currently served by the
// AppCache, if there is one. // AppCache, if there is one.
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "content/browser/appcache/appcache_host.h" #include "content/browser/appcache/appcache_host.h"
#include "content/browser/appcache/appcache_request.h" #include "content/browser/appcache/appcache_request.h"
#include "content/browser/appcache/appcache_request_handler.h" #include "content/browser/appcache/appcache_request_handler.h"
#include "content/browser/appcache/appcache_url_loader_job.h"
#include "content/browser/loader/navigation_url_loader_impl.h" #include "content/browser/loader/navigation_url_loader_impl.h"
#include "content/browser/storage_partition_impl.h" #include "content/browser/storage_partition_impl.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
...@@ -74,7 +73,7 @@ class SubresourceLoader : public network::mojom::URLLoader, ...@@ -74,7 +73,7 @@ class SubresourceLoader : public network::mojom::URLLoader,
} }
private: private:
~SubresourceLoader() override {} ~SubresourceLoader() override = default;
void OnMojoDisconnect() { delete this; } void OnMojoDisconnect() { delete this; }
......
...@@ -22,7 +22,6 @@ class SharedURLLoaderFactory; ...@@ -22,7 +22,6 @@ class SharedURLLoaderFactory;
namespace content { namespace content {
class AppCacheHost; class AppCacheHost;
class AppCacheJob;
class AppCacheRequestHandler; class AppCacheRequestHandler;
class AppCacheServiceImpl; class AppCacheServiceImpl;
......
// Copyright (c) 2017 The Chromium Authors. All rights reserved. // Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_H_
#define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_H_
#include <memory>
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/strings/string16.h" #include "base/sequence_checker.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "content/browser/appcache/appcache_entry.h" #include "content/browser/appcache/appcache_entry.h"
#include "content/browser/appcache/appcache_job.h"
#include "content/browser/appcache/appcache_request_handler.h" #include "content/browser/appcache/appcache_request_handler.h"
#include "content/browser/appcache/appcache_response.h" #include "content/browser/appcache/appcache_response.h"
#include "content/browser/appcache/appcache_storage.h" #include "content/browser/appcache/appcache_storage.h"
#include "content/browser/loader/navigation_loader_interceptor.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/data_pipe.h" #include "mojo/public/cpp/system/data_pipe.h"
#include "net/http/http_byte_range.h"
#include "services/network/public/mojom/url_loader.mojom-forward.h" #include "services/network/public/mojom/url_loader.mojom-forward.h"
#include "third_party/blink/public/mojom/appcache/appcache_info.mojom-forward.h"
#include "url/gurl.h"
namespace net {
class HttpRequestHeaders;
class HttpResponseInfo;
} // namespace net
namespace network { namespace network {
class NetToMojoPendingBuffer; class NetToMojoPendingBuffer;
...@@ -31,23 +39,30 @@ class NetToMojoPendingBuffer; ...@@ -31,23 +39,30 @@ class NetToMojoPendingBuffer;
namespace content { namespace content {
class AppCacheRequest; class AppCacheRequest;
class AppCacheResponseInfo;
class AppCacheResponseReader;
// AppCacheJob wrapper for a network::mojom::URLLoader implementation which // network::mojom::URLLoader that retrieves responses stored in an AppCache.
// returns responses stored in the AppCache. class CONTENT_EXPORT AppCacheURLLoader : public AppCacheStorage::Delegate,
class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob, public network::mojom::URLLoader {
public AppCacheStorage::Delegate,
public network::mojom::URLLoader {
public: public:
enum class DeliveryType {
kAwaitingDeliverCall,
kAppCached,
kNetwork,
kError,
};
// Use AppCacheRequestHandler::CreateJob() instead of calling the constructor // Use AppCacheRequestHandler::CreateJob() instead of calling the constructor
// directly. // directly.
// //
// The constructor is exposed for std::make_unique. // The constructor is exposed for std::make_unique.
AppCacheURLLoaderJob( AppCacheURLLoader(
AppCacheRequest* appcache_request, AppCacheRequest* appcache_request,
AppCacheStorage* storage, AppCacheStorage* storage,
AppCacheRequestHandler::AppCacheLoaderCallback loader_callback); AppCacheRequestHandler::AppCacheLoaderCallback loader_callback);
~AppCacheURLLoaderJob() override; ~AppCacheURLLoader() override;
// Sets up the bindings. // Sets up the bindings.
void Start(base::OnceClosure continuation, void Start(base::OnceClosure continuation,
...@@ -55,19 +70,64 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob, ...@@ -55,19 +70,64 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob,
mojo::PendingReceiver<network::mojom::URLLoader> receiver, mojo::PendingReceiver<network::mojom::URLLoader> receiver,
mojo::PendingRemote<network::mojom::URLLoaderClient> client); mojo::PendingRemote<network::mojom::URLLoaderClient> client);
// AppCacheJob overrides. // True if the loader was started.
bool IsStarted() const override; bool IsStarted() const;
// True if the loader is waiting for instructions.
bool IsWaiting() const {
return delivery_type_ == DeliveryType::kAwaitingDeliverCall;
}
// True if the loader is delivering a response from the cache.
bool IsDeliveringAppCacheResponse() const {
return delivery_type_ == DeliveryType::kAppCached;
}
// True if the loader is delivering a response from the network.
bool IsDeliveringNetworkResponse() const {
return delivery_type_ == DeliveryType::kNetwork;
}
// True if the loader is delivering an error response.
bool IsDeliveringErrorResponse() const {
return delivery_type_ == DeliveryType::kError;
}
void set_delivery_type(DeliveryType delivery_type) {
delivery_type_ = delivery_type;
}
// True if the cache entry was not found in the cache.
bool IsCacheEntryNotFound() const { return cache_entry_not_found_; }
// Informs the loader of what response it should deliver.
//
// Each loader should receive exactly one call to a Deliver*() method. Loaders
// will sit idle and wait indefinitely until one of the Deliver*() methods is
// called.
void DeliverAppCachedResponse(const GURL& manifest_url, void DeliverAppCachedResponse(const GURL& manifest_url,
int64_t cache_id, int64_t cache_id,
const AppCacheEntry& entry, const AppCacheEntry& entry,
bool is_fallback) override; bool is_fallback);
void DeliverNetworkResponse() override;
void DeliverErrorResponse() override; // Informs the loader that it should deliver the response from the network.
AppCacheURLLoaderJob* AsURLLoaderJob() override; // This is generally controlled by the entries in the manifest file.
base::WeakPtr<AppCacheJob> GetWeakPtr() override; //
base::WeakPtr<AppCacheURLLoaderJob> GetDerivedWeakPtr(); // Each loader should receive exactly one call to a Deliver*() method. Loaders
// will sit idle and wait indefinitely until one of the Deliver*() methods is
// network::mojom::URLLoader implementation: // called.
void DeliverNetworkResponse();
// Informs the loader that it should deliver an error response.
//
// Each loader should receive exactly one call to a Deliver*() method. Loaders
// will sit idle and wait indefinitely until one of the Deliver*() methods is
// called.
void DeliverErrorResponse();
base::WeakPtr<AppCacheURLLoader> GetWeakPtr();
// network::mojom::URLLoader:
void FollowRedirect(const std::vector<std::string>& removed_headers, void FollowRedirect(const std::vector<std::string>& removed_headers,
const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_headers,
const base::Optional<GURL>& new_url) override; const base::Optional<GURL>& new_url) override;
...@@ -78,13 +138,19 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob, ...@@ -78,13 +138,19 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob,
void DeleteIfNeeded(); void DeleteIfNeeded();
protected: private:
bool is_range_request() const { return range_requested_.IsValid(); }
void InitializeRangeRequestInfo(const net::HttpRequestHeaders& headers);
void SetupRangeResponse();
// Invokes the loader callback which is expected to setup the mojo binding. // Invokes the loader callback which is expected to setup the mojo binding.
void CallLoaderCallback(base::OnceClosure continuation); void CallLoaderCallback(base::OnceClosure continuation);
// AppCacheStorage::Delegate methods // AppCacheStorage::Delegate:
void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, void OnResponseInfoLoaded(AppCacheResponseInfo* response_info,
int64_t response_id) override; int64_t response_id) override;
void ContinueOnResponseInfoLoaded( void ContinueOnResponseInfoLoaded(
scoped_refptr<AppCacheResponseInfo> response_info); scoped_refptr<AppCacheResponseInfo> response_info);
...@@ -102,6 +168,23 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob, ...@@ -102,6 +168,23 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob,
void ReadMore(); void ReadMore();
void NotifyCompleted(int error_code); void NotifyCompleted(int error_code);
// True if the AppCache entry is not found.
bool cache_entry_not_found_ = false;
// The loader's delivery status.
DeliveryType delivery_type_ = DeliveryType::kAwaitingDeliverCall;
// Byte range request if any.
net::HttpByteRange range_requested_;
std::unique_ptr<net::HttpResponseInfo> range_response_info_;
// The response details.
scoped_refptr<AppCacheResponseInfo> info_;
// Used to read the cache.
std::unique_ptr<AppCacheResponseReader> reader_;
base::WeakPtr<AppCacheStorage> storage_; base::WeakPtr<AppCacheStorage> storage_;
// Time when the request started. // Time when the request started.
...@@ -112,9 +195,9 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob, ...@@ -112,9 +195,9 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob,
net::LoadTimingInfo load_timing_info_; net::LoadTimingInfo load_timing_info_;
GURL manifest_url_; GURL manifest_url_;
int64_t cache_id_; int64_t cache_id_ = blink::mojom::kAppCacheNoCacheId;
AppCacheEntry entry_; AppCacheEntry entry_;
bool is_fallback_; bool is_fallback_ = false;
// Receiver of the URLLoaderClient with us. // Receiver of the URLLoaderClient with us.
mojo::Receiver<network::mojom::URLLoader> receiver_{this}; mojo::Receiver<network::mojom::URLLoader> receiver_{this};
...@@ -135,15 +218,17 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob, ...@@ -135,15 +218,17 @@ class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob,
// The AppCacheRequest instance, used to inform the loader job about range // The AppCacheRequest instance, used to inform the loader job about range
// request headers. Not owned by this class. // request headers. Not owned by this class.
base::WeakPtr<AppCacheRequest> appcache_request_; const base::WeakPtr<AppCacheRequest> appcache_request_;
bool is_deleting_soon_ = false; bool is_deleting_soon_ = false;
bool is_main_resource_load_; const bool is_main_resource_load_;
SEQUENCE_CHECKER(sequence_checker_);
base::WeakPtrFactory<AppCacheURLLoaderJob> weak_factory_{this}; base::WeakPtrFactory<AppCacheURLLoader> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoader);
}; };
} // namespace content } // namespace content
#endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment