Chromium Code Reviews| Index: content/child/service_worker/scoped_service_worker_reference.h |
| diff --git a/content/child/service_worker/scoped_service_worker_reference.h b/content/child/service_worker/scoped_service_worker_reference.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b14f32a8384c5e6f8466979bee05cf7a340a2bf5 |
| --- /dev/null |
| +++ b/content/child/service_worker/scoped_service_worker_reference.h |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2014 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_CHILD_SERVICE_WORKER_SCOPED_SERVICE_WORKER_REFERENCE_H_ |
| +#define CONTENT_CHILD_SERVICE_WORKER_SCOPED_SERVICE_WORKER_REFERENCE_H_ |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "content/common/service_worker/service_worker_types.h" |
| + |
| +namespace content { |
| + |
| +class ThreadSafeSender; |
| + |
| +// Automatically increments and decrement ServiceWorker's ref-count (in the |
|
michaeln
2014/05/01 01:25:18
there are lots of classes so it would help to be r
kinuko
2014/05/02 10:00:56
Sg, done.
|
| +// browser side) in ctor and dtor. |
| +class ScopedServiceWorkerReference { |
| + public: |
| + // Creates a new ScopedServiceWorkerReference (and increments ref-count). |
| + static scoped_ptr<ScopedServiceWorkerReference> Create( |
| + const ServiceWorkerObjectInfo& info, |
| + ThreadSafeSender* sender); |
| + // This doesn't increment ref-count in ctor. |
| + static scoped_ptr<ScopedServiceWorkerReference> CreateForDeleter( |
| + const ServiceWorkerObjectInfo& info, |
| + ThreadSafeSender* sender); |
| + |
| + ~ScopedServiceWorkerReference(); |
| + |
| + const ServiceWorkerObjectInfo& info() const { return info_; } |
| + int handle_id() const { return info_.handle_id; } |
| + const GURL& scope() const { return info_.scope; } |
| + const GURL& url() const { return info_.url; } |
| + blink::WebServiceWorkerState state() const { return info_.state; } |
| + void set_state(blink::WebServiceWorkerState state) { info_.state = state; } |
| + |
| + private: |
| + ScopedServiceWorkerReference(const ServiceWorkerObjectInfo& info, |
| + ThreadSafeSender* sender, |
| + bool increment_ref_in_ctor); |
| + ServiceWorkerObjectInfo info_; |
| + scoped_refptr<ThreadSafeSender> sender_; |
| + DISALLOW_COPY_AND_ASSIGN(ScopedServiceWorkerReference); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_CHILD_SERVICE_WORKER_SCOPED_SERVICE_WORKER_REFERENCE_H_ |