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_PROVIDER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return running_hosted_version_ != NULL; | 48 return running_hosted_version_ != NULL; |
49 } | 49 } |
50 | 50 |
51 // The service worker version that corresponds with | 51 // The service worker version that corresponds with |
52 // navigator.serviceWorker.active for our document. | 52 // navigator.serviceWorker.active for our document. |
53 ServiceWorkerVersion* active_version() const { | 53 ServiceWorkerVersion* active_version() const { |
54 return active_version_.get(); | 54 return active_version_.get(); |
55 } | 55 } |
56 | 56 |
57 // The service worker version that corresponds with | 57 // The service worker version that corresponds with |
58 // navigate.serviceWorker.pending for our document. | 58 // navigate.serviceWorker.waiting for our document. |
59 ServiceWorkerVersion* pending_version() const { | 59 ServiceWorkerVersion* waiting_version() const { |
60 return pending_version_.get(); | 60 return waiting_version_.get(); |
61 } | 61 } |
62 | 62 |
63 // The running version, if any, that this provider is providing resource | 63 // The running version, if any, that this provider is providing resource |
64 // loads for. | 64 // loads for. |
65 ServiceWorkerVersion* running_hosted_version() const { | 65 ServiceWorkerVersion* running_hosted_version() const { |
66 return running_hosted_version_.get(); | 66 return running_hosted_version_.get(); |
67 } | 67 } |
68 | 68 |
69 void set_document_url(const GURL& url) { document_url_ = url; } | 69 void set_document_url(const GURL& url) { document_url_ = url; } |
70 const GURL& document_url() const { return document_url_; } | 70 const GURL& document_url() const { return document_url_; } |
71 | 71 |
72 // Associate |version| to this provider as its '.active' or '.pending' | 72 // Associate |version| to this provider as its '.active' or '.waiting' |
73 // version. | 73 // version. |
74 // Giving NULL to this method will unset the corresponding field. | 74 // Giving NULL to this method will unset the corresponding field. |
75 void SetActiveVersion(ServiceWorkerVersion* version); | 75 void SetActiveVersion(ServiceWorkerVersion* version); |
76 void SetPendingVersion(ServiceWorkerVersion* version); | 76 void SetWaitingVersion(ServiceWorkerVersion* version); |
77 | 77 |
78 // Returns false if the version is not in the expected STARTING in our | 78 // Returns false if the version is not in the expected STARTING in our |
79 // our process state. That would be indicative of a bad IPC message. | 79 // our process state. That would be indicative of a bad IPC message. |
80 bool SetHostedVersionId(int64 versions_id); | 80 bool SetHostedVersionId(int64 versions_id); |
81 | 81 |
82 // Returns a handler for a request, the handler may return NULL if | 82 // Returns a handler for a request, the handler may return NULL if |
83 // the request doesn't require special handling. | 83 // the request doesn't require special handling. |
84 scoped_ptr<ServiceWorkerRequestHandler> CreateRequestHandler( | 84 scoped_ptr<ServiceWorkerRequestHandler> CreateRequestHandler( |
85 ResourceType::Type resource_type); | 85 ResourceType::Type resource_type); |
86 | 86 |
87 // Dispatches message event to the document. | 87 // Dispatches message event to the document. |
88 void PostMessage(const base::string16& message, | 88 void PostMessage(const base::string16& message, |
89 const std::vector<int>& sent_message_port_ids); | 89 const std::vector<int>& sent_message_port_ids); |
90 | 90 |
91 private: | 91 private: |
92 const int process_id_; | 92 const int process_id_; |
93 const int provider_id_; | 93 const int provider_id_; |
94 GURL document_url_; | 94 GURL document_url_; |
95 scoped_refptr<ServiceWorkerVersion> active_version_; | 95 scoped_refptr<ServiceWorkerVersion> active_version_; |
96 scoped_refptr<ServiceWorkerVersion> pending_version_; | 96 scoped_refptr<ServiceWorkerVersion> waiting_version_; |
97 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; | 97 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; |
98 base::WeakPtr<ServiceWorkerContextCore> context_; | 98 base::WeakPtr<ServiceWorkerContextCore> context_; |
99 ServiceWorkerDispatcherHost* dispatcher_host_; | 99 ServiceWorkerDispatcherHost* dispatcher_host_; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 101 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
102 }; | 102 }; |
103 | 103 |
104 } // namespace content | 104 } // namespace content |
105 | 105 |
106 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 106 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
OLD | NEW |