Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: content/browser/service_worker/service_worker_context_watcher.cc

Issue 1693303002: ServiceWorker: Make ServiceWorkerStorage more self-defensive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/containers/scoped_ptr_hash_map.h" 10 #include "base/containers/scoped_ptr_hash_map.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 base::Bind(&ServiceWorkerContextWatcher::StopOnIOThread, this)); 54 base::Bind(&ServiceWorkerContextWatcher::StopOnIOThread, this));
55 } 55 }
56 56
57 void ServiceWorkerContextWatcher::GetStoredRegistrationsOnIOThread() { 57 void ServiceWorkerContextWatcher::GetStoredRegistrationsOnIOThread() {
58 DCHECK_CURRENTLY_ON(BrowserThread::IO); 58 DCHECK_CURRENTLY_ON(BrowserThread::IO);
59 context_->GetAllRegistrations(base::Bind( 59 context_->GetAllRegistrations(base::Bind(
60 &ServiceWorkerContextWatcher::OnStoredRegistrationsOnIOThread, this)); 60 &ServiceWorkerContextWatcher::OnStoredRegistrationsOnIOThread, this));
61 } 61 }
62 62
63 void ServiceWorkerContextWatcher::OnStoredRegistrationsOnIOThread( 63 void ServiceWorkerContextWatcher::OnStoredRegistrationsOnIOThread(
64 ServiceWorkerStatusCode status,
64 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) { 65 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) {
65 DCHECK_CURRENTLY_ON(BrowserThread::IO); 66 DCHECK_CURRENTLY_ON(BrowserThread::IO);
66 context_->AddObserver(this); 67 context_->AddObserver(this);
67 68
68 base::ScopedPtrHashMap<int64_t, scoped_ptr<ServiceWorkerRegistrationInfo>> 69 base::ScopedPtrHashMap<int64_t, scoped_ptr<ServiceWorkerRegistrationInfo>>
69 registration_info_map; 70 registration_info_map;
70 for (const auto& registration : stored_registrations) 71 for (const auto& registration : stored_registrations)
71 StoreRegistrationInfo(registration, &registration_info_map); 72 StoreRegistrationInfo(registration, &registration_info_map);
72 for (const auto& registration : context_->GetAllLiveRegistrationInfo()) 73 for (const auto& registration : context_->GetAllLiveRegistrationInfo())
73 StoreRegistrationInfo(registration, &registration_info_map); 74 StoreRegistrationInfo(registration, &registration_info_map);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 context_->GetLiveRegistration(registration_id); 288 context_->GetLiveRegistration(registration_id);
288 if (!registration) 289 if (!registration)
289 return; 290 return;
290 std::vector<ServiceWorkerRegistrationInfo> registrations; 291 std::vector<ServiceWorkerRegistrationInfo> registrations;
291 registrations.push_back(registration->GetInfo()); 292 registrations.push_back(registration->GetInfo());
292 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 293 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
293 base::Bind(registration_callback_, registrations)); 294 base::Bind(registration_callback_, registrations));
294 } 295 }
295 296
296 } // namespace content 297 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698