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" |
11 #include "content/browser/service_worker/service_worker_job_coordinator.h" | 11 #include "content/browser/service_worker/service_worker_job_coordinator.h" |
12 #include "content/browser/service_worker/service_worker_registration.h" | 12 #include "content/browser/service_worker/service_worker_registration.h" |
13 #include "content/browser/service_worker/service_worker_storage.h" | 13 #include "content/browser/service_worker/service_worker_storage.h" |
14 #include "content/browser/service_worker/service_worker_utils.h" | 14 #include "content/browser/service_worker/service_worker_utils.h" |
15 #include "content/common/service_worker/service_worker_types.h" | 15 #include "content/common/service_worker/service_worker_types.h" |
| 16 #include "content/public/browser/browser_thread.h" |
16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 void RunSoon(const base::Closure& closure) { | 23 void RunSoon(const base::Closure& closure) { |
23 base::MessageLoop::current()->PostTask(FROM_HERE, closure); | 24 base::MessageLoop::current()->PostTask(FROM_HERE, closure); |
24 } | 25 } |
25 | 26 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 provider_host->AddScopedProcessReferenceToPattern(pattern_); | 75 provider_host->AddScopedProcessReferenceToPattern(pattern_); |
75 return; | 76 return; |
76 } | 77 } |
77 RunSoon(base::Bind(callback, promise_resolved_status_, | 78 RunSoon(base::Bind(callback, promise_resolved_status_, |
78 promise_resolved_status_message_, | 79 promise_resolved_status_message_, |
79 promise_resolved_registration_)); | 80 promise_resolved_registration_)); |
80 } | 81 } |
81 | 82 |
82 void ServiceWorkerRegisterJob::Start() { | 83 void ServiceWorkerRegisterJob::Start() { |
83 SetPhase(START); | 84 SetPhase(START); |
| 85 BrowserThread::PostAfterStartupTask( |
| 86 FROM_HERE, |
| 87 base::MessageLoop::current()->task_runner(), |
| 88 base::Bind(&ServiceWorkerRegisterJob::StartInternal, |
| 89 weak_factory_.GetWeakPtr())); |
| 90 } |
| 91 |
| 92 void ServiceWorkerRegisterJob::StartInternal() { |
| 93 if (phase_ != START) |
| 94 return; |
84 ServiceWorkerStorage::FindRegistrationCallback next_step; | 95 ServiceWorkerStorage::FindRegistrationCallback next_step; |
85 if (job_type_ == REGISTRATION_JOB) { | 96 if (job_type_ == REGISTRATION_JOB) { |
86 next_step = base::Bind( | 97 next_step = base::Bind( |
87 &ServiceWorkerRegisterJob::ContinueWithRegistration, | 98 &ServiceWorkerRegisterJob::ContinueWithRegistration, |
88 weak_factory_.GetWeakPtr()); | 99 weak_factory_.GetWeakPtr()); |
89 } else { | 100 } else { |
90 next_step = base::Bind( | 101 next_step = base::Bind( |
91 &ServiceWorkerRegisterJob::ContinueWithUpdate, | 102 &ServiceWorkerRegisterJob::ContinueWithUpdate, |
92 weak_factory_.GetWeakPtr()); | 103 weak_factory_.GetWeakPtr()); |
93 } | 104 } |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 ServiceWorkerProviderHost* host = it->GetProviderHost(); | 567 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
557 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), | 568 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), |
558 host->document_url())) { | 569 host->document_url())) { |
559 if (host->CanAssociateRegistration(registration)) | 570 if (host->CanAssociateRegistration(registration)) |
560 host->AssociateRegistration(registration); | 571 host->AssociateRegistration(registration); |
561 } | 572 } |
562 } | 573 } |
563 } | 574 } |
564 | 575 |
565 } // namespace content | 576 } // namespace content |
OLD | NEW |