| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 ServiceWorkerVersion* version_; | 54 ServiceWorkerVersion* version_; |
| 55 | 55 |
| 56 mojo::AssociatedBinding<mojom::ServiceWorkerInstallEventMethods> | 56 mojo::AssociatedBinding<mojom::ServiceWorkerInstallEventMethods> |
| 57 install_methods_binding_; | 57 install_methods_binding_; |
| 58 | 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(InstallEventMethodsReceiver); | 59 DISALLOW_COPY_AND_ASSIGN(InstallEventMethodsReceiver); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 void RunSoon(const base::Closure& closure) { | 62 void RunSoonFunctionCopy18(const base::Closure& closure) { |
| 63 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); | 63 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 typedef ServiceWorkerRegisterJobBase::RegistrationJobType RegistrationJobType; | 68 typedef ServiceWorkerRegisterJobBase::RegistrationJobType RegistrationJobType; |
| 69 | 69 |
| 70 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob( | 70 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob( |
| 71 base::WeakPtr<ServiceWorkerContextCore> context, | 71 base::WeakPtr<ServiceWorkerContextCore> context, |
| 72 const GURL& script_url, | 72 const GURL& script_url, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 void ServiceWorkerRegisterJob::AddCallback( | 110 void ServiceWorkerRegisterJob::AddCallback( |
| 111 const RegistrationCallback& callback, | 111 const RegistrationCallback& callback, |
| 112 ServiceWorkerProviderHost* provider_host) { | 112 ServiceWorkerProviderHost* provider_host) { |
| 113 if (!is_promise_resolved_) { | 113 if (!is_promise_resolved_) { |
| 114 callbacks_.push_back(callback); | 114 callbacks_.push_back(callback); |
| 115 if (provider_host) | 115 if (provider_host) |
| 116 provider_host->AddScopedProcessReferenceToPattern(pattern_); | 116 provider_host->AddScopedProcessReferenceToPattern(pattern_); |
| 117 return; | 117 return; |
| 118 } | 118 } |
| 119 RunSoon(base::Bind(callback, promise_resolved_status_, | 119 RunSoonFunctionCopy18(base::Bind(callback, promise_resolved_status_, |
| 120 promise_resolved_status_message_, | 120 promise_resolved_status_message_, |
| 121 base::RetainedRef(promise_resolved_registration_))); | 121 base::RetainedRef(promise_resolved_registration_))); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void ServiceWorkerRegisterJob::Start() { | 124 void ServiceWorkerRegisterJob::Start() { |
| 125 start_time_ = base::TimeTicks::Now(); | 125 start_time_ = base::TimeTicks::Now(); |
| 126 BrowserThread::PostAfterStartupTask( | 126 BrowserThread::PostAfterStartupTask( |
| 127 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), | 127 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), |
| 128 base::BindOnce(&ServiceWorkerRegisterJob::StartImpl, | 128 base::BindOnce(&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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 new_version()->force_bypass_cache_for_scripts() || | 665 new_version()->force_bypass_cache_for_scripts() || |
| 666 registration()->last_update_check().is_null()) { | 666 registration()->last_update_check().is_null()) { |
| 667 registration()->set_last_update_check(base::Time::Now()); | 667 registration()->set_last_update_check(base::Time::Now()); |
| 668 | 668 |
| 669 if (registration()->has_installed_version()) | 669 if (registration()->has_installed_version()) |
| 670 context_->storage()->UpdateLastUpdateCheckTime(registration()); | 670 context_->storage()->UpdateLastUpdateCheckTime(registration()); |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 | 673 |
| 674 } // namespace content | 674 } // namespace content |
| OLD | NEW |