| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // is held by ServiceWorker object in blink's c++ layer, e.g. created one | 28 // is held by ServiceWorker object in blink's c++ layer, e.g. created one |
| 29 // per navigator.serviceWorker.current or per successful | 29 // per navigator.serviceWorker.current or per successful |
| 30 // navigator.serviceWorker.register call. | 30 // navigator.serviceWorker.register call. |
| 31 // | 31 // |
| 32 // Each instance holds one ServiceWorkerHandleReference so that | 32 // Each instance holds one ServiceWorkerHandleReference so that |
| 33 // corresponding ServiceWorkerHandle doesn't go away in the browser process | 33 // corresponding ServiceWorkerHandle doesn't go away in the browser process |
| 34 // while the ServiceWorker object is alive. | 34 // while the ServiceWorker object is alive. |
| 35 class WebServiceWorkerImpl | 35 class WebServiceWorkerImpl |
| 36 : NON_EXPORTED_BASE(public blink::WebServiceWorker) { | 36 : NON_EXPORTED_BASE(public blink::WebServiceWorker) { |
| 37 public: | 37 public: |
| 38 WebServiceWorkerImpl(const ServiceWorkerObjectInfo& info, | |
| 39 ThreadSafeSender* thread_safe_sender); | |
| 40 WebServiceWorkerImpl(scoped_ptr<ServiceWorkerHandleReference> handle_ref, | 38 WebServiceWorkerImpl(scoped_ptr<ServiceWorkerHandleReference> handle_ref, |
| 41 ThreadSafeSender* thread_safe_sender); | 39 ThreadSafeSender* thread_safe_sender); |
| 42 virtual ~WebServiceWorkerImpl(); | 40 virtual ~WebServiceWorkerImpl(); |
| 43 | 41 |
| 44 // Notifies that the service worker's state changed. This function may queue | 42 // Notifies that the service worker's state changed. This function may queue |
| 45 // the state change for later processing, if the proxy is not yet ready to | 43 // the state change for later processing, if the proxy is not yet ready to |
| 46 // handle state changes. | 44 // handle state changes. |
| 47 void OnStateChanged(blink::WebServiceWorkerState new_state); | 45 void OnStateChanged(blink::WebServiceWorkerState new_state); |
| 48 | 46 |
| 49 virtual void setProxy(blink::WebServiceWorkerProxy* proxy); | 47 virtual void setProxy(blink::WebServiceWorkerProxy* proxy); |
| 48 virtual blink::WebServiceWorkerProxy* proxy(); |
| 50 virtual void proxyReadyChanged(); | 49 virtual void proxyReadyChanged(); |
| 51 virtual blink::WebURL scope() const; | 50 virtual blink::WebURL scope() const; |
| 52 virtual blink::WebURL url() const; | 51 virtual blink::WebURL url() const; |
| 53 virtual blink::WebServiceWorkerState state() const; | 52 virtual blink::WebServiceWorkerState state() const; |
| 54 virtual void postMessage(const blink::WebString& message, | 53 virtual void postMessage(const blink::WebString& message, |
| 55 blink::WebMessagePortChannelArray* channels); | 54 blink::WebMessagePortChannelArray* channels); |
| 56 | 55 |
| 57 private: | 56 private: |
| 58 // Commits the new state internally and notifies the proxy of the change. | 57 // Commits the new state internally and notifies the proxy of the change. |
| 59 void ChangeState(blink::WebServiceWorkerState new_state); | 58 void ChangeState(blink::WebServiceWorkerState new_state); |
| 60 | 59 |
| 61 scoped_ptr<ServiceWorkerHandleReference> handle_ref_; | 60 scoped_ptr<ServiceWorkerHandleReference> handle_ref_; |
| 62 blink::WebServiceWorkerState state_; | 61 blink::WebServiceWorkerState state_; |
| 63 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 62 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 64 blink::WebServiceWorkerProxy* proxy_; | 63 blink::WebServiceWorkerProxy* proxy_; |
| 65 std::vector<blink::WebServiceWorkerState> queued_states_; | 64 std::vector<blink::WebServiceWorkerState> queued_states_; |
| 66 | 65 |
| 67 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerImpl); | 66 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerImpl); |
| 68 }; | 67 }; |
| 69 | 68 |
| 70 } // namespace content | 69 } // namespace content |
| 71 | 70 |
| 72 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ | 71 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ |
| OLD | NEW |