Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: content/child/service_worker/service_worker_handle_reference.h

Issue 1478103002: [WIP] [service worker] Fix detach controller and fallback to network mechanism (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: return null in Create/Adopt Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_ 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_ 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "content/common/service_worker/service_worker_types.h" 11 #include "content/common/service_worker/service_worker_types.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 class ThreadSafeSender; 15 class ThreadSafeSender;
16 16
17 // Represents an interprocess reference to ServiceWorkerHandle managed in the 17 // Represents an interprocess reference to ServiceWorkerHandle managed in the
18 // browser process. The constructor and destructor sends a message to increment 18 // browser process. The constructor and destructor sends a message to increment
19 // or decrement the reference count to the browser process. 19 // or decrement the reference count to the browser process.
20 class CONTENT_EXPORT ServiceWorkerHandleReference { 20 class CONTENT_EXPORT ServiceWorkerHandleReference {
21 public: 21 public:
22 // Creates a new ServiceWorkerHandleReference and increments ref-count. 22 // Creates a new ServiceWorkerHandleReference and increments ref-count. If
23 // the handle id is kInvalidServiceWorkerHandleId, returns null instead.
23 static scoped_ptr<ServiceWorkerHandleReference> Create( 24 static scoped_ptr<ServiceWorkerHandleReference> Create(
24 const ServiceWorkerObjectInfo& info, 25 const ServiceWorkerObjectInfo& info,
25 ThreadSafeSender* sender); 26 ThreadSafeSender* sender);
26 27
27 // Creates a new ServiceWorkerHandleReference by adopting a ref-count. 28 // Creates a new ServiceWorkerHandleReference by adopting a ref-count. If
29 // the handle id is kInvalidServiceWorkerHandleId, returns null instead.
28 static scoped_ptr<ServiceWorkerHandleReference> Adopt( 30 static scoped_ptr<ServiceWorkerHandleReference> Adopt(
29 const ServiceWorkerObjectInfo& info, 31 const ServiceWorkerObjectInfo& info,
30 ThreadSafeSender* sender); 32 ThreadSafeSender* sender);
31 33
32 ~ServiceWorkerHandleReference(); 34 ~ServiceWorkerHandleReference();
33 35
34 const ServiceWorkerObjectInfo& info() const { return info_; } 36 const ServiceWorkerObjectInfo& info() const { return info_; }
35 int handle_id() const { return info_.handle_id; } 37 int handle_id() const { return info_.handle_id; }
36 const GURL& url() const { return info_.url; } 38 const GURL& url() const { return info_.url; }
37 blink::WebServiceWorkerState state() const { return info_.state; } 39 blink::WebServiceWorkerState state() const { return info_.state; }
38 void set_state(blink::WebServiceWorkerState state) { info_.state = state; } 40 void set_state(blink::WebServiceWorkerState state) { info_.state = state; }
39 int64 version_id() const { return info_.version_id; } 41 int64 version_id() const { return info_.version_id; }
40 42
41 private: 43 private:
42 ServiceWorkerHandleReference(const ServiceWorkerObjectInfo& info, 44 ServiceWorkerHandleReference(const ServiceWorkerObjectInfo& info,
43 ThreadSafeSender* sender, 45 ThreadSafeSender* sender,
44 bool increment_ref_in_ctor); 46 bool increment_ref_in_ctor);
45 ServiceWorkerObjectInfo info_; 47 ServiceWorkerObjectInfo info_;
46 scoped_refptr<ThreadSafeSender> sender_; 48 scoped_refptr<ThreadSafeSender> sender_;
47 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandleReference); 49 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandleReference);
48 }; 50 };
49 51
50 } // namespace content 52 } // namespace content
51 53
52 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_ 54 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698