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 ServiceWorkerVersion* version) { |
| 15 if (!context || !version) |
| 16 return scoped_ptr<ServiceWorkerHandle>(); |
| 17 ServiceWorkerRegistration* registration = |
| 18 context->GetLiveRegistration(version->registration_id()); |
| 19 return make_scoped_ptr( |
| 20 new ServiceWorkerHandle(context, sender, registration, version)); |
| 21 } |
| 22 |
| 23 ServiceWorkerHandle::ServiceWorkerHandle( |
| 24 base::WeakPtr<ServiceWorkerContextCore> context, |
| 25 IPC::Sender* sender, |
| 26 ServiceWorkerRegistration* registration, |
| 27 ServiceWorkerVersion* version) |
| 28 : context_(context), |
| 29 sender_(sender), |
| 30 registration_(registration), |
| 31 version_(version) { |
| 32 // context_->IncrementRegistrationCacheCount(registration); |
| 33 } |
| 34 |
| 35 ServiceWorkerHandle::~ServiceWorkerHandle() { |
| 36 // We can discard the registration after all documents/handles that |
| 37 // have a reference to the registration is closed or freed up, but |
| 38 // could also keep it alive in cache for a while with some timer so that |
| 39 // we don't need to re-create the same registration over and over? |
| 40 // |
| 41 // if (context_) |
| 42 // context_->DecrementRegistrationCacheCount(registration); |
| 43 } |
| 44 |
| 45 void ServiceWorkerHandle::OnVersionStateChanged() { |
| 46 // TODO(kinuko): Implement. |
| 47 } |
| 48 |
| 49 } // namespace content |
OLD | NEW |