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> | |
9 | |
8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
9 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
10 #include "webkit/common/resource_type.h" | 12 #include "webkit/common/resource_type.h" |
11 | 13 |
12 namespace content { | 14 namespace content { |
13 | 15 |
14 class ServiceWorkerVersion; | 16 class ServiceWorkerVersion; |
15 | 17 |
16 // This class is the browser-process representation of a serice worker | 18 // This class is the browser-process representation of a serice worker |
17 // provider. There is a provider per document and the lifetime of this | 19 // provider. There is a provider per document and the lifetime of this |
18 // object is tied to the lifetime of its document in the renderer process. | 20 // object is tied to the lifetime of its document in the renderer process. |
19 // This class holds service worker state this is scoped to an individual | 21 // This class holds service worker state this is scoped to an individual |
20 // document. | 22 // document. |
21 class ServiceWorkerProviderHost | 23 class ServiceWorkerProviderHost |
22 : public base::SupportsWeakPtr<ServiceWorkerProviderHost> { | 24 : public base::SupportsWeakPtr<ServiceWorkerProviderHost> { |
23 public: | 25 public: |
24 ServiceWorkerProviderHost(int process_id, | 26 ServiceWorkerProviderHost(int process_id, |
25 int provider_id); | 27 int provider_id); |
26 ~ServiceWorkerProviderHost(); | 28 ~ServiceWorkerProviderHost(); |
27 | 29 |
28 int process_id() const { return process_id_; } | 30 int process_id() const { return process_id_; } |
29 int provider_id() const { return provider_id_; } | 31 int provider_id() const { return provider_id_; } |
30 | 32 |
33 // Adds and removes client thread ID, who is listening events dispatched | |
34 // from ServiceWorker to the document corresponding to this provider. | |
michaeln
2014/03/07 01:33:58
This comment could be massaged to mention the docu
kinuko
2014/03/07 02:02:17
Done.
| |
35 void AddScriptClient(int thread_id); | |
36 void RemoveScriptClient(int thread_id); | |
37 | |
31 // The service worker version that corresponds with navigator.serviceWorker | 38 // The service worker version that corresponds with navigator.serviceWorker |
32 // for our document. | 39 // for our document. |
33 ServiceWorkerVersion* associated_version() const { | 40 ServiceWorkerVersion* associated_version() const { |
34 return associated_version_.get(); | 41 return associated_version_.get(); |
35 } | 42 } |
36 | 43 |
44 const std::set<int>& client_thread_ids() const { return client_thread_ids_; } | |
michaeln
2014/03/06 20:24:29
Shouldn't there only be one script client thread?
kinuko
2014/03/07 00:22:23
In the CL the Add/Remove messages are sent from th
| |
45 | |
37 // Returns true if this provider host should handle requests for | 46 // Returns true if this provider host should handle requests for |
38 // |resource_type|. | 47 // |resource_type|. |
39 bool ShouldHandleRequest(ResourceType::Type resource_type) const; | 48 bool ShouldHandleRequest(ResourceType::Type resource_type) const; |
40 | 49 |
41 private: | 50 private: |
42 const int process_id_; | 51 const int process_id_; |
43 const int provider_id_; | 52 const int provider_id_; |
53 std::set<int> client_thread_ids_; | |
44 scoped_refptr<ServiceWorkerVersion> associated_version_; | 54 scoped_refptr<ServiceWorkerVersion> associated_version_; |
45 }; | 55 }; |
46 | 56 |
47 } // namespace content | 57 } // namespace content |
48 | 58 |
49 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 59 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
OLD | NEW |