Chromium Code Reviews| 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_context_wrapper.h" | 5 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 123 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 124 | 124 |
| 125 storage_partition_ = nullptr; | 125 storage_partition_ = nullptr; |
| 126 process_manager_->Shutdown(); | 126 process_manager_->Shutdown(); |
| 127 BrowserThread::PostTask( | 127 BrowserThread::PostTask( |
| 128 BrowserThread::IO, | 128 BrowserThread::IO, |
| 129 FROM_HERE, | 129 FROM_HERE, |
| 130 base::Bind(&ServiceWorkerContextWrapper::ShutdownOnIO, this)); | 130 base::Bind(&ServiceWorkerContextWrapper::ShutdownOnIO, this)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void ServiceWorkerContextWrapper::InitializeOnIO( | |
|
michaeln
2016/03/08 22:04:27
naming nit driveby: since there already are Init()
falken
2016/03/10 01:25:35
Done.
| |
| 134 ResourceContext* resource_context, | |
| 135 scoped_refptr<net::URLRequestContextGetter> request_context_getter) { | |
| 136 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 137 resource_context_ = resource_context; | |
| 138 request_context_getter_ = request_context_getter; | |
| 139 request_context_getter_->AddObserver(this); | |
| 140 } | |
| 141 | |
| 142 void ServiceWorkerContextWrapper::OnContextShuttingDown() { | |
| 143 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
|
falken
2016/03/08 09:59:11
mmenke: URLRequestContextGetterObserver documentat
michaeln
2016/03/08 22:04:27
yes, content::iothread == net::networkthread
mmenke
2016/03/09 18:33:42
Correct. net/ is below content/, so doesn't know
| |
| 144 request_context_getter_->RemoveObserver(this); | |
| 145 | |
| 146 // OnContextShuttingDown is called when the ProfileIOData (ResourceContext) is | |
| 147 // shutting down, so call ShutdownOnIO() to clear resource_context_. | |
| 148 // This doesn't seem to be called when using content_shell, so we still must | |
|
mmenke
2016/03/09 18:33:42
This bug may still exist with content shell, or ot
| |
| 149 // also call ShutdownOnIO() in Shutdown(), which is called when the storage | |
| 150 // partition is destroyed. | |
| 151 ShutdownOnIO(); | |
| 152 } | |
| 153 | |
| 133 void ServiceWorkerContextWrapper::DeleteAndStartOver() { | 154 void ServiceWorkerContextWrapper::DeleteAndStartOver() { |
| 134 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 155 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 135 if (!context_core_) { | 156 if (!context_core_) { |
| 136 // The context could be null due to system shutdown or restart failure. In | 157 // The context could be null due to system shutdown or restart failure. In |
| 137 // either case, we should not have to recover the system, so just return | 158 // either case, we should not have to recover the system, so just return |
| 138 // here. | 159 // here. |
| 139 return; | 160 return; |
| 140 } | 161 } |
| 141 context_core_->DeleteAndStartOver( | 162 context_core_->DeleteAndStartOver( |
| 142 base::Bind(&ServiceWorkerContextWrapper::DidDeleteAndStartOver, this)); | 163 base::Bind(&ServiceWorkerContextWrapper::DidDeleteAndStartOver, this)); |
| 143 } | 164 } |
| 144 | 165 |
| 145 StoragePartitionImpl* ServiceWorkerContextWrapper::storage_partition() const { | 166 StoragePartitionImpl* ServiceWorkerContextWrapper::storage_partition() const { |
| 146 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 167 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 147 return storage_partition_; | 168 return storage_partition_; |
| 148 } | 169 } |
| 149 | 170 |
| 150 void ServiceWorkerContextWrapper::set_storage_partition( | 171 void ServiceWorkerContextWrapper::set_storage_partition( |
| 151 StoragePartitionImpl* storage_partition) { | 172 StoragePartitionImpl* storage_partition) { |
| 152 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 173 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 153 storage_partition_ = storage_partition; | 174 storage_partition_ = storage_partition; |
| 154 } | 175 } |
| 155 | 176 |
| 156 ResourceContext* ServiceWorkerContextWrapper::resource_context() { | 177 ResourceContext* ServiceWorkerContextWrapper::resource_context() { |
| 157 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 178 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 158 return resource_context_; | 179 return resource_context_; |
| 159 } | 180 } |
| 160 | 181 |
| 161 void ServiceWorkerContextWrapper::set_resource_context( | |
| 162 ResourceContext* resource_context) { | |
| 163 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 164 resource_context_ = resource_context; | |
| 165 } | |
| 166 | |
| 167 static void FinishRegistrationOnIO( | 182 static void FinishRegistrationOnIO( |
| 168 const ServiceWorkerContext::ResultCallback& continuation, | 183 const ServiceWorkerContext::ResultCallback& continuation, |
| 169 ServiceWorkerStatusCode status, | 184 ServiceWorkerStatusCode status, |
| 170 const std::string& status_message, | 185 const std::string& status_message, |
| 171 int64_t registration_id) { | 186 int64_t registration_id) { |
| 172 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 187 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 173 BrowserThread::PostTask( | 188 BrowserThread::PostTask( |
| 174 BrowserThread::UI, | 189 BrowserThread::UI, |
| 175 FROM_HERE, | 190 FROM_HERE, |
| 176 base::Bind(continuation, status == SERVICE_WORKER_OK)); | 191 base::Bind(continuation, status == SERVICE_WORKER_OK)); |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 observer_list_->Notify(FROM_HERE, | 713 observer_list_->Notify(FROM_HERE, |
| 699 &ServiceWorkerContextObserver::OnStorageWiped); | 714 &ServiceWorkerContextObserver::OnStorageWiped); |
| 700 } | 715 } |
| 701 | 716 |
| 702 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 717 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
| 703 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 718 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 704 return context_core_.get(); | 719 return context_core_.get(); |
| 705 } | 720 } |
| 706 | 721 |
| 707 } // namespace content | 722 } // namespace content |
| OLD | NEW |