OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_HANDLE_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // Creates a handle for a live version. The version's corresponding | 33 // Creates a handle for a live version. The version's corresponding |
34 // registration must be also alive. | 34 // registration must be also alive. |
35 // This may return NULL if |context|.get() or |version| is NULL. | 35 // This may return NULL if |context|.get() or |version| is NULL. |
36 // |sender| and |thread_id| will be used to send messages to the | 36 // |sender| and |thread_id| will be used to send messages to the |
37 // corresponding WebServiceWorkerImpl (which should live on |thread_id| | 37 // corresponding WebServiceWorkerImpl (which should live on |thread_id| |
38 // in the child process). | 38 // in the child process). |
39 static scoped_ptr<ServiceWorkerHandle> Create( | 39 static scoped_ptr<ServiceWorkerHandle> Create( |
40 base::WeakPtr<ServiceWorkerContextCore> context, | 40 base::WeakPtr<ServiceWorkerContextCore> context, |
41 IPC::Sender* sender, | 41 IPC::Sender* sender, |
42 int thread_id, | 42 int thread_id, |
| 43 int provider_id, |
43 ServiceWorkerVersion* version); | 44 ServiceWorkerVersion* version); |
44 | 45 |
45 ServiceWorkerHandle(base::WeakPtr<ServiceWorkerContextCore> context, | 46 ServiceWorkerHandle(base::WeakPtr<ServiceWorkerContextCore> context, |
46 IPC::Sender* sender, | 47 IPC::Sender* sender, |
47 int thread_id, | 48 int thread_id, |
| 49 int provider_id, |
48 ServiceWorkerRegistration* registration, | 50 ServiceWorkerRegistration* registration, |
49 ServiceWorkerVersion* version); | 51 ServiceWorkerVersion* version); |
50 virtual ~ServiceWorkerHandle(); | 52 virtual ~ServiceWorkerHandle(); |
51 | 53 |
52 // ServiceWorkerVersion::Listener overrides. | 54 // ServiceWorkerVersion::Listener overrides. |
53 virtual void OnWorkerStarted(ServiceWorkerVersion* version) OVERRIDE; | 55 virtual void OnWorkerStarted(ServiceWorkerVersion* version) OVERRIDE; |
54 virtual void OnWorkerStopped(ServiceWorkerVersion* version) OVERRIDE; | 56 virtual void OnWorkerStopped(ServiceWorkerVersion* version) OVERRIDE; |
55 virtual void OnErrorReported(ServiceWorkerVersion* version, | 57 virtual void OnErrorReported(ServiceWorkerVersion* version, |
56 const base::string16& error_message, | 58 const base::string16& error_message, |
57 int line_number, | 59 int line_number, |
58 int column_number, | 60 int column_number, |
59 const GURL& source_url) OVERRIDE; | 61 const GURL& source_url) OVERRIDE; |
60 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, | 62 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, |
61 int source_identifier, | 63 int source_identifier, |
62 int message_level, | 64 int message_level, |
63 const base::string16& message, | 65 const base::string16& message, |
64 int line_number, | 66 int line_number, |
65 const GURL& source_url) OVERRIDE; | 67 const GURL& source_url) OVERRIDE; |
66 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) OVERRIDE; | 68 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) OVERRIDE; |
67 | 69 |
68 ServiceWorkerObjectInfo GetObjectInfo(); | 70 ServiceWorkerObjectInfo GetObjectInfo(); |
69 | 71 |
70 int thread_id() const { return thread_id_; } | 72 int thread_id() const { return thread_id_; } |
| 73 int provider_id() const { return provider_id_; } |
71 int handle_id() const { return handle_id_; } | 74 int handle_id() const { return handle_id_; } |
72 ServiceWorkerRegistration* registration() { return registration_.get(); } | 75 ServiceWorkerRegistration* registration() { return registration_.get(); } |
73 ServiceWorkerVersion* version() { return version_.get(); } | 76 ServiceWorkerVersion* version() { return version_.get(); } |
74 | 77 |
75 bool HasNoRefCount() const { return ref_count_ <= 0; } | 78 bool HasNoRefCount() const { return ref_count_ <= 0; } |
76 void IncrementRefCount(); | 79 void IncrementRefCount(); |
77 void DecrementRefCount(); | 80 void DecrementRefCount(); |
78 | 81 |
79 private: | 82 private: |
80 base::WeakPtr<ServiceWorkerContextCore> context_; | 83 base::WeakPtr<ServiceWorkerContextCore> context_; |
81 IPC::Sender* sender_; // Not owned, it should always outlive this. | 84 IPC::Sender* sender_; // Not owned, it should always outlive this. |
82 const int thread_id_; | 85 const int thread_id_; |
| 86 const int provider_id_; |
83 const int handle_id_; | 87 const int handle_id_; |
84 int ref_count_; // Created with 1. | 88 int ref_count_; // Created with 1. |
85 scoped_refptr<ServiceWorkerRegistration> registration_; | 89 scoped_refptr<ServiceWorkerRegistration> registration_; |
86 scoped_refptr<ServiceWorkerVersion> version_; | 90 scoped_refptr<ServiceWorkerVersion> version_; |
87 | 91 |
88 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandle); | 92 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandle); |
89 }; | 93 }; |
90 | 94 |
91 } // namespace content | 95 } // namespace content |
92 | 96 |
93 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_ | 97 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_ |
OLD | NEW |