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

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

Issue 1069943003: Revert of ChannelMojo: Ensure that it always has ScopedIPCSupport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
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"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // 47 //
48 class IPC_MOJO_EXPORT ChannelMojo 48 class IPC_MOJO_EXPORT ChannelMojo
49 : public Channel, 49 : public Channel,
50 public MojoBootstrap::Delegate, 50 public MojoBootstrap::Delegate,
51 public NON_EXPORTED_BASE(internal::MessagePipeReader::Delegate) { 51 public NON_EXPORTED_BASE(internal::MessagePipeReader::Delegate) {
52 public: 52 public:
53 class Delegate { 53 class Delegate {
54 public: 54 public:
55 virtual ~Delegate() {} 55 virtual ~Delegate() {}
56 virtual base::WeakPtr<Delegate> ToWeakPtr() = 0; 56 virtual base::WeakPtr<Delegate> ToWeakPtr() = 0;
57 virtual scoped_refptr<base::TaskRunner> GetIOTaskRunner() = 0;
57 virtual void OnChannelCreated(base::WeakPtr<ChannelMojo> channel) = 0; 58 virtual void OnChannelCreated(base::WeakPtr<ChannelMojo> channel) = 0;
58 }; 59 };
59 60
60 // True if ChannelMojo should be used regardless of the flag. 61 // True if ChannelMojo should be used regardless of the flag.
61 static bool ShouldBeUsed(); 62 static bool ShouldBeUsed();
62 63
63 // Create ChannelMojo. A bootstrap channel is created as well. 64 // Create ChannelMojo. A bootstrap channel is created as well.
64 // |host| must not be null for server channels. 65 // |host| must not be null for server channels.
65 static scoped_ptr<ChannelMojo> Create( 66 static scoped_ptr<ChannelMojo> Create(Delegate* delegate,
66 Delegate* delegate, 67 const ChannelHandle& channel_handle,
67 scoped_refptr<base::TaskRunner> io_runner, 68 Mode mode,
68 const ChannelHandle& channel_handle, 69 Listener* listener);
69 Mode mode,
70 Listener* listener);
71 70
72 // Create a factory object for ChannelMojo. 71 // Create a factory object for ChannelMojo.
73 // The factory is used to create Mojo-based ChannelProxy family. 72 // The factory is used to create Mojo-based ChannelProxy family.
74 // |host| must not be null. 73 // |host| must not be null.
75 static scoped_ptr<ChannelFactory> CreateServerFactory( 74 static scoped_ptr<ChannelFactory> CreateServerFactory(
76 Delegate* delegate, 75 Delegate* delegate,
77 scoped_refptr<base::TaskRunner> io_runner,
78 const ChannelHandle& channel_handle); 76 const ChannelHandle& channel_handle);
79 77
80 static scoped_ptr<ChannelFactory> CreateClientFactory( 78 static scoped_ptr<ChannelFactory> CreateClientFactory(
81 Delegate* delegate, 79 Delegate* delegate,
82 scoped_refptr<base::TaskRunner> io_runner,
83 const ChannelHandle& channel_handle); 80 const ChannelHandle& channel_handle);
84 81
85 ~ChannelMojo() override; 82 ~ChannelMojo() override;
86 83
87 // ChannelMojoHost tells the client handle using this API. 84 // ChannelMojoHost tells the client handle using this API.
88 void OnClientLaunched(base::ProcessHandle handle); 85 void OnClientLaunched(base::ProcessHandle handle);
89 86
90 // Channel implementation 87 // Channel implementation
91 bool Connect() override; 88 bool Connect() override;
92 void Close() override; 89 void Close() override;
(...skipping 18 matching lines...) Expand all
111 // MojoBootstrapDelegate implementation 108 // MojoBootstrapDelegate implementation
112 void OnBootstrapError() override; 109 void OnBootstrapError() override;
113 110
114 // MessagePipeReader::Delegate 111 // MessagePipeReader::Delegate
115 void OnMessageReceived(Message& message) override; 112 void OnMessageReceived(Message& message) override;
116 void OnPipeClosed(internal::MessagePipeReader* reader) override; 113 void OnPipeClosed(internal::MessagePipeReader* reader) override;
117 void OnPipeError(internal::MessagePipeReader* reader) override; 114 void OnPipeError(internal::MessagePipeReader* reader) override;
118 115
119 protected: 116 protected:
120 ChannelMojo(Delegate* delegate, 117 ChannelMojo(Delegate* delegate,
121 scoped_refptr<base::TaskRunner> io_runner,
122 const ChannelHandle& channel_handle, 118 const ChannelHandle& channel_handle,
123 Mode mode, 119 Mode mode,
124 Listener* listener); 120 Listener* listener);
125 121
126 mojo::ScopedMessagePipeHandle CreateMessagingPipe( 122 mojo::ScopedMessagePipeHandle CreateMessagingPipe(
127 mojo::embedder::ScopedPlatformHandle handle); 123 mojo::embedder::ScopedPlatformHandle handle);
128 void InitMessageReader(mojo::ScopedMessagePipeHandle pipe, int32_t peer_pid); 124 void InitMessageReader(mojo::ScopedMessagePipeHandle pipe, int32_t peer_pid);
129 125
130 Listener* listener() const { return listener_; } 126 Listener* listener() const { return listener_; }
131 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; } 127 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; }
132 128
133 private: 129 private:
134 struct ChannelInfoDeleter { 130 struct ChannelInfoDeleter {
135 void operator()(mojo::embedder::ChannelInfo* ptr) const; 131 void operator()(mojo::embedder::ChannelInfo* ptr) const;
136 }; 132 };
137 133
138 // ChannelMojo needs to kill its MessagePipeReader in delayed manner 134 // ChannelMojo needs to kill its MessagePipeReader in delayed manner
139 // because the channel wants to kill these readers during the 135 // because the channel wants to kill these readers during the
140 // notifications invoked by them. 136 // notifications invoked by them.
141 typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter; 137 typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter;
142 138
143 void InitOnIOThread(ChannelMojo::Delegate* delegate); 139 void InitDelegate(ChannelMojo::Delegate* delegate);
144 140
145 scoped_ptr<MojoBootstrap> bootstrap_; 141 scoped_ptr<MojoBootstrap> bootstrap_;
146 base::WeakPtr<Delegate> delegate_; 142 base::WeakPtr<Delegate> delegate_;
147 Mode mode_; 143 Mode mode_;
148 Listener* listener_; 144 Listener* listener_;
149 base::ProcessId peer_pid_; 145 base::ProcessId peer_pid_;
150 scoped_ptr<mojo::embedder::ChannelInfo, 146 scoped_ptr<mojo::embedder::ChannelInfo,
151 ChannelInfoDeleter> channel_info_; 147 ChannelInfoDeleter> channel_info_;
152 148
153 scoped_ptr<internal::MessagePipeReader, ReaderDeleter> message_reader_; 149 scoped_ptr<internal::MessagePipeReader, ReaderDeleter> message_reader_;
154 ScopedVector<Message> pending_messages_; 150 ScopedVector<Message> pending_messages_;
155 151
156 scoped_ptr<ScopedIPCSupport> ipc_support_; 152 scoped_ptr<ScopedIPCSupport> ipc_support_;
157 153
158 base::WeakPtrFactory<ChannelMojo> weak_factory_; 154 base::WeakPtrFactory<ChannelMojo> weak_factory_;
159 155
160 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); 156 DISALLOW_COPY_AND_ASSIGN(ChannelMojo);
161 }; 157 };
162 158
163 } // namespace IPC 159 } // namespace IPC
164 160
165 #endif // IPC_IPC_CHANNEL_MOJO_H_ 161 #endif // IPC_IPC_CHANNEL_MOJO_H_
OLDNEW
« no previous file with comments | « content/test/render_thread_impl_browser_test_ipc_helper.cc ('k') | ipc/mojo/ipc_channel_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698