OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H_ | |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "content/browser/service_worker/service_worker_version.h" | |
10 #include "content/common/background_sync_service.mojom.h" | |
11 #include "content/common/service_worker/service_worker_status_code.h" | |
12 #include "content/public/browser/browser_thread.h" | |
13 | |
14 namespace content { | |
15 | |
16 // This class is used by ServiceWorkerVersion to fire events in the service | |
17 // worker using mojo IPC. It owns an InterfacePtr to each service, which it will | |
18 // construct as necessary. | |
19 // | |
20 // All public methods must be called on IO thread, and callbacks will be | |
21 // executed on that thread. Can be constructed, owned and destructed on a | |
22 // separate thread. | |
jkarlin
2015/06/16 19:00:00
The above paragraph is out of date. Just mention t
iclelland
2015/06/17 12:39:26
Done.
| |
23 class ServiceWorkerMojoEventDispatcher | |
24 : public base::RefCountedThreadSafe<ServiceWorkerMojoEventDispatcher, | |
jkarlin
2015/06/16 19:00:00
This doesn't need to be RefCounted any longer. Ins
iclelland
2015/06/17 12:39:24
Done.
| |
25 BrowserThread::DeleteOnIOThread> { | |
26 public: | |
27 ServiceWorkerMojoEventDispatcher(); | |
28 | |
29 // Dispatches the event, establishing a connection to the mojo service if | |
30 // necessary, and then runs |callback| with the result. | |
31 void DispatchSyncEvent(int render_process_id, | |
32 int thread_id, | |
33 const ServiceWorkerVersion::StatusCallback& callback); | |
34 | |
35 private: | |
36 template <typename MojoServicePtrType> | |
jkarlin
2015/06/16 19:00:00
The typename differs between here and source file.
iclelland
2015/06/17 12:39:27
Thanks -- I didn't catch that. Should be MojoServi
| |
37 void Connect(int render_process_id, | |
38 const base::Callback< | |
39 void(mojo::InterfacePtrInfo<MojoServicePtrType>)>& callback); | |
40 void BindChannelAndDispatchSyncEvent( | |
41 int thread_id, | |
42 const ServiceWorkerVersion::StatusCallback& callback, | |
43 mojo::InterfacePtrInfo<BackgroundSyncServiceClient> ptri); | |
44 void DispatchSyncEventInternal( | |
45 int thread_id, | |
46 const ServiceWorkerVersion::StatusCallback& callback); | |
47 | |
48 friend class base::RefCountedThreadSafe<ServiceWorkerMojoEventDispatcher, | |
49 BrowserThread::DeleteOnIOThread>; | |
50 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; | |
51 friend class base::DeleteHelper<ServiceWorkerMojoEventDispatcher>; | |
jkarlin
2015/06/16 19:00:00
delete the above friends
iclelland
2015/06/17 12:39:27
Done.
| |
52 | |
53 ~ServiceWorkerMojoEventDispatcher(); | |
54 | |
55 void OnEventFinished(const ServiceWorkerVersion::StatusCallback& callback, | |
56 ServiceWorkerEventStatus result); | |
57 | |
58 BackgroundSyncServiceClientPtr background_sync_client_; | |
jkarlin
2015/06/16 19:00:00
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerMojoEventDis
iclelland
2015/06/17 12:39:26
Done.
| |
59 }; | |
60 | |
61 } // namespace content | |
62 | |
63 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H _ | |
OLD | NEW |