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_register_job.h" | 5 #include "content/browser/service_worker/service_worker_register_job.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 status = SERVICE_WORKER_ERROR_NETWORK; | 356 status = SERVICE_WORKER_ERROR_NETWORK; |
357 } | 357 } |
358 } | 358 } |
359 Complete(status); | 359 Complete(status); |
360 } | 360 } |
361 | 361 |
362 // This function corresponds to the spec's [[Install]] algorithm. | 362 // This function corresponds to the spec's [[Install]] algorithm. |
363 void ServiceWorkerRegisterJob::InstallAndContinue() { | 363 void ServiceWorkerRegisterJob::InstallAndContinue() { |
364 SetPhase(INSTALL); | 364 SetPhase(INSTALL); |
365 | 365 |
366 // "2. Set registration.installingWorker to worker." | 366 // "Set registration.installingWorker to worker." |
367 DCHECK(!registration()->installing_version()); | 367 DCHECK(!registration()->installing_version()); |
368 registration()->SetInstallingVersion(new_version()); | 368 registration()->SetInstallingVersion(new_version()); |
369 | 369 |
370 // "3. Resolve promise with registration." | 370 // "Run the Update State algorithm passing registration's installing worker |
| 371 // and installing as the arguments." |
| 372 new_version()->SetStatus(ServiceWorkerVersion::INSTALLING); |
| 373 |
| 374 // "Resolve registrationPromise with registration." |
371 ResolvePromise(SERVICE_WORKER_OK, registration()); | 375 ResolvePromise(SERVICE_WORKER_OK, registration()); |
372 | 376 |
373 // "4. Run the [[UpdateState]] algorithm passing registration.installingWorker | 377 // "Fire a simple event named updatefound..." |
374 // and "installing" as the arguments." | |
375 new_version()->SetStatus(ServiceWorkerVersion::INSTALLING); | |
376 | |
377 // "5. Fire a simple event named updatefound..." | |
378 registration()->NotifyUpdateFound(); | 378 registration()->NotifyUpdateFound(); |
379 | 379 |
380 // "6. Fire an event named install..." | 380 // "Fire an event named install..." |
381 new_version()->DispatchInstallEvent( | 381 new_version()->DispatchInstallEvent( |
382 -1, | 382 -1, |
383 base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, | 383 base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, |
384 weak_factory_.GetWeakPtr())); | 384 weak_factory_.GetWeakPtr())); |
385 } | 385 } |
386 | 386 |
387 void ServiceWorkerRegisterJob::OnInstallFinished( | 387 void ServiceWorkerRegisterJob::OnInstallFinished( |
388 ServiceWorkerStatusCode status) { | 388 ServiceWorkerStatusCode status) { |
389 // TODO(kinuko,falken): For some error cases (e.g. ServiceWorker is | 389 // TODO(kinuko,falken): For some error cases (e.g. ServiceWorker is |
390 // unexpectedly terminated) we may want to retry sending the event again. | 390 // unexpectedly terminated) we may want to retry sending the event again. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 ServiceWorkerProviderHost* host = it->GetProviderHost(); | 551 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
552 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), | 552 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), |
553 host->document_url())) { | 553 host->document_url())) { |
554 if (host->CanAssociateRegistration(registration)) | 554 if (host->CanAssociateRegistration(registration)) |
555 host->AssociateRegistration(registration); | 555 host->AssociateRegistration(registration); |
556 } | 556 } |
557 } | 557 } |
558 } | 558 } |
559 | 559 |
560 } // namespace content | 560 } // namespace content |
OLD | NEW |