 Chromium Code Reviews
 Chromium Code Reviews Issue 62203007:
  Implement memory-persistent registration  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 62203007:
  Implement memory-persistent registration  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: content/browser/service_worker/service_worker_context_core.cc | 
| diff --git a/content/browser/service_worker/service_worker_context_core.cc b/content/browser/service_worker/service_worker_context_core.cc | 
| index 9cb2cbecef8b2969c06f0e9e6302e0cd5b85cf09..3f32a8077d9d954f3bb48d49322181a44f669a27 100644 | 
| --- a/content/browser/service_worker/service_worker_context_core.cc | 
| +++ b/content/browser/service_worker/service_worker_context_core.cc | 
| @@ -6,24 +6,28 @@ | 
| #include "base/command_line.h" | 
| #include "base/files/file_path.h" | 
| +#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/browser/service_worker/service_worker_storage.h" | 
| +#include "content/public/browser/browser_thread.h" | 
| #include "content/public/common/content_switches.h" | 
| -#include "webkit/browser/quota/quota_manager.h" | 
| +#include "url/gurl.h" | 
| namespace content { | 
| -namespace { | 
| - | 
| -const base::FilePath::CharType kServiceWorkerDirectory[] = | 
| - FILE_PATH_LITERAL("ServiceWorker"); | 
| - | 
| -} // namespace | 
| - | 
| ServiceWorkerContextCore::ServiceWorkerContextCore( | 
| - const base::FilePath& user_data_directory, | 
| + const base::FilePath& path, | 
| quota::QuotaManagerProxy* quota_manager_proxy) | 
| - : quota_manager_proxy_(quota_manager_proxy) { | 
| - if (!user_data_directory.empty()) | 
| - path_ = user_data_directory.Append(kServiceWorkerDirectory); | 
| + : storage_(new ServiceWorkerStorage(path, quota_manager_proxy)), | 
| + is_shutdown_(false) {} | 
| + | 
| +ServiceWorkerContextCore::~ServiceWorkerContextCore() { DCHECK(is_shutdown_); } | 
| + | 
| +void ServiceWorkerContextCore::Shutdown() { | 
| 
kinuko
2013/11/25 08:17:10
When this is expected to be called? If this is alw
 
alecflett
2013/11/26 00:19:14
So here the pattern is that the refcounted objects
 | 
| + storage_->Shutdown(); | 
| + storage_.reset(); | 
| + is_shutdown_ = true; | 
| } | 
| bool ServiceWorkerContextCore::IsEnabled() { | 
| @@ -31,7 +35,31 @@ bool ServiceWorkerContextCore::IsEnabled() { | 
| switches::kEnableServiceWorker); | 
| } | 
| -ServiceWorkerContextCore::~ServiceWorkerContextCore() { | 
| +void ServiceWorkerContextCore::RegistrationComplete( | 
| 
kinuko
2013/11/25 08:17:10
nit: method order. (I'm so accustomed to the style
 
alecflett
2013/11/26 00:19:14
Sorry, I'll try to be consistent there.
 | 
| + const ServiceWorkerContextCore::ResponseCallback& callback, | 
| + const scoped_refptr<ServiceWorkerRegistration>& registration) { | 
| + callback.Run(registration->id()); | 
| 
kinuko
2013/11/25 08:17:10
nit: until we need registration reference in this
 
alecflett
2013/11/26 00:19:14
Well I'm trying to shield the Storage objects from
 | 
| +} | 
| + | 
| +void ServiceWorkerContextCore::RegisterServiceWorker( | 
| + const GURL& pattern, | 
| + const GURL& script_url, | 
| + const ResponseCallback& callback) { | 
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 
| + | 
| + storage_->Register(pattern, | 
| + script_url, | 
| + base::Bind(&ServiceWorkerContextCore::RegistrationComplete, | 
| + AsWeakPtr(), | 
| + callback)); | 
| +} | 
| + | 
| +void ServiceWorkerContextCore::UnregisterServiceWorker( | 
| + const GURL& pattern, | 
| + const base::Closure& callback) { | 
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 
| + | 
| + storage_->Unregister(pattern, callback); | 
| } | 
| } // namespace content |