| OLD | NEW |
| 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 CONTENT_COMMON_MOJO_MOJO_CHANNEL_INIT_H_ | 5 #ifndef CONTENT_COMMON_MOJO_MOJO_CHANNEL_INIT_H_ |
| 6 #define CONTENT_COMMON_MOJO_MOJO_CHANNEL_INIT_H_ | 6 #define CONTENT_COMMON_MOJO_MOJO_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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 | 26 |
| 27 // MojoChannelInit handle creation (and destruction) of the mojo channel. It is | 27 // MojoChannelInit handle creation (and destruction) of the mojo channel. It is |
| 28 // expected that this class is created and destroyed on the main thread. | 28 // expected that this class is created and destroyed on the main thread. |
| 29 class CONTENT_EXPORT MojoChannelInit { | 29 class CONTENT_EXPORT MojoChannelInit { |
| 30 public: | 30 public: |
| 31 MojoChannelInit(); | 31 MojoChannelInit(); |
| 32 ~MojoChannelInit(); | 32 ~MojoChannelInit(); |
| 33 | 33 |
| 34 // Inits the channel. This takes ownership of |file|. | 34 // Initializes the channel. This takes ownership of |file|. Returns the |
| 35 void Init(base::PlatformFile file, | 35 // primordial MessagePipe for the channel. |
| 36 scoped_refptr<base::TaskRunner> io_thread_task_runner); | 36 mojo::ScopedMessagePipeHandle Init( |
| 37 | 37 base::PlatformFile file, |
| 38 bool is_handle_valid() const { return bootstrap_message_pipe_.is_valid(); } | 38 scoped_refptr<base::TaskRunner> io_thread_task_runner); |
| 39 | |
| 40 mojo::ScopedMessagePipeHandle bootstrap_message_pipe() { | |
| 41 return bootstrap_message_pipe_.Pass(); | |
| 42 } | |
| 43 | 39 |
| 44 private: | 40 private: |
| 45 // Invoked on the main thread once the channel has been established. | 41 // Invoked on the main thread once the channel has been established. |
| 46 static void OnCreatedChannel( | 42 static void OnCreatedChannel( |
| 47 base::WeakPtr<MojoChannelInit> host, | 43 base::WeakPtr<MojoChannelInit> host, |
| 48 scoped_refptr<base::TaskRunner> io_thread, | 44 scoped_refptr<base::TaskRunner> io_thread, |
| 49 mojo::embedder::ChannelInfo* channel); | 45 mojo::embedder::ChannelInfo* channel); |
| 50 | 46 |
| 51 scoped_refptr<base::TaskRunner> io_thread_task_runner_; | 47 scoped_refptr<base::TaskRunner> io_thread_task_runner_; |
| 52 | 48 |
| 53 // If non-null the channel has been established. | 49 // If non-null the channel has been established. |
| 54 mojo::embedder::ChannelInfo* channel_info_; | 50 mojo::embedder::ChannelInfo* channel_info_; |
| 55 | 51 |
| 56 // The handle from channel creation. | |
| 57 mojo::ScopedMessagePipeHandle bootstrap_message_pipe_; | |
| 58 | |
| 59 base::WeakPtrFactory<MojoChannelInit> weak_factory_; | 52 base::WeakPtrFactory<MojoChannelInit> weak_factory_; |
| 60 | 53 |
| 61 DISALLOW_COPY_AND_ASSIGN(MojoChannelInit); | 54 DISALLOW_COPY_AND_ASSIGN(MojoChannelInit); |
| 62 }; | 55 }; |
| 63 | 56 |
| 64 } // namespace content | 57 } // namespace content |
| 65 | 58 |
| 66 #endif // CONTENT_COMMON_MOJO_MOJO_CHANNEL_INIT_H_ | 59 #endif // CONTENT_COMMON_MOJO_MOJO_CHANNEL_INIT_H_ |
| OLD | NEW |