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

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

Issue 1079923002: ServiceWorker: Stop exposing ServiceWorkerContextCore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up 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 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 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 FROM_HERE, 140 FROM_HERE,
141 base::Bind(&ServiceWorkerContextWrapper::ShutdownOnIO, this)); 141 base::Bind(&ServiceWorkerContextWrapper::ShutdownOnIO, this));
142 } 142 }
143 143
144 void ServiceWorkerContextWrapper::DeleteAndStartOver() { 144 void ServiceWorkerContextWrapper::DeleteAndStartOver() {
145 DCHECK_CURRENTLY_ON(BrowserThread::IO); 145 DCHECK_CURRENTLY_ON(BrowserThread::IO);
146 context_core_->DeleteAndStartOver( 146 context_core_->DeleteAndStartOver(
147 base::Bind(&ServiceWorkerContextWrapper::DidDeleteAndStartOver, this)); 147 base::Bind(&ServiceWorkerContextWrapper::DidDeleteAndStartOver, this));
148 } 148 }
149 149
150 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
151 DCHECK_CURRENTLY_ON(BrowserThread::IO);
152 return context_core_.get();
153 }
154
155 StoragePartitionImpl* ServiceWorkerContextWrapper::storage_partition() const { 150 StoragePartitionImpl* ServiceWorkerContextWrapper::storage_partition() const {
156 DCHECK_CURRENTLY_ON(BrowserThread::UI); 151 DCHECK_CURRENTLY_ON(BrowserThread::UI);
157 return storage_partition_; 152 return storage_partition_;
158 } 153 }
159 154
160 void ServiceWorkerContextWrapper::set_storage_partition( 155 void ServiceWorkerContextWrapper::set_storage_partition(
161 StoragePartitionImpl* storage_partition) { 156 StoragePartitionImpl* storage_partition) {
162 DCHECK_CURRENTLY_ON(BrowserThread::UI); 157 DCHECK_CURRENTLY_ON(BrowserThread::UI);
163 storage_partition_ = storage_partition; 158 storage_partition_ = storage_partition;
164 } 159 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 base::Bind(callback, false)); 386 base::Bind(callback, false));
392 return; 387 return;
393 } 388 }
394 GURL stripped_url = net::SimplifyUrlForRequest(url); 389 GURL stripped_url = net::SimplifyUrlForRequest(url);
395 context()->storage()->FindRegistrationForDocument( 390 context()->storage()->FindRegistrationForDocument(
396 stripped_url, base::Bind(&ServiceWorkerContextWrapper:: 391 stripped_url, base::Bind(&ServiceWorkerContextWrapper::
397 DidFindRegistrationForCheckHasServiceWorker, 392 DidFindRegistrationForCheckHasServiceWorker,
398 this, other_url, callback)); 393 this, other_url, callback));
399 } 394 }
400 395
396 ServiceWorkerRegistration* ServiceWorkerContextWrapper::GetLiveRegistration(
397 int64_t registration_id) {
398 DCHECK_CURRENTLY_ON(BrowserThread::IO);
399 if (!context_core_)
400 return nullptr;
401 return context_core_->GetLiveRegistration(registration_id);
402 }
403
404 ServiceWorkerVersion* ServiceWorkerContextWrapper::GetLiveVersion(
405 int64_t version_id) {
406 DCHECK_CURRENTLY_ON(BrowserThread::IO);
407 if (!context_core_)
408 return nullptr;
409 return context_core_->GetLiveVersion(version_id);
410 }
411
412 std::vector<ServiceWorkerRegistrationInfo>
413 ServiceWorkerContextWrapper::GetAllLiveRegistrationInfo() {
414 DCHECK_CURRENTLY_ON(BrowserThread::IO);
415 if (!context_core_)
416 return std::vector<ServiceWorkerRegistrationInfo>();
417 return context_core_->GetAllLiveRegistrationInfo();
418 }
419
420 std::vector<ServiceWorkerVersionInfo>
421 ServiceWorkerContextWrapper::GetAllLiveVersionInfo() {
422 DCHECK_CURRENTLY_ON(BrowserThread::IO);
423 if (!context_core_)
424 return std::vector<ServiceWorkerVersionInfo>();
425 return context_core_->GetAllLiveVersionInfo();
426 }
427
428 void ServiceWorkerContextWrapper::FindRegistrationForDocument(
429 const GURL& document_url,
430 const FindRegistrationCallback& callback) {
431 DCHECK_CURRENTLY_ON(BrowserThread::IO);
432 if (!context_core_) {
433 // FindRegistrationForDocument() can run the callback synchronously.
434 callback.Run(SERVICE_WORKER_ERROR_ABORT, nullptr);
435 return;
436 }
437 context_core_->storage()->FindRegistrationForDocument(document_url, callback);
438 }
439
440 void ServiceWorkerContextWrapper::FindRegistrationForId(
441 int64_t registration_id,
442 const GURL& origin,
443 const FindRegistrationCallback& callback) {
444 DCHECK_CURRENTLY_ON(BrowserThread::IO);
445 if (!context_core_) {
446 // FindRegistrationForId() can run the callback synchronously.
447 callback.Run(SERVICE_WORKER_ERROR_ABORT, nullptr);
448 return;
449 }
450 context_core_->storage()->FindRegistrationForId(registration_id, origin,
451 callback);
452 }
453
454 void ServiceWorkerContextWrapper::GetAllRegistrations(
455 const GetRegistrationsInfosCallback& callback) {
456 DCHECK_CURRENTLY_ON(BrowserThread::IO);
457 if (!context_core_) {
458 RunSoon(base::Bind(callback, std::vector<ServiceWorkerRegistrationInfo>()));
459 return;
460 }
461 context_core_->storage()->GetAllRegistrations(callback);
462 }
463
464 void ServiceWorkerContextWrapper::GetRegistrationUserData(
465 int64_t registration_id,
466 const std::string& key,
467 const GetUserDataCallback& callback) {
468 DCHECK_CURRENTLY_ON(BrowserThread::IO);
469 if (!context_core_) {
470 RunSoon(base::Bind(callback, std::string(), SERVICE_WORKER_ERROR_ABORT));
471 return;
472 }
473 context_core_->storage()->GetUserData(registration_id, key, callback);
474 }
475
476 void ServiceWorkerContextWrapper::StoreRegistrationUserData(
477 int64_t registration_id,
478 const GURL& origin,
479 const std::string& key,
480 const std::string& data,
481 const StatusCallback& callback) {
482 DCHECK_CURRENTLY_ON(BrowserThread::IO);
483 if (!context_core_) {
484 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
485 return;
486 }
487 context_core_->storage()->StoreUserData(registration_id, origin, key, data,
488 callback);
489 }
490
491 void ServiceWorkerContextWrapper::ClearRegistrationUserData(
492 int64_t registration_id,
493 const std::string& key,
494 const StatusCallback& callback) {
495 DCHECK_CURRENTLY_ON(BrowserThread::IO);
496 if (!context_core_) {
497 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
498 return;
499 }
500 context_core_->storage()->ClearUserData(registration_id, key, callback);
501 }
502
503 void ServiceWorkerContextWrapper::GetUserDataForAllRegistrations(
504 const std::string& key,
505 const GetUserDataForAllRegistrationsCallback& callback) {
506 DCHECK_CURRENTLY_ON(BrowserThread::IO);
507 if (!context_core_) {
508 RunSoon(base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(),
509 SERVICE_WORKER_ERROR_ABORT));
510 return;
511 }
512 context_core_->storage()->GetUserDataForAllRegistrations(key, callback);
513 }
514
401 void ServiceWorkerContextWrapper::AddObserver( 515 void ServiceWorkerContextWrapper::AddObserver(
402 ServiceWorkerContextObserver* observer) { 516 ServiceWorkerContextObserver* observer) {
403 observer_list_->AddObserver(observer); 517 observer_list_->AddObserver(observer);
404 } 518 }
405 519
406 void ServiceWorkerContextWrapper::RemoveObserver( 520 void ServiceWorkerContextWrapper::RemoveObserver(
407 ServiceWorkerContextObserver* observer) { 521 ServiceWorkerContextObserver* observer) {
408 observer_list_->RemoveObserver(observer); 522 observer_list_->RemoveObserver(observer);
409 } 523 }
410 524
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 context_core_.reset(); 570 context_core_.reset();
457 return; 571 return;
458 } 572 }
459 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); 573 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this));
460 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; 574 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully.";
461 575
462 observer_list_->Notify(FROM_HERE, 576 observer_list_->Notify(FROM_HERE,
463 &ServiceWorkerContextObserver::OnStorageWiped); 577 &ServiceWorkerContextObserver::OnStorageWiped);
464 } 578 }
465 579
580 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
581 DCHECK_CURRENTLY_ON(BrowserThread::IO);
582 return context_core_.get();
583 }
584
466 } // namespace content 585 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698