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 IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ | 5 #ifndef IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ |
6 #define IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ | 6 #define IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "ipc/ipc_channel.h" | 10 #include "ipc/ipc_channel.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 }; | 34 }; |
35 | 35 |
36 // Create the MojoBootstrap instance. | 36 // Create the MojoBootstrap instance. |
37 // Instead of creating IPC::Channel, passs its ChannelHandle as |handle|, | 37 // Instead of creating IPC::Channel, passs its ChannelHandle as |handle|, |
38 // mode as |mode|. The result is notified to passed |delegate|. | 38 // mode as |mode|. The result is notified to passed |delegate|. |
39 static scoped_ptr<MojoBootstrap> Create(ChannelHandle handle, | 39 static scoped_ptr<MojoBootstrap> Create(ChannelHandle handle, |
40 Channel::Mode mode, | 40 Channel::Mode mode, |
41 Delegate* delegate); | 41 Delegate* delegate); |
42 | 42 |
43 MojoBootstrap(); | 43 MojoBootstrap(); |
44 virtual ~MojoBootstrap(); | 44 ~MojoBootstrap() override; |
45 | 45 |
46 // Start the handshake over the underlying platform channel. | 46 // Start the handshake over the underlying platform channel. |
47 bool Connect(); | 47 bool Connect(); |
48 | 48 |
49 // Each client should call this once the process handle becomes known. | 49 // Each client should call this once the process handle becomes known. |
50 virtual void OnClientLaunched(base::ProcessHandle process) = 0; | 50 virtual void OnClientLaunched(base::ProcessHandle process) = 0; |
51 | 51 |
52 #if defined(OS_POSIX) && !defined(OS_NACL) | 52 #if defined(OS_POSIX) && !defined(OS_NACL) |
53 int GetClientFileDescriptor() const; | 53 int GetClientFileDescriptor() const; |
54 base::ScopedFD TakeClientFileDescriptor(); | 54 base::ScopedFD TakeClientFileDescriptor(); |
55 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 55 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
56 | 56 |
57 protected: | 57 protected: |
58 enum State { STATE_INITIALIZED, STATE_WAITING_ACK, STATE_READY, STATE_ERROR }; | 58 enum State { STATE_INITIALIZED, STATE_WAITING_ACK, STATE_READY, STATE_ERROR }; |
59 | 59 |
60 Delegate* delegate() const { return delegate_; } | 60 Delegate* delegate() const { return delegate_; } |
61 bool Send(Message* message); | 61 bool Send(Message* message); |
62 void Fail(); | 62 void Fail(); |
63 | 63 |
64 State state() const { return state_; } | 64 State state() const { return state_; } |
65 void set_state(State state) { state_ = state; } | 65 void set_state(State state) { state_ = state; } |
66 | 66 |
67 private: | 67 private: |
68 void Init(scoped_ptr<Channel> channel, Delegate* delegate); | 68 void Init(scoped_ptr<Channel> channel, Delegate* delegate); |
69 | 69 |
70 // Listener implementations | 70 // Listener implementations |
71 virtual void OnBadMessageReceived(const Message& message) override; | 71 void OnBadMessageReceived(const Message& message) override; |
72 virtual void OnChannelError() override; | 72 void OnChannelError() override; |
73 | 73 |
74 scoped_ptr<Channel> channel_; | 74 scoped_ptr<Channel> channel_; |
75 Delegate* delegate_; | 75 Delegate* delegate_; |
76 State state_; | 76 State state_; |
77 | 77 |
78 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap); | 78 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap); |
79 }; | 79 }; |
80 | 80 |
81 } // namespace IPC | 81 } // namespace IPC |
82 | 82 |
83 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ | 83 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ |
OLD | NEW |