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

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

Issue 463013002: ServiceWorker: Implement updatefound event and version attributes (Chromium) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address for comments Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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_core.h" 5 #include "content/browser/service_worker/service_worker_context_core.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "content/browser/service_worker/embedded_worker_registry.h" 10 #include "content/browser/service_worker/embedded_worker_registry.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 storage_(ServiceWorkerStorage::Create(path, 95 storage_(ServiceWorkerStorage::Create(path,
96 AsWeakPtr(), 96 AsWeakPtr(),
97 database_task_runner, 97 database_task_runner,
98 disk_cache_thread, 98 disk_cache_thread,
99 quota_manager_proxy)), 99 quota_manager_proxy)),
100 cache_manager_( 100 cache_manager_(
101 ServiceWorkerCacheStorageManager::Create(path, cache_task_runner)), 101 ServiceWorkerCacheStorageManager::Create(path, cache_task_runner)),
102 embedded_worker_registry_(EmbeddedWorkerRegistry::Create(AsWeakPtr())), 102 embedded_worker_registry_(EmbeddedWorkerRegistry::Create(AsWeakPtr())),
103 job_coordinator_(new ServiceWorkerJobCoordinator(AsWeakPtr())), 103 job_coordinator_(new ServiceWorkerJobCoordinator(AsWeakPtr())),
104 next_handle_id_(0), 104 next_handle_id_(0),
105 next_registration_handle_id_(0),
105 observer_list_(observer_list) { 106 observer_list_(observer_list) {
106 } 107 }
107 108
108 ServiceWorkerContextCore::ServiceWorkerContextCore( 109 ServiceWorkerContextCore::ServiceWorkerContextCore(
109 ServiceWorkerContextCore* old_context, 110 ServiceWorkerContextCore* old_context,
110 ServiceWorkerContextWrapper* wrapper) 111 ServiceWorkerContextWrapper* wrapper)
111 : weak_factory_(this), 112 : weak_factory_(this),
112 wrapper_(wrapper), 113 wrapper_(wrapper),
113 providers_(old_context->providers_.release()), 114 providers_(old_context->providers_.release()),
114 storage_( 115 storage_(
115 ServiceWorkerStorage::Create(AsWeakPtr(), old_context->storage())), 116 ServiceWorkerStorage::Create(AsWeakPtr(), old_context->storage())),
116 cache_manager_(ServiceWorkerCacheStorageManager::Create( 117 cache_manager_(ServiceWorkerCacheStorageManager::Create(
117 old_context->cache_manager())), 118 old_context->cache_manager())),
118 embedded_worker_registry_(EmbeddedWorkerRegistry::Create( 119 embedded_worker_registry_(EmbeddedWorkerRegistry::Create(
119 AsWeakPtr(), 120 AsWeakPtr(),
120 old_context->embedded_worker_registry())), 121 old_context->embedded_worker_registry())),
121 job_coordinator_(new ServiceWorkerJobCoordinator(AsWeakPtr())), 122 job_coordinator_(new ServiceWorkerJobCoordinator(AsWeakPtr())),
122 next_handle_id_(0), 123 next_handle_id_(0),
124 next_registration_handle_id_(0),
123 observer_list_(old_context->observer_list_) { 125 observer_list_(old_context->observer_list_) {
124 } 126 }
125 127
126 ServiceWorkerContextCore::~ServiceWorkerContextCore() { 128 ServiceWorkerContextCore::~ServiceWorkerContextCore() {
127 for (VersionMap::iterator it = live_versions_.begin(); 129 for (VersionMap::iterator it = live_versions_.begin();
128 it != live_versions_.end(); 130 it != live_versions_.end();
129 ++it) { 131 ++it) {
130 it->second->RemoveListener(this); 132 it->second->RemoveListener(this);
131 } 133 }
132 weak_factory_.InvalidateWeakPtrs(); 134 weak_factory_.InvalidateWeakPtrs();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 ++iter) { 312 ++iter) {
311 infos.push_back(iter->second->GetInfo()); 313 infos.push_back(iter->second->GetInfo());
312 } 314 }
313 return infos; 315 return infos;
314 } 316 }
315 317
316 int ServiceWorkerContextCore::GetNewServiceWorkerHandleId() { 318 int ServiceWorkerContextCore::GetNewServiceWorkerHandleId() {
317 return next_handle_id_++; 319 return next_handle_id_++;
318 } 320 }
319 321
322 int ServiceWorkerContextCore::GetNewRegistrationHandleId() {
323 return next_registration_handle_id_++;
324 }
325
320 void ServiceWorkerContextCore::ScheduleDeleteAndStartOver() const { 326 void ServiceWorkerContextCore::ScheduleDeleteAndStartOver() const {
321 storage_->Disable(); 327 storage_->Disable();
322 base::MessageLoop::current()->PostTask( 328 base::MessageLoop::current()->PostTask(
323 FROM_HERE, 329 FROM_HERE,
324 base::Bind(&ServiceWorkerContextWrapper::DeleteAndStartOver, wrapper_)); 330 base::Bind(&ServiceWorkerContextWrapper::DeleteAndStartOver, wrapper_));
325 } 331 }
326 332
327 void ServiceWorkerContextCore::DeleteAndStartOver( 333 void ServiceWorkerContextCore::DeleteAndStartOver(
328 const StatusCallback& callback) { 334 const StatusCallback& callback) {
329 job_coordinator_->AbortAll(); 335 job_coordinator_->AbortAll();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 version->embedded_worker()->thread_id(), 395 version->embedded_worker()->thread_id(),
390 ServiceWorkerContextObserver::ConsoleMessage( 396 ServiceWorkerContextObserver::ConsoleMessage(
391 source_identifier, message_level, message, line_number, source_url)); 397 source_identifier, message_level, message, line_number, source_url));
392 } 398 }
393 399
394 ServiceWorkerProcessManager* ServiceWorkerContextCore::process_manager() { 400 ServiceWorkerProcessManager* ServiceWorkerContextCore::process_manager() {
395 return wrapper_->process_manager(); 401 return wrapper_->process_manager();
396 } 402 }
397 403
398 } // namespace content 404 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698