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

Side by Side Diff: mojo/common/mojo_channel_init.h

Issue 236813002: Move Mojo channel initialization closer to IPC::Channel setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more missing deps Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « mojo/common/channel_init.cc ('k') | mojo/common/mojo_channel_init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_COMMON_MOJO_CHANNEL_INIT_H_
6 #define MOJO_COMMON_MOJO_CHANNEL_INIT_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/platform_file.h"
11 #include "mojo/common/mojo_common_export.h"
12 #include "mojo/public/cpp/system/core.h"
13
14 namespace base {
15 class MessageLoopProxy;
16 class TaskRunner;
17 }
18
19 namespace mojo {
20 namespace embedder {
21 struct ChannelInfo;
22 }
23
24 namespace common {
25
26 // MojoChannelInit handle creation (and destruction) of the mojo channel. It is
27 // expected that this class is created and destroyed on the main thread.
28 class MOJO_COMMON_EXPORT MojoChannelInit {
29 public:
30 MojoChannelInit();
31 ~MojoChannelInit();
32
33 // Inits the channel. This takes ownership of |file|.
34 void Init(base::PlatformFile file,
35 scoped_refptr<base::TaskRunner> io_thread_task_runner);
36
37 bool is_handle_valid() const { return bootstrap_message_pipe_.is_valid(); }
38
39 mojo::ScopedMessagePipeHandle bootstrap_message_pipe() {
40 return bootstrap_message_pipe_.Pass();
41 }
42
43 private:
44 // Invoked on the main thread once the channel has been established.
45 static void OnCreatedChannel(
46 base::WeakPtr<MojoChannelInit> host,
47 scoped_refptr<base::TaskRunner> io_thread,
48 embedder::ChannelInfo* channel);
49
50 scoped_refptr<base::TaskRunner> io_thread_task_runner_;
51
52 // If non-null the channel has been established.
53 embedder::ChannelInfo* channel_info_;
54
55 // The handle from channel creation.
56 mojo::ScopedMessagePipeHandle bootstrap_message_pipe_;
57
58 base::WeakPtrFactory<MojoChannelInit> weak_factory_;
59
60 DISALLOW_COPY_AND_ASSIGN(MojoChannelInit);
61 };
62
63 } // namespace common
64 } // namespace mojo
65
66 #endif // MOJO_COMMON_MOJO_CHANNEL_INIT_H_
OLDNEW
« no previous file with comments | « mojo/common/channel_init.cc ('k') | mojo/common/mojo_channel_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698