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

Unified Diff: content/browser/service_worker/service_worker_write_to_cache_job.h

Issue 1351423002: Revert of ServiceWorkerWriteToCacheJob: refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_write_to_cache_job.h
diff --git a/content/browser/service_worker/service_worker_write_to_cache_job.h b/content/browser/service_worker/service_worker_write_to_cache_job.h
index 9874001b4e3f3618750a9bfddeaa4c266d380f1e..38b040d3168ea09c4ba714b6bbd441f766249e94 100644
--- a/content/browser/service_worker/service_worker_write_to_cache_job.h
+++ b/content/browser/service_worker/service_worker_write_to_cache_job.h
@@ -14,14 +14,13 @@
#include "content/common/service_worker/service_worker_status_code.h"
#include "content/common/service_worker/service_worker_types.h"
#include "content/public/common/resource_type.h"
-#include "net/base/net_errors.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_job.h"
namespace content {
-class ServiceWorkerCacheWriter;
class ServiceWorkerContextCore;
+class ServiceWorkerResponseWriter;
class ServiceWorkerVersions;
// A URLRequestJob derivative used to cache the main script
@@ -58,6 +57,10 @@
UpdateAfter24Hours);
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest,
UpdateForceBypassCache);
+ class NetDataConsumer;
+ class PassThroughConsumer;
+ class Comparer;
+ class Copier;
~ServiceWorkerWriteToCacheJob() override;
@@ -82,12 +85,14 @@
int buf_size,
int* bytes_read);
- // Callbacks for writing headers and data via |cache_writer_|. Note that since
- // the MaybeWriteHeaders and MaybeWriteData methods on |cache_writer_| are
- // guaranteed not to do short writes, these functions only receive a
- // net::Error indicating success or failure, not a count of bytes written.
- void OnWriteHeadersComplete(net::Error error);
- void OnWriteDataComplete(net::Error error);
+ void CommitHeadersAndNotifyHeadersComplete();
+ void WriteHeaders(const base::Closure& callback);
+ void OnWriteHeadersComplete(const base::Closure& callback, int result);
+ void WriteData(net::IOBuffer* buf,
+ int amount_to_write,
+ const base::Callback<void(int result)>& callback);
+ void OnWriteDataComplete(const base::Callback<void(int result)>& callback,
+ int result);
// net::URLRequest::Delegate overrides that observe the net request.
void OnReceivedRedirect(net::URLRequest* request,
@@ -107,22 +112,19 @@
bool CheckPathRestriction(net::URLRequest* request);
- // Writes network data back to the script cache if needed, and notifies the
- // script cache of fetch completion at EOF. This function might need to do
- // asynchronous IO; if so, it signals this through setting the URLRequestJob's
- // status to IO_PENDING. After this function returns, if the URLRequestJob
- // isn't IO_PENDING, all of the data in |io_buffer_| has been written back to
- // the script cache if necessary.
+ void SetPendingIO();
+ void ClearPendingIO();
+ void OnPassThroughComplete();
+ void OnCompareComplete(int bytes_matched, bool is_equal);
+ void CopyIncumbent(int bytes_to_copy);
+ void OnCopyComplete(ServiceWorkerStatusCode status);
void HandleNetData(int bytes_read);
- void NotifyDoneHelper(const net::URLRequestStatus& status,
- const std::string& status_message);
+ void AsyncNotifyDoneHelper(const net::URLRequestStatus& status,
+ const std::string& status_message);
void NotifyFinishedCaching(net::URLRequestStatus status,
const std::string& status_message);
-
- scoped_ptr<ServiceWorkerResponseReader> CreateCacheResponseReader();
- scoped_ptr<ServiceWorkerResponseWriter> CreateCacheResponseWriter();
ResourceType resource_type_; // Differentiate main script and imports
scoped_refptr<net::IOBuffer> io_buffer_;
@@ -135,7 +137,7 @@
scoped_ptr<net::HttpResponseInfo> http_info_;
scoped_ptr<ServiceWorkerResponseWriter> writer_;
scoped_refptr<ServiceWorkerVersion> version_;
- scoped_ptr<ServiceWorkerCacheWriter> cache_writer_;
+ scoped_ptr<NetDataConsumer> consumer_;
bool has_been_killed_;
bool did_notify_started_;
bool did_notify_finished_;

Powered by Google App Engine
This is Rietveld 408576698