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

Side by Side Diff: mojo/edk/test/scoped_ipc_support.h

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanup Created 5 years, 2 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
(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 MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_
6 #define MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_
7
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/synchronization/waitable_event.h"
11 #include "base/task_runner.h"
12 #include "mojo/edk/embedder/process_delegate.h"
13 #include "mojo/edk/embedder/scoped_platform_handle.h"
14 #include "mojo/public/cpp/system/macros.h"
15
16 namespace mojo {
17 namespace edk {
18 namespace test {
19
20 namespace internal {
21
22 class ScopedIPCSupportHelper {
23 public:
24 ScopedIPCSupportHelper();
25 ~ScopedIPCSupportHelper();
26
27 void Init(ProcessDelegate* process_delegate,
28 scoped_refptr<base::TaskRunner> io_thread_task_runner);
29
30 void OnShutdownCompleteImpl();
31
32 private:
33 scoped_refptr<base::TaskRunner> io_thread_task_runner_;
34
35 // Set after shut down.
36 base::WaitableEvent event_;
37
38 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupportHelper);
39 };
40
41 } // namespace internal
42
43 // A simple class that calls |InitIPCSupport()| on construction and
44 // |ShutdownIPCSupport()| on destruction (or |ShutdownIPCSupportOnIOThread()|
45 // if destroyed on the I/O thread).
46 class ScopedIPCSupport : public ProcessDelegate {
47 public:
48 explicit ScopedIPCSupport(
49 scoped_refptr<base::TaskRunner> io_thread_task_runner);
50 ~ScopedIPCSupport() override;
51
52 private:
53 // |ProcessDelegate| implementation:
54 // Note: Executed on the I/O thread.
55 void OnShutdownComplete() override;
56
57 internal::ScopedIPCSupportHelper helper_;
58
59 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport);
60 };
61
62 } // namespace test
63 } // namespace edk
64 } // namespace mojo
65
66 #endif // MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698