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

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

Issue 1011643002: ServiceWorker: Introduce SWMessageSender in order to mock IPC messaging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add header comment Created 5 years, 9 months 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/service_worker/service_worker_types.h" 10 #include "content/common/service_worker/service_worker_types.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 class ThreadSafeSender; 14 class ServiceWorkerMessageSender;
15 15
16 // Automatically increments and decrements ServiceWorkerHandle's ref-count 16 // Automatically increments and decrements ServiceWorkerHandle's ref-count
17 // (in the browser side) in ctor and dtor. 17 // (in the browser side) in ctor and dtor.
18 class ServiceWorkerHandleReference { 18 class ServiceWorkerHandleReference {
19 public: 19 public:
20 // Creates a new ServiceWorkerHandleReference and increments ref-count. 20 // Creates a new ServiceWorkerHandleReference and increments ref-count.
21 static scoped_ptr<ServiceWorkerHandleReference> Create( 21 static scoped_ptr<ServiceWorkerHandleReference> Create(
22 const ServiceWorkerObjectInfo& info, 22 const ServiceWorkerObjectInfo& info,
23 ThreadSafeSender* sender); 23 ServiceWorkerMessageSender* sender);
24 24
25 // Creates a new ServiceWorkerHandleReference by adopting a 25 // Creates a new ServiceWorkerHandleReference by adopting a
26 // ref-count. ServiceWorkerHandleReferences created this way must 26 // ref-count. ServiceWorkerHandleReferences created this way must
27 // have a matching 27 // have a matching
28 // ServiceWorkerDispatcherHost::RegisterServiceWorkerHandle call on 28 // ServiceWorkerDispatcherHost::RegisterServiceWorkerHandle call on
29 // the browser side. 29 // the browser side.
30 static scoped_ptr<ServiceWorkerHandleReference> Adopt( 30 static scoped_ptr<ServiceWorkerHandleReference> Adopt(
31 const ServiceWorkerObjectInfo& info, 31 const ServiceWorkerObjectInfo& info,
32 ThreadSafeSender* sender); 32 ServiceWorkerMessageSender* sender);
33 33
34 ~ServiceWorkerHandleReference(); 34 ~ServiceWorkerHandleReference();
35 35
36 const ServiceWorkerObjectInfo& info() const { return info_; } 36 const ServiceWorkerObjectInfo& info() const { return info_; }
37 int handle_id() const { return info_.handle_id; } 37 int handle_id() const { return info_.handle_id; }
38 const GURL& url() const { return info_.url; } 38 const GURL& url() const { return info_.url; }
39 blink::WebServiceWorkerState state() const { return info_.state; } 39 blink::WebServiceWorkerState state() const { return info_.state; }
40 void set_state(blink::WebServiceWorkerState state) { info_.state = state; } 40 void set_state(blink::WebServiceWorkerState state) { info_.state = state; }
41 int64 version_id() const { return info_.version_id; } 41 int64 version_id() const { return info_.version_id; }
42 42
43 private: 43 private:
44 ServiceWorkerHandleReference(const ServiceWorkerObjectInfo& info, 44 ServiceWorkerHandleReference(
45 ThreadSafeSender* sender, 45 const ServiceWorkerObjectInfo& info,
46 bool increment_ref_in_ctor); 46 ServiceWorkerMessageSender* sender,
47 bool increment_ref_in_ctor);
48
47 ServiceWorkerObjectInfo info_; 49 ServiceWorkerObjectInfo info_;
48 scoped_refptr<ThreadSafeSender> sender_; 50 scoped_refptr<ServiceWorkerMessageSender> sender_;
51
49 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandleReference); 52 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandleReference);
50 }; 53 };
51 54
52 } // namespace content 55 } // namespace content
53 56
54 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_ 57 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698