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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 388 |
383 void ServiceWorkerVersion::RemoveControllee( | 389 void ServiceWorkerVersion::RemoveControllee( |
384 ServiceWorkerProviderHost* provider_host) { | 390 ServiceWorkerProviderHost* provider_host) { |
385 ControlleeMap::iterator found = controllee_map_.find(provider_host); | 391 ControlleeMap::iterator found = controllee_map_.find(provider_host); |
386 DCHECK(found != controllee_map_.end()); | 392 DCHECK(found != controllee_map_.end()); |
387 controllee_by_id_.Remove(found->second); | 393 controllee_by_id_.Remove(found->second); |
388 controllee_map_.erase(found); | 394 controllee_map_.erase(found); |
389 RemoveProcessFromWorker(provider_host->process_id()); | 395 RemoveProcessFromWorker(provider_host->process_id()); |
390 if (HasControllee()) | 396 if (HasControllee()) |
391 return; | 397 return; |
| 398 FOR_EACH_OBSERVER(Listener, listeners_, OnNoControllees(this)); |
392 if (is_doomed_) { | 399 if (is_doomed_) { |
393 DoomInternal(); | 400 DoomInternal(); |
394 return; | 401 return; |
395 } | 402 } |
396 ScheduleStopWorker(); | 403 ScheduleStopWorker(); |
397 } | 404 } |
398 | 405 |
399 void ServiceWorkerVersion::AddPotentialControllee( | 406 void ServiceWorkerVersion::AddPotentialControllee( |
400 ServiceWorkerProviderHost* provider_host) { | 407 ServiceWorkerProviderHost* provider_host) { |
401 AddProcessToWorker(provider_host->process_id()); | 408 AddProcessToWorker(provider_host->process_id()); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 SetStatus(REDUNDANT); | 680 SetStatus(REDUNDANT); |
674 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 681 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
675 if (!context_) | 682 if (!context_) |
676 return; | 683 return; |
677 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; | 684 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; |
678 script_cache_map_.GetResources(&resources); | 685 script_cache_map_.GetResources(&resources); |
679 context_->storage()->PurgeResources(resources); | 686 context_->storage()->PurgeResources(resources); |
680 } | 687 } |
681 | 688 |
682 } // namespace content | 689 } // namespace content |
OLD | NEW |