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

Side by Side Diff: mojo/common/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: include guards 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
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 MOJO_COMMON_MOJO_CHANNEL_INIT_H_ 5 #ifndef MOJO_COMMON_CHANNEL_INIT_H_
6 #define MOJO_COMMON_MOJO_CHANNEL_INIT_H_ 6 #define MOJO_COMMON_CHANNEL_INIT_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
11 #include "mojo/common/mojo_common_export.h" 11 #include "mojo/common/mojo_common_export.h"
12 #include "mojo/public/cpp/system/core.h" 12 #include "mojo/public/cpp/system/core.h"
13 13
14 namespace base { 14 namespace base {
15 class MessageLoopProxy; 15 class MessageLoopProxy;
16 class TaskRunner; 16 class TaskRunner;
17 } 17 }
18 18
19 namespace mojo { 19 namespace mojo {
20 namespace embedder { 20 namespace embedder {
21 struct ChannelInfo; 21 struct ChannelInfo;
22 } 22 }
23 23
24 namespace common { 24 namespace common {
25 25
26 // MojoChannelInit handle creation (and destruction) of the mojo channel. It is 26 // ChannelInit handle creation (and destruction) of the mojo channel. It is
sky 2014/04/22 15:52:20 Is there a reason you don't like naming this MojoC
27 // expected that this class is created and destroyed on the main thread. 27 // expected that this class is created and destroyed on the main thread.
28 class MOJO_COMMON_EXPORT MojoChannelInit { 28 class MOJO_COMMON_EXPORT ChannelInit {
29 public: 29 public:
30 MojoChannelInit(); 30 ChannelInit();
31 ~MojoChannelInit(); 31 ~ChannelInit();
32 32
33 // Inits the channel. This takes ownership of |file|. 33 // Initializes the channel. This takes ownership of |file|. Returns the
34 void Init(base::PlatformFile file, 34 // primordial MessagePipe for the channel.
35 scoped_refptr<base::TaskRunner> io_thread_task_runner); 35 mojo::ScopedMessagePipeHandle Init(
36 36 base::PlatformFile file,
37 bool is_handle_valid() const { return bootstrap_message_pipe_.is_valid(); } 37 scoped_refptr<base::TaskRunner> io_thread_task_runner);
38
39 mojo::ScopedMessagePipeHandle bootstrap_message_pipe() {
40 return bootstrap_message_pipe_.Pass();
41 }
42 38
43 private: 39 private:
44 // Invoked on the main thread once the channel has been established. 40 // Invoked on the main thread once the channel has been established.
45 static void OnCreatedChannel( 41 static void OnCreatedChannel(
46 base::WeakPtr<MojoChannelInit> host, 42 base::WeakPtr<ChannelInit> host,
47 scoped_refptr<base::TaskRunner> io_thread, 43 scoped_refptr<base::TaskRunner> io_thread,
48 embedder::ChannelInfo* channel); 44 embedder::ChannelInfo* channel);
49 45
50 scoped_refptr<base::TaskRunner> io_thread_task_runner_; 46 scoped_refptr<base::TaskRunner> io_thread_task_runner_;
51 47
52 // If non-null the channel has been established. 48 // If non-null the channel has been established.
53 embedder::ChannelInfo* channel_info_; 49 embedder::ChannelInfo* channel_info_;
54 50
55 // The handle from channel creation. 51 base::WeakPtrFactory<ChannelInit> weak_factory_;
56 mojo::ScopedMessagePipeHandle bootstrap_message_pipe_;
57 52
58 base::WeakPtrFactory<MojoChannelInit> weak_factory_; 53 DISALLOW_COPY_AND_ASSIGN(ChannelInit);
59
60 DISALLOW_COPY_AND_ASSIGN(MojoChannelInit);
61 }; 54 };
62 55
63 } // namespace common 56 } // namespace common
64 } // namespace mojo 57 } // namespace mojo
65 58
66 #endif // MOJO_COMMON_MOJO_CHANNEL_INIT_H_ 59 #endif // MOJO_COMMON_CHANNEL_INIT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698