Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 | 130 |
| 131 int64_t version_id() const { return version_id_; } | 131 int64_t version_id() const { return version_id_; } |
| 132 int64_t registration_id() const { return registration_id_; } | 132 int64_t registration_id() const { return registration_id_; } |
| 133 const GURL& script_url() const { return script_url_; } | 133 const GURL& script_url() const { return script_url_; } |
| 134 const GURL& scope() const { return scope_; } | 134 const GURL& scope() const { return scope_; } |
| 135 RunningStatus running_status() const { | 135 RunningStatus running_status() const { |
| 136 return static_cast<RunningStatus>(embedded_worker_->status()); | 136 return static_cast<RunningStatus>(embedded_worker_->status()); |
| 137 } | 137 } |
| 138 ServiceWorkerVersionInfo GetInfo(); | 138 ServiceWorkerVersionInfo GetInfo(); |
| 139 Status status() const { return status_; } | 139 Status status() const { return status_; } |
| 140 bool has_fetch_handler() const { return has_fetch_handler_; } | |
| 141 void set_has_fetch_handler(bool has_fetch_handler) { | |
| 142 has_fetch_handler_ = has_fetch_handler; | |
| 143 } | |
| 140 | 144 |
| 141 const std::vector<GURL>& foreign_fetch_scopes() const { | 145 const std::vector<GURL>& foreign_fetch_scopes() const { |
| 142 return foreign_fetch_scopes_; | 146 return foreign_fetch_scopes_; |
| 143 } | 147 } |
| 144 void set_foreign_fetch_scopes(const std::vector<GURL>& scopes) { | 148 void set_foreign_fetch_scopes(const std::vector<GURL>& scopes) { |
| 145 foreign_fetch_scopes_ = scopes; | 149 foreign_fetch_scopes_ = scopes; |
| 146 } | 150 } |
| 147 | 151 |
| 148 const std::vector<url::Origin>& foreign_fetch_origins() const { | 152 const std::vector<url::Origin>& foreign_fetch_origins() const { |
| 149 return foreign_fetch_origins_; | 153 return foreign_fetch_origins_; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 | 245 |
| 242 // For simple events where the full functionality of DispatchEvent is not | 246 // For simple events where the full functionality of DispatchEvent is not |
| 243 // needed, this method can be used instead. The ResponseMessage must consist | 247 // needed, this method can be used instead. The ResponseMessage must consist |
| 244 // of just a request_id and a blink::WebServiceWorkerEventResult field. The | 248 // of just a request_id and a blink::WebServiceWorkerEventResult field. The |
| 245 // result is converted to a ServiceWorkerStatusCode and passed to the error | 249 // result is converted to a ServiceWorkerStatusCode and passed to the error |
| 246 // handler associated with the request. Additionally this methods calls | 250 // handler associated with the request. Additionally this methods calls |
| 247 // FinishRequest before passing the reply to the callback. | 251 // FinishRequest before passing the reply to the callback. |
| 248 template <typename ResponseMessage> | 252 template <typename ResponseMessage> |
| 249 void DispatchSimpleEvent(int request_id, const IPC::Message& message); | 253 void DispatchSimpleEvent(int request_id, const IPC::Message& message); |
| 250 | 254 |
| 255 // For install event, the callback should be specialized to update the stat | |
| 256 // of version object because |has_fetch_handler| should be set corresponding | |
| 257 // to the result of script evaluation. | |
|
falken
2016/05/23 08:41:13
I think DispatchEvent() (not DispatchSimpleEvent)
shimazu
2016/05/23 10:44:24
I considered has_fetch_handler is a property which
falken
2016/05/24 01:15:34
But SWVersion is kind of transient: it can be dest
shimazu
2016/05/24 04:17:46
Thanks. Done.
| |
| 258 void DispatchInstallEvent(int request_id); | |
| 259 | |
| 251 // Adds and removes |provider_host| as a controllee of this ServiceWorker. | 260 // Adds and removes |provider_host| as a controllee of this ServiceWorker. |
| 252 // A potential controllee is a host having the version as its .installing | 261 // A potential controllee is a host having the version as its .installing |
| 253 // or .waiting version. | 262 // or .waiting version. |
| 254 void AddControllee(ServiceWorkerProviderHost* provider_host); | 263 void AddControllee(ServiceWorkerProviderHost* provider_host); |
| 255 void RemoveControllee(ServiceWorkerProviderHost* provider_host); | 264 void RemoveControllee(ServiceWorkerProviderHost* provider_host); |
| 256 | 265 |
| 257 // Returns if it has controllee. | 266 // Returns if it has controllee. |
| 258 bool HasControllee() const { return !controllee_map_.empty(); } | 267 bool HasControllee() const { return !controllee_map_.empty(); } |
| 259 std::map<std::string, ServiceWorkerProviderHost*> controllee_map() { | 268 std::map<std::string, ServiceWorkerProviderHost*> controllee_map() { |
| 260 return controllee_map_; | 269 return controllee_map_; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 | 502 |
| 494 // This corresponds to the spec's get(id) steps. | 503 // This corresponds to the spec's get(id) steps. |
| 495 void OnGetClient(int request_id, const std::string& client_uuid); | 504 void OnGetClient(int request_id, const std::string& client_uuid); |
| 496 | 505 |
| 497 // This corresponds to the spec's matchAll(options) steps. | 506 // This corresponds to the spec's matchAll(options) steps. |
| 498 void OnGetClients(int request_id, | 507 void OnGetClients(int request_id, |
| 499 const ServiceWorkerClientQueryOptions& options); | 508 const ServiceWorkerClientQueryOptions& options); |
| 500 | 509 |
| 501 void OnSimpleEventResponse(int request_id, | 510 void OnSimpleEventResponse(int request_id, |
| 502 blink::WebServiceWorkerEventResult result); | 511 blink::WebServiceWorkerEventResult result); |
| 512 void OnInstallEventResponse(int request_id, | |
| 513 blink::WebServiceWorkerEventResult result, | |
| 514 bool has_fetch_handler); | |
| 503 void OnOpenWindow(int request_id, GURL url); | 515 void OnOpenWindow(int request_id, GURL url); |
| 504 void OnOpenWindowFinished(int request_id, | 516 void OnOpenWindowFinished(int request_id, |
| 505 ServiceWorkerStatusCode status, | 517 ServiceWorkerStatusCode status, |
| 506 const ServiceWorkerClientInfo& client_info); | 518 const ServiceWorkerClientInfo& client_info); |
| 507 | 519 |
| 508 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); | 520 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); |
| 509 void OnSetCachedMetadataFinished(int64_t callback_id, int result); | 521 void OnSetCachedMetadataFinished(int64_t callback_id, int result); |
| 510 void OnClearCachedMetadata(const GURL& url); | 522 void OnClearCachedMetadata(const GURL& url); |
| 511 void OnClearCachedMetadataFinished(int64_t callback_id, int result); | 523 void OnClearCachedMetadataFinished(int64_t callback_id, int result); |
| 512 | 524 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 // the time elapsed since idle (generally the time since the previous | 608 // the time elapsed since idle (generally the time since the previous |
| 597 // event ended). | 609 // event ended). |
| 598 void OnBeginEvent(); | 610 void OnBeginEvent(); |
| 599 | 611 |
| 600 const int64_t version_id_; | 612 const int64_t version_id_; |
| 601 const int64_t registration_id_; | 613 const int64_t registration_id_; |
| 602 const GURL script_url_; | 614 const GURL script_url_; |
| 603 const GURL scope_; | 615 const GURL scope_; |
| 604 std::vector<GURL> foreign_fetch_scopes_; | 616 std::vector<GURL> foreign_fetch_scopes_; |
| 605 std::vector<url::Origin> foreign_fetch_origins_; | 617 std::vector<url::Origin> foreign_fetch_origins_; |
| 618 bool has_fetch_handler_ = true; | |
| 606 | 619 |
| 607 Status status_ = NEW; | 620 Status status_ = NEW; |
| 608 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; | 621 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; |
| 609 std::vector<StatusCallback> start_callbacks_; | 622 std::vector<StatusCallback> start_callbacks_; |
| 610 std::vector<StatusCallback> stop_callbacks_; | 623 std::vector<StatusCallback> stop_callbacks_; |
| 611 std::vector<base::Closure> status_change_callbacks_; | 624 std::vector<base::Closure> status_change_callbacks_; |
| 612 | 625 |
| 613 // Message callbacks. (Update HasInflightRequests() too when you update this | 626 // Message callbacks. (Update HasInflightRequests() too when you update this |
| 614 // list.) | 627 // list.) |
| 615 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> custom_requests_; | 628 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> custom_requests_; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 | 764 |
| 752 // At this point |this| can have been deleted, so don't do anything other | 765 // At this point |this| can have been deleted, so don't do anything other |
| 753 // than returning. | 766 // than returning. |
| 754 | 767 |
| 755 return true; | 768 return true; |
| 756 } | 769 } |
| 757 | 770 |
| 758 } // namespace content | 771 } // namespace content |
| 759 | 772 |
| 760 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 773 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
| OLD | NEW |