#ifndef CONTENT_COMMON_MOJO_MOJO_CHANNEL_INIT_H_
#define CONTENT_COMMON_MOJO_MOJO_CHANNEL_INIT_H_
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
#include "content/common/content_export.h"
#include "mojo/public/cpp/system/core.h"
namespace base {
class MessageLoopProxy;
class TaskRunner;
}
namespace mojo {
namespace embedder {
struct ChannelInfo;
}
}
namespace content {
class CONTENT_EXPORT MojoChannelInit {
public:
MojoChannelInit();
~MojoChannelInit();
void Init(base::PlatformFile file,
scoped_refptr<base::TaskRunner> io_thread_task_runner);
bool is_handle_valid() const { return bootstrap_message_pipe_.is_valid(); }
mojo::ScopedMessagePipeHandle bootstrap_message_pipe() {
return bootstrap_message_pipe_.Pass();
}
private:
static void OnCreatedChannel(
base::WeakPtr<MojoChannelInit> host,
scoped_refptr<base::TaskRunner> io_thread,
mojo::embedder::ChannelInfo* channel);
scoped_refptr<base::TaskRunner> io_thread_task_runner_;
mojo::embedder::ChannelInfo* channel_info_;
mojo::ScopedMessagePipeHandle bootstrap_message_pipe_;
base::WeakPtrFactory<MojoChannelInit> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(MojoChannelInit);
};
}
#endif