Chromium Code Reviews| 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> | |
| 9 | |
| 8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 10 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 11 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 13 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
| 12 #include "third_party/WebKit/public/platform/WebServiceWorker.h" | 14 #include "third_party/WebKit/public/platform/WebServiceWorker.h" |
| 13 #include "third_party/WebKit/public/web/WebFrame.h" | 15 #include "third_party/WebKit/public/web/WebFrame.h" |
| 14 | 16 |
| 15 namespace blink { | 17 namespace blink { |
| 16 class WebServiceWorkerProxy; | 18 class WebServiceWorkerProxy; |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace content { | 21 namespace content { |
| 20 | 22 |
| 21 class ThreadSafeSender; | 23 class ThreadSafeSender; |
| 22 struct ServiceWorkerObjectInfo; | 24 struct ServiceWorkerObjectInfo; |
| 23 | 25 |
| 24 class WebServiceWorkerImpl | 26 class WebServiceWorkerImpl |
| 25 : NON_EXPORTED_BASE(public blink::WebServiceWorker) { | 27 : NON_EXPORTED_BASE(public blink::WebServiceWorker) { |
| 26 public: | 28 public: |
| 27 WebServiceWorkerImpl(const ServiceWorkerObjectInfo& info, | 29 WebServiceWorkerImpl(const ServiceWorkerObjectInfo& info, |
| 28 ThreadSafeSender* thread_safe_sender); | 30 ThreadSafeSender* thread_safe_sender); |
| 29 virtual ~WebServiceWorkerImpl(); | 31 virtual ~WebServiceWorkerImpl(); |
| 30 | 32 |
| 31 void SetState(blink::WebServiceWorkerState new_state); | 33 // 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 | |
| 35 // handle state changes. | |
| 36 void OnStateChanged(blink::WebServiceWorkerState new_state); | |
| 32 | 37 |
| 33 virtual void setProxy(blink::WebServiceWorkerProxy* proxy); | 38 virtual void setProxy(blink::WebServiceWorkerProxy* proxy); |
| 39 virtual void proxyReadyChanged(); | |
| 34 virtual blink::WebURL scope() const; | 40 virtual blink::WebURL scope() const; |
| 35 virtual blink::WebURL url() const; | 41 virtual blink::WebURL url() const; |
| 36 virtual blink::WebServiceWorkerState state() const; | 42 virtual blink::WebServiceWorkerState state() const; |
| 37 virtual void postMessage(const blink::WebString& message, | 43 virtual void postMessage(const blink::WebString& message, |
| 38 blink::WebMessagePortChannelArray* channels); | 44 blink::WebMessagePortChannelArray* channels); |
| 39 | 45 |
| 40 private: | 46 private: |
| 47 // Commits the new state internally and notifies the proxy of the change. | |
| 48 void ChangeState(blink::WebServiceWorkerState new_state); | |
|
kinuko
2014/04/25 08:07:34
nit: CommitStateChange() maybe, to clearly disting
falken
2014/04/27 03:31:17
I agree. Unfortunately I can't remote into my comp
| |
| 49 | |
| 41 const int handle_id_; | 50 const int handle_id_; |
| 42 const GURL scope_; | 51 const GURL scope_; |
| 43 const GURL url_; | 52 const GURL url_; |
| 44 blink::WebServiceWorkerState state_; | 53 blink::WebServiceWorkerState state_; |
| 45 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 54 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 46 blink::WebServiceWorkerProxy* proxy_; | 55 blink::WebServiceWorkerProxy* proxy_; |
| 56 std::vector<blink::WebServiceWorkerState> queued_states_; | |
| 47 | 57 |
| 48 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerImpl); | 58 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerImpl); |
| 49 }; | 59 }; |
| 50 | 60 |
| 51 } // namespace content | 61 } // namespace content |
| 52 | 62 |
| 53 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ | 63 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_IMPL_H_ |
| OLD | NEW |