 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_register_job.h | 
| diff --git a/content/browser/service_worker/service_worker_register_job.h b/content/browser/service_worker/service_worker_register_job.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..150834c00fec1cea88e13c09ba1606d732458561 | 
| --- /dev/null | 
| +++ b/content/browser/service_worker/service_worker_register_job.h | 
| @@ -0,0 +1,75 @@ | 
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 
| +#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 
| + | 
| +#include "base/memory/weak_ptr.h" | 
| +#include "content/browser/service_worker/service_worker_storage.h" | 
| + | 
| +namespace content { | 
| + | 
| +// A ServiceWorkerRegisterJob lives only for the lifetime of a single | 
| +// registration or unregistration. | 
| +class ServiceWorkerRegisterJob { | 
| + public: | 
| + typedef base::Callback< | 
| + void(ServiceWorkerRegisterJob*, | 
| + ServiceWorkerStorage::RegistrationStatus status, | 
| + ServiceWorkerRegistration*)> RegistrationCompleteCallback; | 
| + | 
| + // All type of jobs (Register and Unregister) complete through a | 
| + // single call to this callback on the IO thread. | 
| + ServiceWorkerRegisterJob(const base::WeakPtr<ServiceWorkerStorage>& storage, | 
| + const RegistrationCompleteCallback& callback); | 
| + ~ServiceWorkerRegisterJob(); | 
| + | 
| + // The Registration flow includes most or all of the following, | 
| + // depending on what is already registered: | 
| + // - creating a ServiceWorkerRegistration instance if there isn't | 
| + // already something registered | 
| + // - creating a ServiceWorkerVersion for the new registration instance. | 
| + // - starting a worker for the ServiceWorkerVersion | 
| + // - telling the Version to evaluate the script | 
| + // - firing the 'install' event at the ServiceWorkerVersion | 
| + // - firing the 'activate' event at the ServiceWorkerVersion | 
| + // - Waiting for older ServiceWorkerVersions to deactivate | 
| + // - designating the new version to be the 'active' version | 
| + void StartRegister(const GURL& pattern, const GURL& script_url); | 
| + | 
| + // The Unregistration process is primarily cleanup, removing | 
| + // everything that was created during the Registration process, | 
| + // including the ServiceWorkerRegistration itself. | 
| + void StartUnregister(const GURL& pattern); | 
| 
kinuko
2013/11/27 03:45:23
It's one off operation class, I think ideally havi
 
alecflett
2013/12/02 16:11:35
I'd like to avoid doing that just yet. They share
 | 
| + | 
| + private: | 
| + // These are all steps in the registration and unregistration pipeline. | 
| + void RegisterPatternAndContinue( | 
| + const GURL& pattern, | 
| + const GURL& script_url, | 
| + const ServiceWorkerStorage::RegistrationCallback& callback, | 
| + ServiceWorkerStorage::RegistrationStatus previous_status); | 
| + | 
| + void UnregisterPatternAndContinue( | 
| + const GURL& pattern, | 
| + const GURL& script_url, | 
| + const ServiceWorkerStorage::UnregistrationCallback& callback, | 
| + ServiceWorkerStorage::RegistrationStatus previous_status, | 
| + const scoped_refptr<ServiceWorkerRegistration>& previous_registration); | 
| + | 
| + // These methods convert | 
| + void UnregisterComplete(ServiceWorkerStorage::RegistrationStatus status); | 
| + void RegisterComplete( | 
| + ServiceWorkerStorage::RegistrationStatus status, | 
| + const scoped_refptr<ServiceWorkerRegistration>& registration); | 
| + | 
| + const base::WeakPtr<ServiceWorkerStorage> storage_; | 
| + const RegistrationCompleteCallback callback_; | 
| + base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); | 
| +}; | 
| +} // namespace content | 
| + | 
| +#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |