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

Side by Side Diff: content/common/child_process_host_impl.cc

Issue 2766263009: Convert content ConnectionFilter to OnBindInterface (Closed)
Patch Set: . Created 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/common/child_process_host_impl.h" 5 #include "content/common/child_process_host_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 } 103 }
104 104
105 void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) { 105 void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) {
106 filters_.push_back(filter); 106 filters_.push_back(filter);
107 107
108 if (channel_) 108 if (channel_)
109 filter->OnFilterAdded(channel_.get()); 109 filter->OnFilterAdded(channel_.get());
110 } 110 }
111 111
112 service_manager::InterfaceProvider* 112 void ChildProcessHostImpl::BindInterface(
113 ChildProcessHostImpl::GetRemoteInterfaces() { 113 const std::string& interface_name,
114 return delegate_->GetRemoteInterfaces(); 114 mojo::ScopedMessagePipeHandle interface_pipe) {
115 return delegate_->BindInterface(interface_name, std::move(interface_pipe));
115 } 116 }
116 117
117 void ChildProcessHostImpl::ForceShutdown() { 118 void ChildProcessHostImpl::ForceShutdown() {
118 Send(new ChildProcessMsg_Shutdown()); 119 Send(new ChildProcessMsg_Shutdown());
119 } 120 }
120 121
121 std::string ChildProcessHostImpl::CreateChannelMojo( 122 std::string ChildProcessHostImpl::CreateChannelMojo(
122 mojo::edk::PendingProcessConnection* connection) { 123 mojo::edk::PendingProcessConnection* connection) {
123 DCHECK(channel_id_.empty()); 124 DCHECK(channel_id_.empty());
124 channel_ = 125 channel_ =
125 IPC::ChannelMojo::Create(connection->CreateMessagePipe(&channel_id_), 126 IPC::ChannelMojo::Create(connection->CreateMessagePipe(&channel_id_),
126 IPC::Channel::MODE_SERVER, this); 127 IPC::Channel::MODE_SERVER, this);
127 if (!channel_ || !InitChannel()) 128 if (!channel_ || !InitChannel())
128 return std::string(); 129 return std::string();
129 return channel_id_; 130 return channel_id_;
130 } 131 }
131 132
132 void ChildProcessHostImpl::CreateChannelMojo() { 133 void ChildProcessHostImpl::CreateChannelMojo() {
133 // TODO(rockot): Remove |channel_id_| once this is the only code path by which 134 // TODO(rockot): Remove |channel_id_| once this is the only code path by which
134 // the Channel is created. For now it serves to at least mutually exclude 135 // the Channel is created. For now it serves to at least mutually exclude
135 // different CreateChannel* calls. 136 // different CreateChannel* calls.
136 DCHECK(channel_id_.empty()); 137 DCHECK(channel_id_.empty());
137 channel_id_ = "ChannelMojo"; 138 channel_id_ = "ChannelMojo";
138 139
139 service_manager::InterfaceProvider* remote_interfaces = GetRemoteInterfaces(); 140 mojo::MessagePipe pipe;
140 DCHECK(remote_interfaces); 141 BindInterface(IPC::mojom::ChannelBootstrap::Name_, std::move(pipe.handle1));
141 142 channel_ = IPC::ChannelMojo::Create(std::move(pipe.handle0),
142 IPC::mojom::ChannelBootstrapPtr bootstrap;
143 remote_interfaces->GetInterface(&bootstrap);
144 channel_ = IPC::ChannelMojo::Create(bootstrap.PassInterface().PassHandle(),
145 IPC::Channel::MODE_SERVER, this); 143 IPC::Channel::MODE_SERVER, this);
146 DCHECK(channel_); 144 DCHECK(channel_);
147 145
148 bool initialized = InitChannel(); 146 bool initialized = InitChannel();
149 DCHECK(initialized); 147 DCHECK(initialized);
150 } 148 }
151 149
152 bool ChildProcessHostImpl::InitChannel() { 150 bool ChildProcessHostImpl::InitChannel() {
153 if (!channel_->Connect()) 151 if (!channel_->Connect())
154 return false; 152 return false;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { 277 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) {
280 delegate_->OnBadMessageReceived(message); 278 delegate_->OnBadMessageReceived(message);
281 } 279 }
282 280
283 void ChildProcessHostImpl::OnShutdownRequest() { 281 void ChildProcessHostImpl::OnShutdownRequest() {
284 if (delegate_->CanShutdown()) 282 if (delegate_->CanShutdown())
285 Send(new ChildProcessMsg_Shutdown()); 283 Send(new ChildProcessMsg_Shutdown());
286 } 284 }
287 285
288 } // namespace content 286 } // namespace content
OLDNEW
« no previous file with comments | « content/common/child_process_host_impl.h ('k') | content/common/service_manager/child_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698