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 #include "content/browser/service_worker/service_worker_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "content/browser/service_worker/embedded_worker_instance.h" | 10 #include "content/browser/service_worker/embedded_worker_instance.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 DCHECK(context_); | 104 DCHECK(context_); |
105 DCHECK(registration); | 105 DCHECK(registration); |
106 if (registration) { | 106 if (registration) { |
107 registration_id_ = registration->id(); | 107 registration_id_ = registration->id(); |
108 script_url_ = registration->script_url(); | 108 script_url_ = registration->script_url(); |
109 scope_ = registration->pattern(); | 109 scope_ = registration->pattern(); |
110 } | 110 } |
111 context_->AddLiveVersion(this); | 111 context_->AddLiveVersion(this); |
112 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); | 112 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); |
113 embedded_worker_->AddListener(this); | 113 embedded_worker_->AddListener(this); |
| 114 cache_listener_.reset(new ServiceWorkerCacheListener(this)); |
| 115 embedded_worker_->AddListener(cache_listener_.get()); |
114 } | 116 } |
115 | 117 |
116 ServiceWorkerVersion::~ServiceWorkerVersion() { | 118 ServiceWorkerVersion::~ServiceWorkerVersion() { |
117 embedded_worker_->RemoveListener(this); | 119 embedded_worker_->RemoveListener(this); |
118 if (context_) | 120 if (context_) |
119 context_->RemoveLiveVersion(version_id_); | 121 context_->RemoveLiveVersion(version_id_); |
120 // EmbeddedWorker's dtor sends StopWorker if it's still running. | 122 // EmbeddedWorker's dtor sends StopWorker if it's still running. |
121 } | 123 } |
122 | 124 |
123 void ServiceWorkerVersion::SetStatus(Status status) { | 125 void ServiceWorkerVersion::SetStatus(Status status) { |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 SetStatus(REDUNDANT); | 682 SetStatus(REDUNDANT); |
681 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 683 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
682 if (!context_) | 684 if (!context_) |
683 return; | 685 return; |
684 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; | 686 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; |
685 script_cache_map_.GetResources(&resources); | 687 script_cache_map_.GetResources(&resources); |
686 context_->storage()->PurgeResources(resources); | 688 context_->storage()->PurgeResources(resources); |
687 } | 689 } |
688 | 690 |
689 } // namespace content | 691 } // namespace content |
OLD | NEW |