Reland debugging for ipc related crash.
[chromium-blink-merge.git] / content / child / service_worker / service_worker_registration_handle_reference.h
blob3a1618ce3a8db1132b1467ad7c1205e121458a54
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.
5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_REFERENCE_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_REFERENCE_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/service_worker/service_worker_types.h"
11 #include "url/gurl.h"
13 namespace content {
15 class ThreadSafeSender;
17 // Represents an interprocess reference to ServiceWorkerRegistrationHandle
18 // managed in the browser process. The constructor and destructor sends a
19 // message to increment or decrement the reference count to the browser
20 // process.
21 class ServiceWorkerRegistrationHandleReference {
22 public:
23 // Creates a new ServiceWorkerRegistrationHandleReference and increments
24 // ref-count.
25 static scoped_ptr<ServiceWorkerRegistrationHandleReference> Create(
26 const ServiceWorkerRegistrationObjectInfo& info,
27 ThreadSafeSender* sender);
29 // Creates a new ServiceWorkerRegistrationHandleReference by adopting a
30 // ref-count.
31 static scoped_ptr<ServiceWorkerRegistrationHandleReference> Adopt(
32 const ServiceWorkerRegistrationObjectInfo& info,
33 ThreadSafeSender* sender);
35 ~ServiceWorkerRegistrationHandleReference();
37 const ServiceWorkerRegistrationObjectInfo& info() const { return info_; }
38 int handle_id() const { return info_.handle_id; }
39 GURL scope() const { return info_.scope; }
40 int64 registration_id() const { return info_.registration_id; }
42 private:
43 ServiceWorkerRegistrationHandleReference(
44 const ServiceWorkerRegistrationObjectInfo& info,
45 ThreadSafeSender* sender,
46 bool increment_ref_in_ctor);
48 ServiceWorkerRegistrationObjectInfo info_;
49 scoped_refptr<ThreadSafeSender> sender_;
51 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistrationHandleReference);
54 } // namespace content
56 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_REFERENCE_H_