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

Unified Diff: content/browser/service_worker/service_worker_storage.cc

Issue 113133013: Refactor job coordination into a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove WeakPtr usage from Storage Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_storage.cc
diff --git a/content/browser/service_worker/service_worker_storage.cc b/content/browser/service_worker/service_worker_storage.cc
index 16a671e20b8a929b45d29f5a925e826af96cd062..1f95cf708ebf630eccec8683fdfe2a8306b387ff 100644
--- a/content/browser/service_worker/service_worker_storage.cc
+++ b/content/browser/service_worker/service_worker_storage.cc
@@ -7,7 +7,6 @@
#include <string>
#include "base/strings/string_util.h"
-#include "content/browser/service_worker/service_worker_register_job.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/public/browser/browser_thread.h"
#include "webkit/browser/quota/quota_manager.h"
@@ -29,7 +28,7 @@ const base::FilePath::CharType kServiceWorkerDirectory[] =
ServiceWorkerStorage::ServiceWorkerStorage(
const base::FilePath& path,
quota::QuotaManagerProxy* quota_manager_proxy)
- : quota_manager_proxy_(quota_manager_proxy), weak_factory_(this) {
+ : quota_manager_proxy_(quota_manager_proxy) {
if (!path.empty())
path_ = path.Append(kServiceWorkerDirectory);
}
@@ -95,29 +94,6 @@ void ServiceWorkerStorage::FindRegistrationForDocument(
scoped_refptr<ServiceWorkerRegistration>()));
}
-void ServiceWorkerStorage::Register(const GURL& pattern,
- const GURL& script_url,
- const RegistrationCallback& callback) {
- scoped_ptr<ServiceWorkerRegisterJob> job(new ServiceWorkerRegisterJob(
- weak_factory_.GetWeakPtr(),
- base::Bind(&ServiceWorkerStorage::RegisterComplete,
- weak_factory_.GetWeakPtr(),
- callback)));
- job->StartRegister(pattern, script_url);
- registration_jobs_.push_back(job.release());
-}
-
-void ServiceWorkerStorage::Unregister(const GURL& pattern,
- const UnregistrationCallback& callback) {
- scoped_ptr<ServiceWorkerRegisterJob> job(new ServiceWorkerRegisterJob(
- weak_factory_.GetWeakPtr(),
- base::Bind(&ServiceWorkerStorage::UnregisterComplete,
- weak_factory_.GetWeakPtr(),
- callback)));
- job->StartUnregister(pattern);
- registration_jobs_.push_back(job.release());
-}
-
scoped_refptr<ServiceWorkerRegistration> ServiceWorkerStorage::RegisterInternal(
const GURL& pattern,
const GURL& script_url) {
@@ -161,34 +137,4 @@ bool ServiceWorkerStorage::PatternMatches(const GURL& pattern,
return MatchPattern(url.spec(), pattern_spec);
}
-void ServiceWorkerStorage::EraseJob(ServiceWorkerRegisterJob* job) {
- ScopedVector<ServiceWorkerRegisterJob>::iterator job_position =
- registration_jobs_.begin();
- for (; job_position != registration_jobs_.end(); ++job_position) {
- if (*job_position == job) {
- registration_jobs_.erase(job_position);
- return;
- }
- }
- NOTREACHED() << "Deleting non-existent job. ";
-}
-
-void ServiceWorkerStorage::UnregisterComplete(
- const UnregistrationCallback& callback,
- ServiceWorkerRegisterJob* job,
- ServiceWorkerRegistrationStatus status,
- ServiceWorkerRegistration* previous_registration) {
- callback.Run(status);
- EraseJob(job);
-}
-
-void ServiceWorkerStorage::RegisterComplete(
- const RegistrationCallback& callback,
- ServiceWorkerRegisterJob* job,
- ServiceWorkerRegistrationStatus status,
- ServiceWorkerRegistration* registration) {
- callback.Run(status, registration);
- EraseJob(job);
-}
-
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698