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

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

Issue 1647323002: Move activate event dispatching out of ServiceWorkerVersion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-install-event
Patch Set: address comments Created 4 years, 10 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
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // FinishRequest before passing the reply to the callback. 234 // FinishRequest before passing the reply to the callback.
235 template <typename ResponseMessage> 235 template <typename ResponseMessage>
236 void DispatchSimpleEvent(int request_id, const IPC::Message& message); 236 void DispatchSimpleEvent(int request_id, const IPC::Message& message);
237 237
238 // Sends a message event to the associated embedded worker. 238 // Sends a message event to the associated embedded worker.
239 void DispatchMessageEvent( 239 void DispatchMessageEvent(
240 const base::string16& message, 240 const base::string16& message,
241 const std::vector<TransferredMessagePort>& sent_message_ports, 241 const std::vector<TransferredMessagePort>& sent_message_ports,
242 const StatusCallback& callback); 242 const StatusCallback& callback);
243 243
244 // Sends activate event to the associated embedded worker and asynchronously
245 // calls |callback| when it errors out or it gets a response from the worker
246 // to notify activation completion.
247 //
248 // This must be called when the status() is INSTALLED. Calling this changes
249 // the version's status to ACTIVATING.
250 // Upon completion, the version's status will be changed to ACTIVATED
251 // on success, or back to INSTALLED on failure.
252 void DispatchActivateEvent(const StatusCallback& callback);
253
254 // Sends fetch event to the associated embedded worker and calls 244 // Sends fetch event to the associated embedded worker and calls
255 // |callback| with the response from the worker. 245 // |callback| with the response from the worker.
256 // 246 //
257 // This must be called when the status() is ACTIVATED. Calling this in other 247 // This must be called when the status() is ACTIVATED. Calling this in other
258 // statuses will result in an error SERVICE_WORKER_ERROR_FAILED. 248 // statuses will result in an error SERVICE_WORKER_ERROR_FAILED.
259 void DispatchFetchEvent(const ServiceWorkerFetchRequest& request, 249 void DispatchFetchEvent(const ServiceWorkerFetchRequest& request,
260 const base::Closure& prepare_callback, 250 const base::Closure& prepare_callback,
261 const FetchCallback& fetch_callback); 251 const FetchCallback& fetch_callback);
262 252
263 // Sends a cross origin message event to the associated embedded worker and 253 // Sends a cross origin message event to the associated embedded worker and
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, RequestCustomizedTimeout); 367 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, RequestCustomizedTimeout);
378 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, 368 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest,
379 RequestCustomizedTimeoutKill); 369 RequestCustomizedTimeoutKill);
380 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWaitForeverInFetchTest, 370 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWaitForeverInFetchTest,
381 MixedRequestTimeouts); 371 MixedRequestTimeouts);
382 372
383 class Metrics; 373 class Metrics;
384 class PingController; 374 class PingController;
385 375
386 enum RequestType { 376 enum RequestType {
387 REQUEST_ACTIVATE,
388 REQUEST_FETCH, 377 REQUEST_FETCH,
389 REQUEST_CUSTOM, 378 REQUEST_CUSTOM,
390 NUM_REQUEST_TYPES 379 NUM_REQUEST_TYPES
391 }; 380 };
392 381
393 struct RequestInfo { 382 struct RequestInfo {
394 RequestInfo(int id, 383 RequestInfo(int id,
395 RequestType type, 384 RequestType type,
396 ServiceWorkerMetrics::EventType event_type, 385 ServiceWorkerMetrics::EventType event_type,
397 const base::TimeTicks& expiration, 386 const base::TimeTicks& expiration,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 const GURL& source_url) override; 507 const GURL& source_url) override;
519 void OnReportConsoleMessage(int source_identifier, 508 void OnReportConsoleMessage(int source_identifier,
520 int message_level, 509 int message_level,
521 const base::string16& message, 510 const base::string16& message,
522 int line_number, 511 int line_number,
523 const GURL& source_url) override; 512 const GURL& source_url) override;
524 bool OnMessageReceived(const IPC::Message& message) override; 513 bool OnMessageReceived(const IPC::Message& message) override;
525 514
526 void OnStartSentAndScriptEvaluated(ServiceWorkerStatusCode status); 515 void OnStartSentAndScriptEvaluated(ServiceWorkerStatusCode status);
527 516
528 void DispatchActivateEventAfterStartWorker(const StatusCallback& callback);
529
530 void DispatchMessageEventInternal( 517 void DispatchMessageEventInternal(
531 const base::string16& message, 518 const base::string16& message,
532 const std::vector<TransferredMessagePort>& sent_message_ports, 519 const std::vector<TransferredMessagePort>& sent_message_ports,
533 const StatusCallback& callback); 520 const StatusCallback& callback);
534 521
535 // Message handlers. 522 // Message handlers.
536 523
537 // This corresponds to the spec's matchAll(options) steps. 524 // This corresponds to the spec's matchAll(options) steps.
538 void OnGetClients(int request_id, 525 void OnGetClients(int request_id,
539 const ServiceWorkerClientQueryOptions& options); 526 const ServiceWorkerClientQueryOptions& options);
540 527
541 void OnActivateEventFinished(int request_id,
542 blink::WebServiceWorkerEventResult result);
543 void OnFetchEventFinished(int request_id, 528 void OnFetchEventFinished(int request_id,
544 ServiceWorkerFetchEventResult result, 529 ServiceWorkerFetchEventResult result,
545 const ServiceWorkerResponse& response); 530 const ServiceWorkerResponse& response);
546 void OnSimpleEventResponse(int request_id, 531 void OnSimpleEventResponse(int request_id,
547 blink::WebServiceWorkerEventResult result); 532 blink::WebServiceWorkerEventResult result);
548 void OnOpenWindow(int request_id, GURL url); 533 void OnOpenWindow(int request_id, GURL url);
549 void OnOpenWindowFinished(int request_id, 534 void OnOpenWindowFinished(int request_id,
550 ServiceWorkerStatusCode status, 535 ServiceWorkerStatusCode status,
551 const std::string& client_uuid, 536 const std::string& client_uuid,
552 const ServiceWorkerClientInfo& client_info); 537 const ServiceWorkerClientInfo& client_info);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 std::vector<GURL> foreign_fetch_scopes_; 646 std::vector<GURL> foreign_fetch_scopes_;
662 647
663 Status status_ = NEW; 648 Status status_ = NEW;
664 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; 649 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_;
665 std::vector<StatusCallback> start_callbacks_; 650 std::vector<StatusCallback> start_callbacks_;
666 std::vector<StatusCallback> stop_callbacks_; 651 std::vector<StatusCallback> stop_callbacks_;
667 std::vector<base::Closure> status_change_callbacks_; 652 std::vector<base::Closure> status_change_callbacks_;
668 653
669 // Message callbacks. (Update HasInflightRequests() too when you update this 654 // Message callbacks. (Update HasInflightRequests() too when you update this
670 // list.) 655 // list.)
671 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> activate_requests_;
672 IDMap<PendingRequest<FetchCallback>, IDMapOwnPointer> fetch_requests_; 656 IDMap<PendingRequest<FetchCallback>, IDMapOwnPointer> fetch_requests_;
673 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> custom_requests_; 657 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> custom_requests_;
674 658
675 // Stores all open connections to mojo services. Maps the service name to 659 // Stores all open connections to mojo services. Maps the service name to
676 // the actual interface pointer. When a connection is closed it is removed 660 // the actual interface pointer. When a connection is closed it is removed
677 // from this map. 661 // from this map.
678 // mojo_services_[Interface::Name_] is assumed to always contain a 662 // mojo_services_[Interface::Name_] is assumed to always contain a
679 // MojoServiceWrapper<Interface> instance. 663 // MojoServiceWrapper<Interface> instance.
680 base::ScopedPtrHashMap<const char*, scoped_ptr<BaseMojoServiceWrapper>> 664 base::ScopedPtrHashMap<const char*, scoped_ptr<BaseMojoServiceWrapper>>
681 mojo_services_; 665 mojo_services_;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 792
809 // At this point |this| can have been deleted, so don't do anything other 793 // At this point |this| can have been deleted, so don't do anything other
810 // than returning. 794 // than returning.
811 795
812 return true; 796 return true;
813 } 797 }
814 798
815 } // namespace content 799 } // namespace content
816 800
817 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 801 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698