OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_watcher.h" | 5 #include "content/browser/service_worker/service_worker_context_watcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/containers/scoped_ptr_hash_map.h" | 8 #include "base/containers/scoped_ptr_hash_map.h" |
9 #include "content/browser/service_worker/service_worker_context_observer.h" | 9 #include "content/browser/service_worker/service_worker_context_observer.h" |
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 int64 registration_id = kInvalidServiceWorkerRegistrationId; | 231 int64 registration_id = kInvalidServiceWorkerRegistrationId; |
232 if (ServiceWorkerVersionInfo* version = version_info_map_.get(version_id)) | 232 if (ServiceWorkerVersionInfo* version = version_info_map_.get(version_id)) |
233 registration_id = version->registration_id; | 233 registration_id = version->registration_id; |
234 BrowserThread::PostTask( | 234 BrowserThread::PostTask( |
235 BrowserThread::UI, FROM_HERE, | 235 BrowserThread::UI, FROM_HERE, |
236 base::Bind(error_callback_, registration_id, version_id, | 236 base::Bind(error_callback_, registration_id, version_id, |
237 ErrorInfo(message.message, message.line_number, -1, | 237 ErrorInfo(message.message, message.line_number, -1, |
238 message.source_url))); | 238 message.source_url))); |
239 } | 239 } |
240 | 240 |
| 241 void ServiceWorkerContextWatcher::OnControlleeAdded( |
| 242 int64 version_id, |
| 243 const std::string& uuid, |
| 244 int process_id, |
| 245 int route_id, |
| 246 ServiceWorkerProviderType type) { |
| 247 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); |
| 248 DCHECK(version); |
| 249 version->clients[uuid] = |
| 250 ServiceWorkerVersionInfo::ClientInfo(process_id, route_id, type); |
| 251 SendVersionInfo(*version); |
| 252 } |
| 253 |
| 254 void ServiceWorkerContextWatcher::OnControlleeRemoved(int64 version_id, |
| 255 const std::string& uuid) { |
| 256 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); |
| 257 DCHECK(version); |
| 258 version->clients.erase(uuid); |
| 259 SendVersionInfo(*version); |
| 260 } |
| 261 |
241 void ServiceWorkerContextWatcher::OnRegistrationStored(int64 registration_id, | 262 void ServiceWorkerContextWatcher::OnRegistrationStored(int64 registration_id, |
242 const GURL& pattern) { | 263 const GURL& pattern) { |
243 SendRegistrationInfo(registration_id, pattern, | 264 SendRegistrationInfo(registration_id, pattern, |
244 ServiceWorkerRegistrationInfo::IS_NOT_DELETED); | 265 ServiceWorkerRegistrationInfo::IS_NOT_DELETED); |
245 } | 266 } |
246 | 267 |
247 void ServiceWorkerContextWatcher::OnRegistrationDeleted(int64 registration_id, | 268 void ServiceWorkerContextWatcher::OnRegistrationDeleted(int64 registration_id, |
248 const GURL& pattern) { | 269 const GURL& pattern) { |
249 SendRegistrationInfo(registration_id, pattern, | 270 SendRegistrationInfo(registration_id, pattern, |
250 ServiceWorkerRegistrationInfo::IS_DELETED); | 271 ServiceWorkerRegistrationInfo::IS_DELETED); |
251 } | 272 } |
252 | 273 |
253 } // namespace content | 274 } // namespace content |
OLD | NEW |