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

Side by Side Diff: ipc/ipc_mojo_bootstrap.h

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

Powered by Google App Engine
This is Rietveld 408576698