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

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

Issue 1079923002: ServiceWorker: Stop exposing ServiceWorkerContextCore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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 "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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 void ServiceWorkerContextWatcher::Stop() { 48 void ServiceWorkerContextWatcher::Stop() {
49 DCHECK_CURRENTLY_ON(BrowserThread::UI); 49 DCHECK_CURRENTLY_ON(BrowserThread::UI);
50 BrowserThread::PostTask( 50 BrowserThread::PostTask(
51 BrowserThread::IO, FROM_HERE, 51 BrowserThread::IO, FROM_HERE,
52 base::Bind(&ServiceWorkerContextWatcher::StopOnIOThread, this)); 52 base::Bind(&ServiceWorkerContextWatcher::StopOnIOThread, this));
53 } 53 }
54 54
55 void ServiceWorkerContextWatcher::GetStoredRegistrationsOnIOThread() { 55 void ServiceWorkerContextWatcher::GetStoredRegistrationsOnIOThread() {
56 DCHECK_CURRENTLY_ON(BrowserThread::IO); 56 DCHECK_CURRENTLY_ON(BrowserThread::IO);
57 context_->context()->storage()->GetAllRegistrations(base::Bind( 57 context_->GetAllRegistrations(base::Bind(
58 &ServiceWorkerContextWatcher::OnStoredRegistrationsOnIOThread, this)); 58 &ServiceWorkerContextWatcher::OnStoredRegistrationsOnIOThread, this));
59 } 59 }
60 60
61 void ServiceWorkerContextWatcher::OnStoredRegistrationsOnIOThread( 61 void ServiceWorkerContextWatcher::OnStoredRegistrationsOnIOThread(
62 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) { 62 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) {
63 DCHECK_CURRENTLY_ON(BrowserThread::IO); 63 DCHECK_CURRENTLY_ON(BrowserThread::IO);
64 context_->AddObserver(this); 64 context_->AddObserver(this);
65 65
66 base::ScopedPtrHashMap<int64, ServiceWorkerRegistrationInfo> 66 base::ScopedPtrHashMap<int64, ServiceWorkerRegistrationInfo>
67 registration_info_map; 67 registration_info_map;
68 for (const auto& registration : stored_registrations) 68 for (const auto& registration : stored_registrations)
69 StoreRegistrationInfo(registration, &registration_info_map); 69 StoreRegistrationInfo(registration, &registration_info_map);
70 for (const auto& registration : 70 for (const auto& registration : context_->GetAllLiveRegistrationInfo())
71 context_->context()->GetAllLiveRegistrationInfo()) {
72 StoreRegistrationInfo(registration, &registration_info_map); 71 StoreRegistrationInfo(registration, &registration_info_map);
73 } 72 for (const auto& version : context_->GetAllLiveVersionInfo())
74 for (const auto& version : context_->context()->GetAllLiveVersionInfo())
75 StoreVersionInfo(version); 73 StoreVersionInfo(version);
76 74
77 std::vector<ServiceWorkerRegistrationInfo> registrations; 75 std::vector<ServiceWorkerRegistrationInfo> registrations;
78 registrations.reserve(registration_info_map.size()); 76 registrations.reserve(registration_info_map.size());
79 for (const auto& registration_id_info_pair : registration_info_map) 77 for (const auto& registration_id_info_pair : registration_info_map)
80 registrations.push_back(*registration_id_info_pair.second); 78 registrations.push_back(*registration_id_info_pair.second);
81 79
82 std::vector<ServiceWorkerVersionInfo> versions; 80 std::vector<ServiceWorkerVersionInfo> versions;
83 versions.reserve(version_info_map_.size()); 81 versions.reserve(version_info_map_.size());
84 82
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 ServiceWorkerRegistrationInfo::IS_NOT_DELETED); 243 ServiceWorkerRegistrationInfo::IS_NOT_DELETED);
246 } 244 }
247 245
248 void ServiceWorkerContextWatcher::OnRegistrationDeleted(int64 registration_id, 246 void ServiceWorkerContextWatcher::OnRegistrationDeleted(int64 registration_id,
249 const GURL& pattern) { 247 const GURL& pattern) {
250 SendRegistrationInfo(registration_id, pattern, 248 SendRegistrationInfo(registration_id, pattern,
251 ServiceWorkerRegistrationInfo::IS_DELETED); 249 ServiceWorkerRegistrationInfo::IS_DELETED);
252 } 250 }
253 251
254 } // namespace content 252 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698