| 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 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { | 159 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { |
| 160 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 160 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 161 std::vector<ServiceWorkerUsageInfo> usage_infos; | 161 std::vector<ServiceWorkerUsageInfo> usage_infos; |
| 162 | 162 |
| 163 std::map<GURL, ServiceWorkerUsageInfo> origins; | 163 std::map<GURL, ServiceWorkerUsageInfo> origins; |
| 164 for (std::vector<ServiceWorkerRegistrationInfo>::const_iterator it = | 164 for (std::vector<ServiceWorkerRegistrationInfo>::const_iterator it = |
| 165 registrations.begin(); | 165 registrations.begin(); |
| 166 it != registrations.end(); | 166 it != registrations.end(); |
| 167 ++it) { | 167 ++it) { |
| 168 const ServiceWorkerRegistrationInfo& registration_info = *it; | 168 const ServiceWorkerRegistrationInfo& registration_info = *it; |
| 169 GURL origin = registration_info.script_url.GetOrigin(); | 169 GURL origin = registration_info.pattern.GetOrigin(); |
| 170 | 170 |
| 171 ServiceWorkerUsageInfo& usage_info = origins[origin]; | 171 ServiceWorkerUsageInfo& usage_info = origins[origin]; |
| 172 if (usage_info.origin.is_empty()) | 172 if (usage_info.origin.is_empty()) |
| 173 usage_info.origin = origin; | 173 usage_info.origin = origin; |
| 174 usage_info.scopes.push_back(registration_info.pattern); | 174 usage_info.scopes.push_back(registration_info.pattern); |
| 175 } | 175 } |
| 176 | 176 |
| 177 for (std::map<GURL, ServiceWorkerUsageInfo>::const_iterator it = | 177 for (std::map<GURL, ServiceWorkerUsageInfo>::const_iterator it = |
| 178 origins.begin(); | 178 origins.begin(); |
| 179 it != origins.end(); | 179 it != origins.end(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 202 void ServiceWorkerContextWrapper::DidGetAllRegistrationsForDeleteForOrigin( | 202 void ServiceWorkerContextWrapper::DidGetAllRegistrationsForDeleteForOrigin( |
| 203 const GURL& origin, | 203 const GURL& origin, |
| 204 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { | 204 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { |
| 205 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 205 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 206 | 206 |
| 207 for (std::vector<ServiceWorkerRegistrationInfo>::const_iterator it = | 207 for (std::vector<ServiceWorkerRegistrationInfo>::const_iterator it = |
| 208 registrations.begin(); | 208 registrations.begin(); |
| 209 it != registrations.end(); | 209 it != registrations.end(); |
| 210 ++it) { | 210 ++it) { |
| 211 const ServiceWorkerRegistrationInfo& registration_info = *it; | 211 const ServiceWorkerRegistrationInfo& registration_info = *it; |
| 212 if (origin == registration_info.script_url.GetOrigin()) { | 212 if (origin == registration_info.pattern.GetOrigin()) { |
| 213 UnregisterServiceWorker(registration_info.pattern, | 213 UnregisterServiceWorker(registration_info.pattern, |
| 214 base::Bind(&EmptySuccessCallback)); | 214 base::Bind(&EmptySuccessCallback)); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 void ServiceWorkerContextWrapper::AddObserver( | 219 void ServiceWorkerContextWrapper::AddObserver( |
| 220 ServiceWorkerContextObserver* observer) { | 220 ServiceWorkerContextObserver* observer) { |
| 221 observer_list_->AddObserver(observer); | 221 observer_list_->AddObserver(observer); |
| 222 } | 222 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 277 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 278 if (status != SERVICE_WORKER_OK) { | 278 if (status != SERVICE_WORKER_OK) { |
| 279 context_core_.reset(); | 279 context_core_.reset(); |
| 280 return; | 280 return; |
| 281 } | 281 } |
| 282 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); | 282 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); |
| 283 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; | 283 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace content | 286 } // namespace content |
| OLD | NEW |