Chromium Code Reviews| Index: content/browser/service_worker/service_worker_registration.h |
| diff --git a/content/browser/service_worker/service_worker_registration.h b/content/browser/service_worker/service_worker_registration.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7dda160bc8cf5b889333435a6ae5c84d75dc3aec |
| --- /dev/null |
| +++ b/content/browser/service_worker/service_worker_registration.h |
| @@ -0,0 +1,65 @@ |
| +// 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_REGISTRATION_H_ |
| +#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/logging.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "content/browser/service_worker/service_worker_version.h" |
| + |
| +class GURL; |
| + |
| +namespace content { |
| + |
| +class ServiceWorkerVersion; |
| + |
| +// This class acts as a persistent instance |
| +class ServiceWorkerRegistration |
| + : public base::RefCountedThreadSafe<ServiceWorkerRegistration> { |
|
michaeln
2013/11/11 23:48:24
Is there a reason to make this a thread-safe? I th
|
| + public: |
| + ServiceWorkerRegistration(const GURL& pattern, |
|
michaeln
2013/11/11 23:48:24
other places we use the term 'scope', here it's 'p
|
| + const GURL& script_url, |
| + int32 service_worker_id); |
|
michaeln
2013/11/11 23:48:24
registration_id this arg s/b called registration_i
|
| + |
| + int32 id() const { return registration_id_; } |
|
kinuko
2013/11/08 09:08:21
We're using int64 in other files
alecflett
2013/11/08 22:50:54
Done.
|
| + |
| + void Shutdown(); |
| + |
| + ServiceWorkerVersion* active_version() { |
| + DCHECK(!is_shutdown_); |
| + return active_version_.get(); |
| + } |
| + ServiceWorkerVersion* in_waiting_version() { |
| + return in_waiting_version_.get(); |
| + } |
| + |
| + void set_active_version(ServiceWorkerVersion* version) { |
| + DCHECK(!is_shutdown_); |
| + active_version_.reset(version); |
| + } |
| + void set_in_waiting_version(ServiceWorkerVersion* version) { |
| + DCHECK(!is_shutdown_); |
| + in_waiting_version_.reset(version); |
| + } |
| + |
| + private: |
| + virtual ~ServiceWorkerRegistration(); |
| + friend class base::RefCountedThreadSafe<ServiceWorkerRegistration>; |
| + |
| + const GURL& pattern_; |
| + const GURL& script_url_; |
| + const int32 registration_id_; |
| + |
| + scoped_ptr<ServiceWorkerVersion> active_version_; |
| + scoped_ptr<ServiceWorkerVersion> in_waiting_version_; |
| + |
| + bool is_shutdown_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration); |
| +}; |
| +} |
| +#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ |