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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 weak_factory_.GetWeakPtr())); | 209 weak_factory_.GetWeakPtr())); |
210 } | 210 } |
211 | 211 |
212 void ServiceWorkerVersion::DeferScheduledUpdate() { | 212 void ServiceWorkerVersion::DeferScheduledUpdate() { |
213 if (update_timer_.IsRunning()) | 213 if (update_timer_.IsRunning()) |
214 update_timer_.Reset(); | 214 update_timer_.Reset(); |
215 } | 215 } |
216 | 216 |
217 void ServiceWorkerVersion::StartUpdate() { | 217 void ServiceWorkerVersion::StartUpdate() { |
218 update_timer_.Stop(); | 218 update_timer_.Stop(); |
219 // TODO(michaeln): write me | 219 if (!context_) |
| 220 return; |
| 221 ServiceWorkerRegistration* registration = |
| 222 context_->GetLiveRegistration(registration_id_); |
| 223 if (!registration) |
| 224 return; |
| 225 context_->UpdateServiceWorker(registration); |
220 } | 226 } |
221 | 227 |
222 void ServiceWorkerVersion::SendMessage( | 228 void ServiceWorkerVersion::SendMessage( |
223 const IPC::Message& message, const StatusCallback& callback) { | 229 const IPC::Message& message, const StatusCallback& callback) { |
224 if (running_status() != RUNNING) { | 230 if (running_status() != RUNNING) { |
225 // Schedule calling this method after starting the worker. | 231 // Schedule calling this method after starting the worker. |
226 StartWorker(base::Bind(&RunTaskAfterStartWorker, | 232 StartWorker(base::Bind(&RunTaskAfterStartWorker, |
227 weak_factory_.GetWeakPtr(), callback, | 233 weak_factory_.GetWeakPtr(), callback, |
228 base::Bind(&self::SendMessage, | 234 base::Bind(&self::SendMessage, |
229 weak_factory_.GetWeakPtr(), | 235 weak_factory_.GetWeakPtr(), |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 return; | 656 return; |
651 } | 657 } |
652 stop_worker_timer_.Start( | 658 stop_worker_timer_.Start( |
653 FROM_HERE, base::TimeDelta::FromSeconds(kStopWorkerDelay), | 659 FROM_HERE, base::TimeDelta::FromSeconds(kStopWorkerDelay), |
654 base::Bind(&ServiceWorkerVersion::StopWorker, | 660 base::Bind(&ServiceWorkerVersion::StopWorker, |
655 weak_factory_.GetWeakPtr(), | 661 weak_factory_.GetWeakPtr(), |
656 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback))); | 662 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback))); |
657 } | 663 } |
658 | 664 |
659 } // namespace content | 665 } // namespace content |
OLD | NEW |