| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 ServiceWorkerVersion* version_; | 53 ServiceWorkerVersion* version_; |
| 54 | 54 |
| 55 mojo::AssociatedBinding<mojom::ServiceWorkerInstallEventMethods> | 55 mojo::AssociatedBinding<mojom::ServiceWorkerInstallEventMethods> |
| 56 install_methods_binding_; | 56 install_methods_binding_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(InstallEventMethodsReceiver); | 58 DISALLOW_COPY_AND_ASSIGN(InstallEventMethodsReceiver); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 void RunSoon(const base::Closure& closure) { | 61 void RunSoonFunctionCopy18(const base::Closure& closure) { |
| 62 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); | 62 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 typedef ServiceWorkerRegisterJobBase::RegistrationJobType RegistrationJobType; | 67 typedef ServiceWorkerRegisterJobBase::RegistrationJobType RegistrationJobType; |
| 68 | 68 |
| 69 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob( | 69 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob( |
| 70 base::WeakPtr<ServiceWorkerContextCore> context, | 70 base::WeakPtr<ServiceWorkerContextCore> context, |
| 71 const GURL& script_url, | 71 const GURL& script_url, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 void ServiceWorkerRegisterJob::AddCallback( | 111 void ServiceWorkerRegisterJob::AddCallback( |
| 112 const RegistrationCallback& callback, | 112 const RegistrationCallback& callback, |
| 113 ServiceWorkerProviderHost* provider_host) { | 113 ServiceWorkerProviderHost* provider_host) { |
| 114 if (!is_promise_resolved_) { | 114 if (!is_promise_resolved_) { |
| 115 callbacks_.push_back(callback); | 115 callbacks_.push_back(callback); |
| 116 if (provider_host) | 116 if (provider_host) |
| 117 provider_host->AddScopedProcessReferenceToPattern(pattern_); | 117 provider_host->AddScopedProcessReferenceToPattern(pattern_); |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 RunSoon(base::Bind(callback, promise_resolved_status_, | 120 RunSoonFunctionCopy18(base::Bind(callback, promise_resolved_status_, |
| 121 promise_resolved_status_message_, | 121 promise_resolved_status_message_, |
| 122 base::RetainedRef(promise_resolved_registration_))); | 122 base::RetainedRef(promise_resolved_registration_))); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void ServiceWorkerRegisterJob::Start() { | 125 void ServiceWorkerRegisterJob::Start() { |
| 126 BrowserThread::PostAfterStartupTask( | 126 BrowserThread::PostAfterStartupTask( |
| 127 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), | 127 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), |
| 128 base::Bind(&ServiceWorkerRegisterJob::StartImpl, | 128 base::Bind(&ServiceWorkerRegisterJob::StartImpl, |
| 129 weak_factory_.GetWeakPtr())); | 129 weak_factory_.GetWeakPtr())); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void ServiceWorkerRegisterJob::StartImpl() { | 132 void ServiceWorkerRegisterJob::StartImpl() { |
| 133 SetPhase(START); | 133 SetPhase(START); |
| 134 ServiceWorkerStorage::FindRegistrationCallback next_step; | 134 ServiceWorkerStorage::FindRegistrationCallback next_step; |
| 135 if (job_type_ == REGISTRATION_JOB) { | 135 if (job_type_ == REGISTRATION_JOB) { |
| 136 next_step = base::Bind( | 136 next_step = base::Bind( |
| 137 &ServiceWorkerRegisterJob::ContinueWithRegistration, | 137 &ServiceWorkerRegisterJob::ContinueWithRegistration, |
| 138 weak_factory_.GetWeakPtr()); | 138 weak_factory_.GetWeakPtr()); |
| 139 } else { | 139 } else { |
| 140 next_step = base::Bind( | 140 next_step = base::Bind( |
| 141 &ServiceWorkerRegisterJob::ContinueWithUpdate, | 141 &ServiceWorkerRegisterJob::ContinueWithUpdate, |
| 142 weak_factory_.GetWeakPtr()); | 142 weak_factory_.GetWeakPtr()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 scoped_refptr<ServiceWorkerRegistration> registration = | 145 scoped_refptr<ServiceWorkerRegistration> registration = |
| 146 context_->storage()->GetUninstallingRegistration(pattern_); | 146 context_->storage()->GetUninstallingRegistration(pattern_); |
| 147 if (registration.get()) | 147 if (registration.get()) |
| 148 RunSoon(base::Bind(next_step, SERVICE_WORKER_OK, registration)); | 148 RunSoonFunctionCopy18(base::Bind(next_step, SERVICE_WORKER_OK, registration)
); |
| 149 else | 149 else |
| 150 context_->storage()->FindRegistrationForPattern(pattern_, next_step); | 150 context_->storage()->FindRegistrationForPattern(pattern_, next_step); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void ServiceWorkerRegisterJob::Abort() { | 153 void ServiceWorkerRegisterJob::Abort() { |
| 154 SetPhase(ABORT); | 154 SetPhase(ABORT); |
| 155 CompleteInternal(SERVICE_WORKER_ERROR_ABORT, std::string()); | 155 CompleteInternal(SERVICE_WORKER_ERROR_ABORT, std::string()); |
| 156 // Don't have to call FinishJob() because the caller takes care of removing | 156 // Don't have to call FinishJob() because the caller takes care of removing |
| 157 // the jobs from the queue. | 157 // the jobs from the queue. |
| 158 } | 158 } |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 new_version()->force_bypass_cache_for_scripts() || | 672 new_version()->force_bypass_cache_for_scripts() || |
| 673 registration()->last_update_check().is_null()) { | 673 registration()->last_update_check().is_null()) { |
| 674 registration()->set_last_update_check(base::Time::Now()); | 674 registration()->set_last_update_check(base::Time::Now()); |
| 675 | 675 |
| 676 if (registration()->has_installed_version()) | 676 if (registration()->has_installed_version()) |
| 677 context_->storage()->UpdateLastUpdateCheckTime(registration()); | 677 context_->storage()->UpdateLastUpdateCheckTime(registration()); |
| 678 } | 678 } |
| 679 } | 679 } |
| 680 | 680 |
| 681 } // namespace content | 681 } // namespace content |
| OLD | NEW |