Index: content/child/service_worker/web_service_worker_impl.cc |
diff --git a/content/child/service_worker/web_service_worker_impl.cc b/content/child/service_worker/web_service_worker_impl.cc |
index 02f877951c3b512f14045ac98fc498282eab6f54..3a30243bc35c78a5f69176f1053771735fc13ac6 100644 |
--- a/content/child/service_worker/web_service_worker_impl.cc |
+++ b/content/child/service_worker/web_service_worker_impl.cc |
@@ -4,6 +4,7 @@ |
#include "content/child/service_worker/web_service_worker_impl.h" |
+#include "content/child/service_worker/scoped_service_worker_reference.h" |
#include "content/child/service_worker/service_worker_dispatcher.h" |
#include "content/child/thread_safe_sender.h" |
#include "content/child/webmessageportchannel_impl.h" |
@@ -21,27 +22,38 @@ namespace content { |
WebServiceWorkerImpl::WebServiceWorkerImpl( |
const ServiceWorkerObjectInfo& info, |
ThreadSafeSender* thread_safe_sender) |
- : handle_id_(info.handle_id), |
- scope_(info.scope), |
- url_(info.url), |
- state_(info.state), |
+ : worker_ref_( |
+ ScopedServiceWorkerReference::CreateForDeleter(info, |
+ thread_safe_sender)), |
+ state_(worker_ref_->state()), |
thread_safe_sender_(thread_safe_sender), |
proxy_(NULL) { |
ServiceWorkerDispatcher* dispatcher = |
ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
DCHECK(dispatcher); |
- dispatcher->AddServiceWorker(handle_id_, this); |
+ dispatcher->AddServiceWorker(worker_ref_->handle_id(), this); |
+} |
+ |
+WebServiceWorkerImpl::WebServiceWorkerImpl( |
+ scoped_ptr<ScopedServiceWorkerReference> worker_ref, |
+ ThreadSafeSender* thread_safe_sender) |
+ : worker_ref_(worker_ref.Pass()), |
+ state_(worker_ref_->state()), |
+ thread_safe_sender_(thread_safe_sender), |
+ proxy_(NULL) { |
+ ServiceWorkerDispatcher* dispatcher = |
+ ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
+ DCHECK(dispatcher); |
+ dispatcher->AddServiceWorker(worker_ref_->handle_id(), this); |
} |
WebServiceWorkerImpl::~WebServiceWorkerImpl() { |
- if (handle_id_ == kInvalidServiceWorkerHandleId) |
+ if (worker_ref_->handle_id() == kInvalidServiceWorkerHandleId) |
return; |
- thread_safe_sender_->Send( |
- new ServiceWorkerHostMsg_ServiceWorkerObjectDestroyed(handle_id_)); |
ServiceWorkerDispatcher* dispatcher = |
ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
if (dispatcher) |
- dispatcher->RemoveServiceWorker(handle_id_); |
+ dispatcher->RemoveServiceWorker(worker_ref_->handle_id()); |
} |
void WebServiceWorkerImpl::OnStateChanged( |
@@ -70,11 +82,11 @@ void WebServiceWorkerImpl::proxyReadyChanged() { |
} |
blink::WebURL WebServiceWorkerImpl::scope() const { |
- return scope_; |
+ return worker_ref_->scope(); |
} |
blink::WebURL WebServiceWorkerImpl::url() const { |
- return url_; |
+ return worker_ref_->url(); |
} |
blink::WebServiceWorkerState WebServiceWorkerImpl::state() const { |
@@ -84,7 +96,7 @@ blink::WebServiceWorkerState WebServiceWorkerImpl::state() const { |
void WebServiceWorkerImpl::postMessage(const WebString& message, |
WebMessagePortChannelArray* channels) { |
thread_safe_sender_->Send(new ServiceWorkerHostMsg_PostMessage( |
- handle_id_, |
+ worker_ref_->handle_id(), |
message, |
WebMessagePortChannelImpl::ExtractMessagePortIDs(channels))); |
} |