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

Side by Side Diff: ipc/mojo/ipc_mojo_bootstrap.h

Issue 2069803003: Fold //ipc/mojo into //ipc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-ipc-deps
Patch Set: rebase Created 4 years, 5 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
« no previous file with comments | « ipc/mojo/ipc_mojo.gyp ('k') | ipc/mojo/ipc_mojo_bootstrap.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 IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_
6 #define IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11
12 #include "base/macros.h"
13 #include "base/process/process_handle.h"
14 #include "build/build_config.h"
15 #include "ipc/ipc_channel.h"
16 #include "ipc/ipc_listener.h"
17 #include "ipc/mojo/ipc.mojom.h"
18 #include "mojo/public/cpp/system/message_pipe.h"
19
20 namespace IPC {
21
22 // MojoBootstrap establishes a pair of associated interfaces between two
23 // processes in Chrome.
24 //
25 // Clients should implement MojoBootstrap::Delegate to get the associated pipes
26 // from MojoBootstrap object.
27 //
28 // This lives on IO thread other than Create(), which can be called from
29 // UI thread as Channel::Create() can be.
30 class IPC_MOJO_EXPORT MojoBootstrap {
31 public:
32 class Delegate {
33 public:
34 virtual void OnPipesAvailable(
35 mojom::ChannelAssociatedPtrInfo send_channel,
36 mojom::ChannelAssociatedRequest receive_channel,
37 int32_t peer_pid) = 0;
38 virtual void OnBootstrapError() = 0;
39 };
40
41 // Create the MojoBootstrap instance, using |handle| as the message pipe, in
42 // mode as specified by |mode|. The result is passed to |delegate|.
43 static std::unique_ptr<MojoBootstrap> Create(
44 mojo::ScopedMessagePipeHandle handle,
45 Channel::Mode mode,
46 Delegate* delegate);
47
48 MojoBootstrap();
49 virtual ~MojoBootstrap();
50
51 // Start the handshake over the underlying message pipe.
52 virtual void Connect() = 0;
53
54 // GetSelfPID returns our PID.
55 base::ProcessId GetSelfPID() const;
56
57 protected:
58 // On MojoServerBootstrap: INITIALIZED -> WAITING_ACK -> READY
59 // On MojoClientBootstrap: INITIALIZED -> READY
60 // STATE_ERROR is a catch-all state that captures any observed error.
61 enum State { STATE_INITIALIZED, STATE_WAITING_ACK, STATE_READY, STATE_ERROR };
62
63 Delegate* delegate() const { return delegate_; }
64 void Fail();
65 bool HasFailed() const;
66
67 State state() const { return state_; }
68 void set_state(State state) { state_ = state; }
69
70 mojo::ScopedMessagePipeHandle TakeHandle();
71
72 private:
73 void Init(mojo::ScopedMessagePipeHandle, Delegate* delegate);
74
75 mojo::ScopedMessagePipeHandle handle_;
76 Delegate* delegate_;
77 State state_;
78
79 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap);
80 };
81
82 } // namespace IPC
83
84 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_
OLDNEW
« no previous file with comments | « ipc/mojo/ipc_mojo.gyp ('k') | ipc/mojo/ipc_mojo_bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698