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

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

Issue 780223002: ChannelProxy: Send() from UI thread when ChannelMojo is used. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
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 <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/synchronization/lock.h"
13 #include "ipc/ipc_channel.h" 14 #include "ipc/ipc_channel.h"
14 #include "ipc/ipc_channel_factory.h" 15 #include "ipc/ipc_channel_factory.h"
15 #include "ipc/ipc_export.h" 16 #include "ipc/ipc_export.h"
16 #include "ipc/mojo/ipc_message_pipe_reader.h" 17 #include "ipc/mojo/ipc_message_pipe_reader.h"
17 #include "ipc/mojo/ipc_mojo_bootstrap.h" 18 #include "ipc/mojo/ipc_mojo_bootstrap.h"
18 #include "mojo/edk/embedder/channel_info_forward.h" 19 #include "mojo/edk/embedder/channel_info_forward.h"
19 #include "mojo/public/cpp/system/core.h" 20 #include "mojo/public/cpp/system/core.h"
20 21
21 namespace IPC { 22 namespace IPC {
22 23
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 80
80 ~ChannelMojo() override; 81 ~ChannelMojo() override;
81 82
82 // ChannelMojoHost tells the client handle using this API. 83 // ChannelMojoHost tells the client handle using this API.
83 void OnClientLaunched(base::ProcessHandle handle); 84 void OnClientLaunched(base::ProcessHandle handle);
84 85
85 // Channel implementation 86 // Channel implementation
86 bool Connect() override; 87 bool Connect() override;
87 void Close() override; 88 void Close() override;
88 bool Send(Message* message) override; 89 bool Send(Message* message) override;
90 bool IsSendThreadSafe() const override;
89 base::ProcessId GetPeerPID() const override; 91 base::ProcessId GetPeerPID() const override;
90 base::ProcessId GetSelfPID() const override; 92 base::ProcessId GetSelfPID() const override;
91 93
92 #if defined(OS_POSIX) && !defined(OS_NACL) 94 #if defined(OS_POSIX) && !defined(OS_NACL)
93 int GetClientFileDescriptor() const override; 95 int GetClientFileDescriptor() const override;
94 base::ScopedFD TakeClientFileDescriptor() override; 96 base::ScopedFD TakeClientFileDescriptor() override;
95 97
96 // These access protected API of IPC::Message, which has ChannelMojo 98 // These access protected API of IPC::Message, which has ChannelMojo
97 // as a friend class. 99 // as a friend class.
98 static MojoResult WriteToFileDescriptorSet( 100 static MojoResult WriteToFileDescriptorSet(
(...skipping 29 matching lines...) Expand all
128 struct ChannelInfoDeleter { 130 struct ChannelInfoDeleter {
129 void operator()(mojo::embedder::ChannelInfo* ptr) const; 131 void operator()(mojo::embedder::ChannelInfo* ptr) const;
130 }; 132 };
131 133
132 // ChannelMojo needs to kill its MessagePipeReader in delayed manner 134 // ChannelMojo needs to kill its MessagePipeReader in delayed manner
133 // because the channel wants to kill these readers during the 135 // because the channel wants to kill these readers during the
134 // notifications invoked by them. 136 // notifications invoked by them.
135 typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter; 137 typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter;
136 138
137 void InitDelegate(ChannelMojo::Delegate* delegate); 139 void InitDelegate(ChannelMojo::Delegate* delegate);
140 base::TaskRunner* GetIOTaskRunner();
138 141
139 scoped_ptr<MojoBootstrap> bootstrap_; 142 scoped_ptr<MojoBootstrap> bootstrap_;
140 base::WeakPtr<Delegate> delegate_;
141 Mode mode_; 143 Mode mode_;
142 Listener* listener_; 144 Listener* listener_;
143 base::ProcessId peer_pid_; 145 base::ProcessId peer_pid_;
144 scoped_ptr<mojo::embedder::ChannelInfo, 146 scoped_ptr<mojo::embedder::ChannelInfo,
145 ChannelInfoDeleter> channel_info_; 147 ChannelInfoDeleter> channel_info_;
146 148
149 // Guards |message_reader_|, |pending_messages_| and |delegate_|.
150 //
151 // * The contents of |pending_messages_| can be modified from any threads.
152 // * |delegate_| and |message_reader_| is modified only from IO thread,
153 // but they can be referred from other threads.
154 base::Lock lock_;
155 base::WeakPtr<Delegate> delegate_;
147 scoped_ptr<internal::MessagePipeReader, ReaderDeleter> message_reader_; 156 scoped_ptr<internal::MessagePipeReader, ReaderDeleter> message_reader_;
148 ScopedVector<Message> pending_messages_; 157 ScopedVector<Message> pending_messages_;
149 158
150 base::WeakPtrFactory<ChannelMojo> weak_factory_; 159 base::WeakPtrFactory<ChannelMojo> weak_factory_;
151 160
152 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); 161 DISALLOW_COPY_AND_ASSIGN(ChannelMojo);
153 }; 162 };
154 163
155 } // namespace IPC 164 } // namespace IPC
156 165
157 #endif // IPC_IPC_CHANNEL_MOJO_H_ 166 #endif // IPC_IPC_CHANNEL_MOJO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698