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

Side by Side Diff: content/browser/service_worker/service_worker_version.h

Issue 2114893002: service worker: Clean up fetch event if URLRequest gets cancelled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revise Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_url_request_job_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <functional> 10 #include <functional>
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // Starts the worker if it isn't already running, and calls |task| when the 185 // Starts the worker if it isn't already running, and calls |task| when the
186 // worker is running, or |error_callback| if starting the worker failed. 186 // worker is running, or |error_callback| if starting the worker failed.
187 // If the worker is already running, |task| is executed synchronously (before 187 // If the worker is already running, |task| is executed synchronously (before
188 // this method returns). 188 // this method returns).
189 // |purpose| is used for UMA. 189 // |purpose| is used for UMA.
190 void RunAfterStartWorker(ServiceWorkerMetrics::EventType purpose, 190 void RunAfterStartWorker(ServiceWorkerMetrics::EventType purpose,
191 const base::Closure& task, 191 const base::Closure& task,
192 const StatusCallback& error_callback); 192 const StatusCallback& error_callback);
193 193
194 // Call this while the worker is running before dispatching an event to the 194 // Call this while the worker is running before dispatching an event to the
195 // worker. This informs ServiceWorkerVersion about the event in progress. 195 // worker. This informs ServiceWorkerVersion about the event in progress. The
196 // Returns a request id, which should later be passed to FinishRequest when 196 // worker attempts to keep running until the event finishes.
197 // the event finished. 197 //
198 // Returns a request id, which must later be passed to FinishRequest when the
199 // event finished. The caller is responsible for ensuring FinishRequest is
200 // called. If FinishRequest is not called the request will eventually time
201 // out and the worker will be forcibly terminated.
202 //
198 // The |error_callback| is called if either ServiceWorkerVersion decides the 203 // The |error_callback| is called if either ServiceWorkerVersion decides the
199 // event is taking too long, or if for some reason the worker stops or is 204 // event is taking too long, or if for some reason the worker stops or is
200 // killed before the request finishes. 205 // killed before the request finishes. In this case, the caller should not
206 // call FinishRequest.
201 int StartRequest(ServiceWorkerMetrics::EventType event_type, 207 int StartRequest(ServiceWorkerMetrics::EventType event_type,
202 const StatusCallback& error_callback); 208 const StatusCallback& error_callback);
203 209
204 // Same as StartRequest, but allows the caller to specify a custom timeout for 210 // Same as StartRequest, but allows the caller to specify a custom timeout for
205 // the event, as well as the behavior for when the request times out. 211 // the event, as well as the behavior for when the request times out.
206 int StartRequestWithCustomTimeout(ServiceWorkerMetrics::EventType event_type, 212 int StartRequestWithCustomTimeout(ServiceWorkerMetrics::EventType event_type,
207 const StatusCallback& error_callback, 213 const StatusCallback& error_callback,
208 const base::TimeDelta& timeout, 214 const base::TimeDelta& timeout,
209 TimeoutBehavior timeout_behavior); 215 TimeoutBehavior timeout_behavior);
210 216
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 TimeoutWorkerInEvent); 372 TimeoutWorkerInEvent);
367 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerStallInStoppingTest, DetachThenStart); 373 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerStallInStoppingTest, DetachThenStart);
368 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerStallInStoppingTest, DetachThenRestart); 374 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerStallInStoppingTest, DetachThenRestart);
369 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, 375 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest,
370 RegisterForeignFetchScopes); 376 RegisterForeignFetchScopes);
371 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, RequestCustomizedTimeout); 377 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, RequestCustomizedTimeout);
372 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, 378 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest,
373 RequestCustomizedTimeoutKill); 379 RequestCustomizedTimeoutKill);
374 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, MixedRequestTimeouts); 380 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, MixedRequestTimeouts);
375 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerURLRequestJobTest, EarlyResponse); 381 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerURLRequestJobTest, EarlyResponse);
382 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerURLRequestJobTest, CancelRequest);
376 383
377 class Metrics; 384 class Metrics;
378 class PingController; 385 class PingController;
379 386
380 struct RequestInfo { 387 struct RequestInfo {
381 RequestInfo(int id, 388 RequestInfo(int id,
382 ServiceWorkerMetrics::EventType event_type, 389 ServiceWorkerMetrics::EventType event_type,
383 const base::TimeTicks& expiration, 390 const base::TimeTicks& expiration,
384 TimeoutBehavior timeout_behavior); 391 TimeoutBehavior timeout_behavior);
385 ~RequestInfo(); 392 ~RequestInfo();
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 783
777 // At this point |this| can have been deleted, so don't do anything other 784 // At this point |this| can have been deleted, so don't do anything other
778 // than returning. 785 // than returning.
779 786
780 return true; 787 return true;
781 } 788 }
782 789
783 } // namespace content 790 } // namespace content
784 791
785 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 792 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_url_request_job_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698