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

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: move to mojo::edk namespace in preparation for runtim flag Created 5 years, 3 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 ScopedPlatformHandle platform_handle);
30
31 void OnShutdownCompleteImpl();
32
33 private:
34 scoped_refptr<base::TaskRunner> io_thread_task_runner_;
35
36 // Set after shut down.
37 base::WaitableEvent event_;
38
39 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupportHelper);
40 };
41
42 } // namespace internal
43
44 // A simple class that calls |InitIPCSupport()| on construction and
45 // |ShutdownIPCSupport()| on destruction (or |ShutdownIPCSupportOnIOThread()|
46 // if destroyed on the I/O thread).
47 class ScopedIPCSupport : public ProcessDelegate {
48 public:
49 explicit ScopedIPCSupport(
50 scoped_refptr<base::TaskRunner> io_thread_task_runner);
51 ~ScopedIPCSupport() override;
52
53 private:
54 // |ProcessDelegate| implementation:
55 // Note: Executed on the I/O thread.
56 void OnShutdownComplete() override;
57
58 internal::ScopedIPCSupportHelper helper_;
59
60 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport);
61 };
62
63 } // namespace test
64 } // namespace edk
65 } // namespace mojo
66
67 #endif // MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698