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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 DCHECK(context_); | 103 DCHECK(context_); |
104 DCHECK(registration); | 104 DCHECK(registration); |
105 if (registration) { | 105 if (registration) { |
106 registration_id_ = registration->id(); | 106 registration_id_ = registration->id(); |
107 script_url_ = registration->script_url(); | 107 script_url_ = registration->script_url(); |
108 scope_ = registration->pattern(); | 108 scope_ = registration->pattern(); |
109 } | 109 } |
110 context_->AddLiveVersion(this); | 110 context_->AddLiveVersion(this); |
111 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); | 111 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); |
112 embedded_worker_->AddListener(this); | 112 embedded_worker_->AddListener(this); |
113 stores_listener_.reset(new ServiceWorkerStoresListener(this)); | 113 cache_listener_.reset(new ServiceWorkerCacheListener(this, context)); |
114 embedded_worker_->AddListener(stores_listener_.get()); | 114 embedded_worker_->AddListener(cache_listener_.get()); |
115 } | 115 } |
116 | 116 |
117 ServiceWorkerVersion::~ServiceWorkerVersion() { | 117 ServiceWorkerVersion::~ServiceWorkerVersion() { |
118 embedded_worker_->RemoveListener(this); | 118 embedded_worker_->RemoveListener(this); |
119 if (context_) | 119 if (context_) |
120 context_->RemoveLiveVersion(version_id_); | 120 context_->RemoveLiveVersion(version_id_); |
121 // EmbeddedWorker's dtor sends StopWorker if it's still running. | 121 // EmbeddedWorker's dtor sends StopWorker if it's still running. |
122 } | 122 } |
123 | 123 |
124 void ServiceWorkerVersion::SetStatus(Status status) { | 124 void ServiceWorkerVersion::SetStatus(Status status) { |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 SetStatus(REDUNDANT); | 690 SetStatus(REDUNDANT); |
691 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 691 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
692 if (!context_) | 692 if (!context_) |
693 return; | 693 return; |
694 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; | 694 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; |
695 script_cache_map_.GetResources(&resources); | 695 script_cache_map_.GetResources(&resources); |
696 context_->storage()->PurgeResources(resources); | 696 context_->storage()->PurgeResources(resources); |
697 } | 697 } |
698 | 698 |
699 } // namespace content | 699 } // namespace content |
OLD | NEW |