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

Side by Side Diff: ipc/ipc_channel_mojo.h

Issue 2173753002: 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_channel.h ('k') | ipc/ipc_channel_mojo.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_CHANNEL_MOJO_H_ 5 #ifndef IPC_IPC_CHANNEL_MOJO_H_
6 #define IPC_IPC_CHANNEL_MOJO_H_ 6 #define IPC_IPC_CHANNEL_MOJO_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 24 matching lines...) Expand all
35 // ChannelMojo builds a Mojo MessagePipe using the provided message pipe 35 // ChannelMojo builds a Mojo MessagePipe using the provided message pipe
36 // |handle| and builds an associated interface for each direction on the 36 // |handle| and builds an associated interface for each direction on the
37 // channel. 37 // channel.
38 // 38 //
39 // TODO(morrita): Add APIs to create extra MessagePipes to let 39 // TODO(morrita): Add APIs to create extra MessagePipes to let
40 // Mojo-based objects talk over this Channel. 40 // Mojo-based objects talk over this Channel.
41 // 41 //
42 class IPC_EXPORT ChannelMojo 42 class IPC_EXPORT ChannelMojo
43 : public Channel, 43 : public Channel,
44 public Channel::AssociatedInterfaceSupport, 44 public Channel::AssociatedInterfaceSupport,
45 public NON_EXPORTED_BASE(MojoBootstrap::Delegate), 45 public MojoBootstrap::Delegate,
46 public NON_EXPORTED_BASE(internal::MessagePipeReader::Delegate) { 46 public NON_EXPORTED_BASE(internal::MessagePipeReader::Delegate) {
47 public: 47 public:
48 // Creates a ChannelMojo. 48 // Creates a ChannelMojo.
49 static std::unique_ptr<ChannelMojo> 49 static std::unique_ptr<ChannelMojo>
50 Create(mojo::ScopedMessagePipeHandle handle, 50 Create(mojo::ScopedMessagePipeHandle handle,
51 Mode mode, 51 Mode mode,
52 Listener* listener, 52 Listener* listener,
53 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner = 53 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner =
54 base::ThreadTaskRunnerHandle::Get()); 54 base::ThreadTaskRunnerHandle::Get());
55 55
(...skipping 27 matching lines...) Expand all
83 // These access protected API of IPC::Message, which has ChannelMojo 83 // These access protected API of IPC::Message, which has ChannelMojo
84 // as a friend class. 84 // as a friend class.
85 static MojoResult WriteToMessageAttachmentSet( 85 static MojoResult WriteToMessageAttachmentSet(
86 mojo::Array<mojom::SerializedHandlePtr> handle_buffer, 86 mojo::Array<mojom::SerializedHandlePtr> handle_buffer,
87 Message* message); 87 Message* message);
88 static MojoResult ReadFromMessageAttachmentSet( 88 static MojoResult ReadFromMessageAttachmentSet(
89 Message* message, 89 Message* message,
90 mojo::Array<mojom::SerializedHandlePtr>* handles); 90 mojo::Array<mojom::SerializedHandlePtr>* handles);
91 91
92 // MojoBootstrapDelegate implementation 92 // MojoBootstrapDelegate implementation
93 void OnPipesAvailable(mojom::ChannelAssociatedPtr sender, 93 void OnPipesAvailable(mojom::ChannelAssociatedPtrInfo send_channel,
94 mojom::ChannelAssociatedRequest receiver) override; 94 mojom::ChannelAssociatedRequest receive_channel,
95 95 int32_t peer_pid) override;
96 // MessagePipeReader::Delegate 96 void OnBootstrapError() override;
97 void OnPeerPidReceived() override;
98 void OnMessageReceived(const Message& message) override;
99 void OnPipeError() override;
100 void OnAssociatedInterfaceRequest( 97 void OnAssociatedInterfaceRequest(
101 const std::string& name, 98 const std::string& name,
102 mojo::ScopedInterfaceEndpointHandle handle) override; 99 mojo::ScopedInterfaceEndpointHandle handle) override;
103 100
101 // MessagePipeReader::Delegate
102 void OnMessageReceived(const Message& message) override;
103 void OnPipeError() override;
104
104 private: 105 private:
105 ChannelMojo( 106 ChannelMojo(
106 mojo::ScopedMessagePipeHandle handle, 107 mojo::ScopedMessagePipeHandle handle,
107 Mode mode, 108 Mode mode,
108 Listener* listener, 109 Listener* listener,
109 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner); 110 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner);
110 111
112 void InitMessageReader(mojom::ChannelAssociatedPtrInfo sender,
113 mojom::ChannelAssociatedRequest receiver,
114 base::ProcessId peer_pid);
115
111 // Channel::AssociatedInterfaceSupport: 116 // Channel::AssociatedInterfaceSupport:
112 mojo::AssociatedGroup* GetAssociatedGroup() override; 117 mojo::AssociatedGroup* GetAssociatedGroup() override;
113 void AddGenericAssociatedInterface( 118 void AddGenericAssociatedInterface(
114 const std::string& name, 119 const std::string& name,
115 const GenericAssociatedInterfaceFactory& factory) override; 120 const GenericAssociatedInterfaceFactory& factory) override;
116 void GetGenericRemoteAssociatedInterface( 121 void GetGenericRemoteAssociatedInterface(
117 const std::string& name, 122 const std::string& name,
118 mojo::ScopedInterfaceEndpointHandle handle) override; 123 mojo::ScopedInterfaceEndpointHandle handle) override;
124 void SetProxyTaskRunner(
125 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override;
126
127 // ChannelMojo needs to kill its MessagePipeReader in delayed manner
128 // because the channel wants to kill these readers during the
129 // notifications invoked by them.
130 typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter;
119 131
120 // A TaskRunner which runs tasks on the ChannelMojo's owning thread. 132 // A TaskRunner which runs tasks on the ChannelMojo's owning thread.
121 scoped_refptr<base::TaskRunner> task_runner_; 133 scoped_refptr<base::TaskRunner> task_runner_;
122 134
123 const mojo::MessagePipeHandle pipe_; 135 const mojo::MessagePipeHandle pipe_;
124 std::unique_ptr<MojoBootstrap> bootstrap_; 136 std::unique_ptr<MojoBootstrap> bootstrap_;
125 Listener* listener_; 137 Listener* listener_;
126 138
127 std::unique_ptr<internal::MessagePipeReader> message_reader_;
128
129 base::Lock associated_interface_lock_;
130 std::map<std::string, GenericAssociatedInterfaceFactory> 139 std::map<std::string, GenericAssociatedInterfaceFactory>
131 associated_interfaces_; 140 associated_interfaces_;
132 141
142 // Guards access to the fields below.
143 mutable base::Lock lock_;
144 std::unique_ptr<internal::MessagePipeReader, ReaderDeleter> message_reader_;
145 std::vector<std::unique_ptr<Message>> pending_messages_;
146 bool waiting_connect_;
147
133 base::WeakPtrFactory<ChannelMojo> weak_factory_; 148 base::WeakPtrFactory<ChannelMojo> weak_factory_;
134 149
135 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); 150 DISALLOW_COPY_AND_ASSIGN(ChannelMojo);
136 }; 151 };
137 152
138 } // namespace IPC 153 } // namespace IPC
139 154
140 #endif // IPC_IPC_CHANNEL_MOJO_H_ 155 #endif // IPC_IPC_CHANNEL_MOJO_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel.h ('k') | ipc/ipc_channel_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698