OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/service_worker/service_worker_context_core.h" |
| 6 #include "content/browser/service_worker/service_worker_handle.h" |
| 7 #include "content/browser/service_worker/service_worker_registration.h" |
| 8 |
| 9 namespace content { |
| 10 |
| 11 scoped_ptr<ServiceWorkerHandle> ServiceWorkerHandle::Create( |
| 12 base::WeakPtr<ServiceWorkerContextCore> context, |
| 13 IPC::Sender* sender, |
| 14 int thread_id, |
| 15 ServiceWorkerVersion* version) { |
| 16 if (!context || !version) |
| 17 return scoped_ptr<ServiceWorkerHandle>(); |
| 18 ServiceWorkerRegistration* registration = |
| 19 context->GetLiveRegistration(version->registration_id()); |
| 20 return make_scoped_ptr( |
| 21 new ServiceWorkerHandle(context, sender, thread_id, |
| 22 registration, version)); |
| 23 } |
| 24 |
| 25 ServiceWorkerHandle::ServiceWorkerHandle( |
| 26 base::WeakPtr<ServiceWorkerContextCore> context, |
| 27 IPC::Sender* sender, |
| 28 int thread_id, |
| 29 ServiceWorkerRegistration* registration, |
| 30 ServiceWorkerVersion* version) |
| 31 : context_(context), |
| 32 sender_(sender), |
| 33 thread_id_(thread_id), |
| 34 registration_(registration), |
| 35 version_(version) { |
| 36 } |
| 37 |
| 38 ServiceWorkerHandle::~ServiceWorkerHandle() { |
| 39 // TODO(kinuko): At this point we can discard the registration if |
| 40 // all documents/handles that have a reference to the registration is |
| 41 // closed or freed up, but could also keep it alive in cache |
| 42 // (e.g. in context_) for a while with some timer so that we don't |
| 43 // need to re-load the same registration from disk over and over. |
| 44 } |
| 45 |
| 46 void ServiceWorkerHandle::OnVersionStateChanged(ServiceWorkerVersion* version) { |
| 47 // TODO(kinuko): Implement. |
| 48 } |
| 49 |
| 50 } // namespace content |
OLD | NEW |