Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / child / service_worker / service_worker_registration_handle_reference.h
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_REFERENCE_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_REFERENCE_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "url/gurl.h"
11
12 namespace content {
13
14 class ThreadSafeSender;
15 struct ServiceWorkerObjectInfo;
16
17 class ServiceWorkerRegistrationHandleReference {
18  public:
19   // Creates a new ServiceWorkerRegistrationHandleReference and increments
20   // ref-count.
21   static scoped_ptr<ServiceWorkerRegistrationHandleReference> Create(
22       int registration_handle_id,
23       const ServiceWorkerObjectInfo& info,
24       ThreadSafeSender* sender);
25
26   // Creates a new ServiceWorkerRegistrationHandleReference by adopting a
27   // ref-count.
28   static scoped_ptr<ServiceWorkerRegistrationHandleReference> Adopt(
29       int registration_handle_id,
30       const ServiceWorkerObjectInfo& info,
31       ThreadSafeSender* sender);
32
33   ~ServiceWorkerRegistrationHandleReference();
34
35   int handle_id() const { return handle_id_; }
36   GURL scope() const { return scope_; }
37
38  private:
39   ServiceWorkerRegistrationHandleReference(int registration_handle_id,
40                                            const ServiceWorkerObjectInfo& info,
41                                            ThreadSafeSender* sender,
42                                            bool increment_ref_in_ctor);
43
44   const int handle_id_;
45   const GURL scope_;
46   scoped_refptr<ThreadSafeSender> sender_;
47
48   DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistrationHandleReference);
49 };
50
51 }  // namespace content
52
53 #endif  // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_REFERENCE_H_