diff options
Diffstat (limited to 'chromium/content/child/service_worker/web_service_worker_impl.h')
-rw-r--r-- | chromium/content/child/service_worker/web_service_worker_impl.h | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/chromium/content/child/service_worker/web_service_worker_impl.h b/chromium/content/child/service_worker/web_service_worker_impl.h index de6010e212c..47260404f2d 100644 --- a/chromium/content/child/service_worker/web_service_worker_impl.h +++ b/chromium/content/child/service_worker/web_service_worker_impl.h @@ -5,21 +5,63 @@ #ifndef CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ #define CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ +#include <vector> + #include "base/compiler_specific.h" +#include "base/memory/ref_counted.h" +#include "base/strings/string16.h" +#include "third_party/WebKit/public/platform/WebMessagePortChannel.h" #include "third_party/WebKit/public/platform/WebServiceWorker.h" #include "third_party/WebKit/public/web/WebFrame.h" +namespace blink { +class WebServiceWorkerProxy; +} + namespace content { +class ServiceWorkerHandleReference; +struct ServiceWorkerObjectInfo; +class ThreadSafeSender; + +// Each instance corresponds to one ServiceWorker object in JS context, and +// is held by ServiceWorker object in blink's c++ layer, e.g. created one +// per navigator.serviceWorker.current or per successful +// navigator.serviceWorker.register call. +// +// Each instance holds one ServiceWorkerHandleReference so that +// corresponding ServiceWorkerHandle doesn't go away in the browser process +// while the ServiceWorker object is alive. class WebServiceWorkerImpl : NON_EXPORTED_BASE(public blink::WebServiceWorker) { public: - explicit WebServiceWorkerImpl(int64 registration_id) - : registration_id_(registration_id) {} + WebServiceWorkerImpl(scoped_ptr<ServiceWorkerHandleReference> handle_ref, + ThreadSafeSender* thread_safe_sender); virtual ~WebServiceWorkerImpl(); + // Notifies that the service worker's state changed. This function may queue + // the state change for later processing, if the proxy is not yet ready to + // handle state changes. + void OnStateChanged(blink::WebServiceWorkerState new_state); + + virtual void setProxy(blink::WebServiceWorkerProxy* proxy); + virtual blink::WebServiceWorkerProxy* proxy(); + virtual void proxyReadyChanged(); + virtual blink::WebURL scope() const; + virtual blink::WebURL url() const; + virtual blink::WebServiceWorkerState state() const; + virtual void postMessage(const blink::WebString& message, + blink::WebMessagePortChannelArray* channels); + private: - int64 registration_id_; + // Commits the new state internally and notifies the proxy of the change. + void ChangeState(blink::WebServiceWorkerState new_state); + + scoped_ptr<ServiceWorkerHandleReference> handle_ref_; + blink::WebServiceWorkerState state_; + scoped_refptr<ThreadSafeSender> thread_safe_sender_; + blink::WebServiceWorkerProxy* proxy_; + std::vector<blink::WebServiceWorkerState> queued_states_; DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerImpl); }; |