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

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

Issue 2034663002: ServiceWorker: Keep the worker alive until FetchEvent.waitUntil settles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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_version.h
diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h
index 9b88f791b286971ad5e1ad1853fa8260df2dfe62..bf9941f478e7253896c00d1f2a96e5a87bceb243 100644
--- a/content/browser/service_worker/service_worker_version.h
+++ b/content/browser/service_worker/service_worker_version.h
@@ -65,7 +65,9 @@ class CONTENT_EXPORT ServiceWorkerVersion
: NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>),
public EmbeddedWorkerInstance::Listener {
public:
- typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback;
+ using StatusCallback = base::Callback<void(ServiceWorkerStatusCode)>;
+ using FetchResponseCallback = base::Callback<
+ void(int, ServiceWorkerFetchEventResult, const ServiceWorkerResponse&)>;
enum RunningStatus {
STOPPED = EmbeddedWorkerInstance::STOPPED,
@@ -252,6 +254,14 @@ class CONTENT_EXPORT ServiceWorkerVersion
template <typename ResponseMessage>
void DispatchSimpleEvent(int request_id, const IPC::Message& message);
+ // For fetch event, response is returned earlier than the event is done.
+ // In order to handle the both (response and the end of event),
+ // DispatchFetchEvent takes two request ids and handles each callbacks.
+ void DispatchFetchEvent(int response_request_id,
Marijn Kruisselbrink 2016/06/02 16:58:55 It seems very unfortunate to go back to having cod
+ int event_request_id,
+ const ServiceWorkerFetchRequest& fetch_request,
+ const FetchResponseCallback& callback);
+
// Adds and removes |provider_host| as a controllee of this ServiceWorker.
// A potential controllee is a host having the version as its .installing
// or .waiting version.
@@ -355,6 +365,7 @@ class CONTENT_EXPORT ServiceWorkerVersion
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest,
RequestCustomizedTimeoutKill);
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, MixedRequestTimeouts);
+ FRIEND_TEST_ALL_PREFIXES(ServiceWorkerURLRequestJobTest, EarlyResponse);
class Metrics;
class PingController;
@@ -432,6 +443,8 @@ class CONTENT_EXPORT ServiceWorkerVersion
std::priority_queue<RequestInfo,
std::vector<RequestInfo>,
std::greater<RequestInfo>>;
+ using WebStatusCallback =
+ base::Callback<void(int, blink::WebServiceWorkerEventResult)>;
// EmbeddedWorkerInstance Listener implementation which calls a callback
// on receiving a particular IPC message. ResponseMessage is the type of

Powered by Google App Engine
This is Rietveld 408576698