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 20 matching lines...) Expand all Loading... |
31 const GURL& script_url) | 31 const GURL& script_url) |
32 : context_(context), | 32 : context_(context), |
33 pattern_(pattern), | 33 pattern_(pattern), |
34 script_url_(script_url), | 34 script_url_(script_url), |
35 phase_(INITIAL), | 35 phase_(INITIAL), |
36 is_promise_resolved_(false), | 36 is_promise_resolved_(false), |
37 promise_resolved_status_(SERVICE_WORKER_OK), | 37 promise_resolved_status_(SERVICE_WORKER_OK), |
38 weak_factory_(this) {} | 38 weak_factory_(this) {} |
39 | 39 |
40 ServiceWorkerRegisterJob::~ServiceWorkerRegisterJob() { | 40 ServiceWorkerRegisterJob::~ServiceWorkerRegisterJob() { |
41 DCHECK(phase_ == INITIAL || phase_ == COMPLETE); | 41 DCHECK(!context_ || phase_ == INITIAL || phase_ == COMPLETE) |
| 42 << "Jobs should only be interrupted during shutdown."; |
42 } | 43 } |
43 | 44 |
44 void ServiceWorkerRegisterJob::AddCallback(const RegistrationCallback& callback, | 45 void ServiceWorkerRegisterJob::AddCallback(const RegistrationCallback& callback, |
45 int process_id) { | 46 int process_id) { |
46 if (!is_promise_resolved_) { | 47 if (!is_promise_resolved_) { |
47 callbacks_.push_back(callback); | 48 callbacks_.push_back(callback); |
48 if (process_id != -1 && (phase_ < UPDATE || !pending_version())) | 49 if (process_id != -1 && (phase_ < UPDATE || !pending_version())) |
49 pending_process_ids_.push_back(process_id); | 50 pending_process_ids_.push_back(process_id); |
50 return; | 51 return; |
51 } | 52 } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 !it->IsAtEnd(); | 407 !it->IsAtEnd(); |
407 it->Advance()) { | 408 it->Advance()) { |
408 ServiceWorkerProviderHost* provider_host = it->GetProviderHost(); | 409 ServiceWorkerProviderHost* provider_host = it->GetProviderHost(); |
409 if (ServiceWorkerUtils::ScopeMatches(pattern_, | 410 if (ServiceWorkerUtils::ScopeMatches(pattern_, |
410 provider_host->document_url())) | 411 provider_host->document_url())) |
411 provider_host->SetPendingVersion(version); | 412 provider_host->SetPendingVersion(version); |
412 } | 413 } |
413 } | 414 } |
414 | 415 |
415 } // namespace content | 416 } // namespace content |
OLD | NEW |