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_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ | 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ |
6 #define CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ | 6 #define CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 13 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
14 #include "third_party/WebKit/public/platform/WebServiceWorker.h" | 14 #include "third_party/WebKit/public/platform/WebServiceWorker.h" |
15 #include "third_party/WebKit/public/web/WebFrame.h" | 15 #include "third_party/WebKit/public/web/WebFrame.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 class WebServiceWorkerProxy; | 18 class WebServiceWorkerProxy; |
19 } | 19 } |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 class ServiceWorkerHandleReference; | |
24 struct ServiceWorkerObjectInfo; | |
23 class ThreadSafeSender; | 25 class ThreadSafeSender; |
24 struct ServiceWorkerObjectInfo; | |
25 | 26 |
27 // Each instance corresponds to onw ServiceWorker object in JS context, and | |
michaeln
2014/05/05 23:18:03
own --> one?
kinuko
2014/05/06 00:39:37
Done.
| |
28 // is held by ServiceWorker object in blink's c++ layer, e.g. created one | |
29 // per navigator.serviceWorker.current or per successful | |
30 // navigator.serviceWorker.register call. | |
31 // | |
32 // Each instance holds one ServiceWorkerHandleReference so that | |
33 // corresponding ServiceWorkerHandle doesn't go away in the browser process | |
34 // while the ServiceWorker object is alive. | |
26 class WebServiceWorkerImpl | 35 class WebServiceWorkerImpl |
27 : NON_EXPORTED_BASE(public blink::WebServiceWorker) { | 36 : NON_EXPORTED_BASE(public blink::WebServiceWorker) { |
28 public: | 37 public: |
29 WebServiceWorkerImpl(const ServiceWorkerObjectInfo& info, | 38 WebServiceWorkerImpl(const ServiceWorkerObjectInfo& info, |
30 ThreadSafeSender* thread_safe_sender); | 39 ThreadSafeSender* thread_safe_sender); |
40 WebServiceWorkerImpl(scoped_ptr<ServiceWorkerHandleReference> handle_ref, | |
41 ThreadSafeSender* thread_safe_sender); | |
31 virtual ~WebServiceWorkerImpl(); | 42 virtual ~WebServiceWorkerImpl(); |
32 | 43 |
33 // Notifies that the service worker's state changed. This function may queue | 44 // Notifies that the service worker's state changed. This function may queue |
34 // the state change for later processing, if the proxy is not yet ready to | 45 // the state change for later processing, if the proxy is not yet ready to |
35 // handle state changes. | 46 // handle state changes. |
36 void OnStateChanged(blink::WebServiceWorkerState new_state); | 47 void OnStateChanged(blink::WebServiceWorkerState new_state); |
37 | 48 |
38 virtual void setProxy(blink::WebServiceWorkerProxy* proxy); | 49 virtual void setProxy(blink::WebServiceWorkerProxy* proxy); |
39 virtual void proxyReadyChanged(); | 50 virtual void proxyReadyChanged(); |
40 virtual blink::WebURL scope() const; | 51 virtual blink::WebURL scope() const; |
41 virtual blink::WebURL url() const; | 52 virtual blink::WebURL url() const; |
42 virtual blink::WebServiceWorkerState state() const; | 53 virtual blink::WebServiceWorkerState state() const; |
43 virtual void postMessage(const blink::WebString& message, | 54 virtual void postMessage(const blink::WebString& message, |
44 blink::WebMessagePortChannelArray* channels); | 55 blink::WebMessagePortChannelArray* channels); |
45 | 56 |
46 private: | 57 private: |
47 // Commits the new state internally and notifies the proxy of the change. | 58 // Commits the new state internally and notifies the proxy of the change. |
48 void ChangeState(blink::WebServiceWorkerState new_state); | 59 void ChangeState(blink::WebServiceWorkerState new_state); |
49 | 60 |
50 const int handle_id_; | 61 scoped_ptr<ServiceWorkerHandleReference> handle_ref_; |
51 const GURL scope_; | |
52 const GURL url_; | |
53 blink::WebServiceWorkerState state_; | 62 blink::WebServiceWorkerState state_; |
54 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 63 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
55 blink::WebServiceWorkerProxy* proxy_; | 64 blink::WebServiceWorkerProxy* proxy_; |
56 std::vector<blink::WebServiceWorkerState> queued_states_; | 65 std::vector<blink::WebServiceWorkerState> queued_states_; |
57 | 66 |
58 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerImpl); | 67 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerImpl); |
59 }; | 68 }; |
60 | 69 |
61 } // namespace content | 70 } // namespace content |
62 | 71 |
63 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ | 72 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ |
OLD | NEW |