| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 weak_factory_.GetWeakPtr())); | 210 weak_factory_.GetWeakPtr())); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void ServiceWorkerVersion::DeferScheduledUpdate() { | 213 void ServiceWorkerVersion::DeferScheduledUpdate() { |
| 214 if (update_timer_.IsRunning()) | 214 if (update_timer_.IsRunning()) |
| 215 update_timer_.Reset(); | 215 update_timer_.Reset(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void ServiceWorkerVersion::StartUpdate() { | 218 void ServiceWorkerVersion::StartUpdate() { |
| 219 update_timer_.Stop(); | 219 update_timer_.Stop(); |
| 220 // TODO(michaeln): write me | 220 if (!context_) |
| 221 return; |
| 222 ServiceWorkerRegistration* registration = |
| 223 context_->GetLiveRegistration(registration_id_); |
| 224 if (!registration) |
| 225 return; |
| 226 context_->UpdateServiceWorker(registration); |
| 221 } | 227 } |
| 222 | 228 |
| 223 void ServiceWorkerVersion::SendMessage( | 229 void ServiceWorkerVersion::SendMessage( |
| 224 const IPC::Message& message, const StatusCallback& callback) { | 230 const IPC::Message& message, const StatusCallback& callback) { |
| 225 if (running_status() != RUNNING) { | 231 if (running_status() != RUNNING) { |
| 226 // Schedule calling this method after starting the worker. | 232 // Schedule calling this method after starting the worker. |
| 227 StartWorker(base::Bind(&RunTaskAfterStartWorker, | 233 StartWorker(base::Bind(&RunTaskAfterStartWorker, |
| 228 weak_factory_.GetWeakPtr(), callback, | 234 weak_factory_.GetWeakPtr(), callback, |
| 229 base::Bind(&self::SendMessage, | 235 base::Bind(&self::SendMessage, |
| 230 weak_factory_.GetWeakPtr(), | 236 weak_factory_.GetWeakPtr(), |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 SetStatus(REDUNDANT); | 679 SetStatus(REDUNDANT); |
| 674 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 680 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 675 if (!context_) | 681 if (!context_) |
| 676 return; | 682 return; |
| 677 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; | 683 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; |
| 678 script_cache_map_.GetResources(&resources); | 684 script_cache_map_.GetResources(&resources); |
| 679 context_->storage()->PurgeResources(resources); | 685 context_->storage()->PurgeResources(resources); |
| 680 } | 686 } |
| 681 | 687 |
| 682 } // namespace content | 688 } // namespace content |
| OLD | NEW |