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

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

Issue 599333002: ChannelMojo: Handle when ChannelMojo outlives ChannelMojoHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // TODO(morrita): Extract handle creation part of IPC::Channel into 55 // TODO(morrita): Extract handle creation part of IPC::Channel into
56 // separate class to clarify what ChannelMojo relies 56 // separate class to clarify what ChannelMojo relies
57 // on. 57 // on.
58 // TODO(morrita): Add APIs to create extra MessagePipes to let 58 // TODO(morrita): Add APIs to create extra MessagePipes to let
59 // Mojo-based objects talk over this Channel. 59 // Mojo-based objects talk over this Channel.
60 // 60 //
61 class IPC_MOJO_EXPORT ChannelMojo : public Channel, 61 class IPC_MOJO_EXPORT ChannelMojo : public Channel,
62 public MojoBootstrap::Delegate { 62 public MojoBootstrap::Delegate {
63 public: 63 public:
64 // Create ChannelMojo. A bootstrap channel is created as well. 64 // Create ChannelMojo. A bootstrap channel is created as well.
65 // |host| must not be null. 65 // |host| must not be null for server channels.
66 static scoped_ptr<ChannelMojo> Create(ChannelMojoHost* host, 66 static scoped_ptr<ChannelMojo> Create(ChannelMojoHost* host,
67 const ChannelHandle& channel_handle, 67 const ChannelHandle& channel_handle,
68 Mode mode, 68 Mode mode,
69 Listener* listener); 69 Listener* listener);
70 70
71 // Create a factory object for ChannelMojo. 71 // Create a factory object for ChannelMojo.
72 // The factory is used to create Mojo-based ChannelProxy family. 72 // The factory is used to create Mojo-based ChannelProxy family.
73 // |host| must not be null. 73 // |host| must not be null.
74 static scoped_ptr<ChannelFactory> CreateServerFactory( 74 static scoped_ptr<ChannelFactory> CreateServerFactory(
75 ChannelMojoHost* host, 75 ChannelMojoHost* host,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 mojo::embedder::ScopedPlatformHandle handle) OVERRIDE; 110 mojo::embedder::ScopedPlatformHandle handle) OVERRIDE;
111 virtual void OnBootstrapError() OVERRIDE; 111 virtual void OnBootstrapError() OVERRIDE;
112 112
113 // Called from MessagePipeReader implementations 113 // Called from MessagePipeReader implementations
114 void OnMessageReceived(Message& message); 114 void OnMessageReceived(Message& message);
115 void OnConnected(mojo::ScopedMessagePipeHandle pipe); 115 void OnConnected(mojo::ScopedMessagePipeHandle pipe);
116 void OnPipeClosed(internal::MessagePipeReader* reader); 116 void OnPipeClosed(internal::MessagePipeReader* reader);
117 void OnPipeError(internal::MessagePipeReader* reader); 117 void OnPipeError(internal::MessagePipeReader* reader);
118 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; } 118 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; }
119 119
120 void HostWasDestroyed();
viettrungluu 2014/09/25 19:38:34 I don't think this is used (or implemented).
Hajime Morrita 2014/09/25 22:00:03 Oops. Removed.
121
120 protected: 122 protected:
121 ChannelMojo(ChannelMojoHost* host, 123 ChannelMojo(ChannelMojoHost* host,
122 const ChannelHandle& channel_handle, 124 const ChannelHandle& channel_handle,
123 Mode mode, 125 Mode mode,
124 Listener* listener); 126 Listener* listener);
125 127
126 private: 128 private:
127 struct ChannelInfoDeleter { 129 struct ChannelInfoDeleter {
128 void operator()(mojo::embedder::ChannelInfo* ptr) const; 130 void operator()(mojo::embedder::ChannelInfo* ptr) const;
129 }; 131 };
130 132
131 // ChannelMojo needs to kill its MessagePipeReader in delayed manner 133 // ChannelMojo needs to kill its MessagePipeReader in delayed manner
132 // because the channel wants to kill these readers during the 134 // because the channel wants to kill these readers during the
133 // notifications invoked by them. 135 // notifications invoked by them.
134 typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter; 136 typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter;
135 137
136 void InitControlReader(mojo::embedder::ScopedPlatformHandle handle); 138 void InitControlReader(mojo::embedder::ScopedPlatformHandle handle);
137 139
138 scoped_ptr<MojoBootstrap> bootstrap_; 140 scoped_ptr<MojoBootstrap> bootstrap_;
139 ChannelMojoHost* const host_; 141 base::WeakPtr<ChannelMojoHost> host_;
140 Mode mode_; 142 Mode mode_;
141 Listener* listener_; 143 Listener* listener_;
142 base::ProcessId peer_pid_; 144 base::ProcessId peer_pid_;
143 scoped_ptr<mojo::embedder::ChannelInfo, 145 scoped_ptr<mojo::embedder::ChannelInfo,
144 ChannelInfoDeleter> channel_info_; 146 ChannelInfoDeleter> channel_info_;
145 147
146 scoped_ptr<internal::ControlReader, ReaderDeleter> control_reader_; 148 scoped_ptr<internal::ControlReader, ReaderDeleter> control_reader_;
147 scoped_ptr<internal::MessageReader, ReaderDeleter> message_reader_; 149 scoped_ptr<internal::MessageReader, ReaderDeleter> message_reader_;
148 ScopedVector<Message> pending_messages_; 150 ScopedVector<Message> pending_messages_;
149 151
150 base::WeakPtrFactory<ChannelMojo> weak_factory_; 152 base::WeakPtrFactory<ChannelMojo> weak_factory_;
151 153
152 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); 154 DISALLOW_COPY_AND_ASSIGN(ChannelMojo);
153 }; 155 };
154 156
155 } // namespace IPC 157 } // namespace IPC
156 158
157 #endif // IPC_IPC_CHANNEL_MOJO_H_ 159 #endif // IPC_IPC_CHANNEL_MOJO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698