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

Side by Side Diff: content/child/child_thread_impl.cc

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 (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/child/child_thread_impl.h" 5 #include "content/child/child_thread_impl.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "content/child/thread_safe_sender.h" 49 #include "content/child/thread_safe_sender.h"
50 #include "content/child/websocket_dispatcher.h" 50 #include "content/child/websocket_dispatcher.h"
51 #include "content/common/child_process_messages.h" 51 #include "content/common/child_process_messages.h"
52 #include "content/common/in_process_child_thread_params.h" 52 #include "content/common/in_process_child_thread_params.h"
53 #include "content/public/common/content_switches.h" 53 #include "content/public/common/content_switches.h"
54 #include "ipc/ipc_logging.h" 54 #include "ipc/ipc_logging.h"
55 #include "ipc/ipc_switches.h" 55 #include "ipc/ipc_switches.h"
56 #include "ipc/ipc_sync_channel.h" 56 #include "ipc/ipc_sync_channel.h"
57 #include "ipc/ipc_sync_message_filter.h" 57 #include "ipc/ipc_sync_message_filter.h"
58 #include "ipc/mojo/ipc_channel_mojo.h" 58 #include "ipc/mojo/ipc_channel_mojo.h"
59 #include "ipc/mojo/scoped_ipc_support.h"
59 60
60 #if defined(OS_WIN) 61 #if defined(OS_WIN)
61 #include "content/common/handle_enumerator_win.h" 62 #include "content/common/handle_enumerator_win.h"
62 #endif 63 #endif
63 64
64 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) 65 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED)
65 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" 66 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
66 #endif 67 #endif
67 68
68 using tracked_objects::ThreadData; 69 using tracked_objects::ThreadData;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 198 }
198 199
199 #endif 200 #endif
200 201
201 } // namespace 202 } // namespace
202 203
203 ChildThread* ChildThread::Get() { 204 ChildThread* ChildThread::Get() {
204 return ChildThreadImpl::current(); 205 return ChildThreadImpl::current();
205 } 206 }
206 207
208 // Mojo client channel delegate to be used in single process mode.
209 class ChildThreadImpl::SingleProcessChannelDelegate
210 : public IPC::ChannelMojo::Delegate {
211 public:
212 explicit SingleProcessChannelDelegate(
213 scoped_refptr<base::SequencedTaskRunner> io_runner)
214 : io_runner_(io_runner), weak_factory_(this) {}
215
216 ~SingleProcessChannelDelegate() override {}
217
218 base::WeakPtr<IPC::ChannelMojo::Delegate> ToWeakPtr() override {
219 return weak_factory_.GetWeakPtr();
220 }
221
222 scoped_refptr<base::TaskRunner> GetIOTaskRunner() override {
223 return io_runner_;
224 }
225
226 void OnChannelCreated(base::WeakPtr<IPC::ChannelMojo> channel) override {}
227
228 void DeleteSoon() {
229 io_runner_->PostTask(
230 FROM_HERE,
231 base::Bind(&base::DeletePointer<SingleProcessChannelDelegate>,
232 base::Unretained(this)));
233 }
234
235 private:
236 scoped_refptr<base::SequencedTaskRunner> io_runner_;
237 base::WeakPtrFactory<IPC::ChannelMojo::Delegate> weak_factory_;
238
239 DISALLOW_COPY_AND_ASSIGN(SingleProcessChannelDelegate);
240 };
241
242 void ChildThreadImpl::SingleProcessChannelDelegateDeleter::operator()(
243 SingleProcessChannelDelegate* delegate) const {
244 delegate->DeleteSoon();
245 }
246
207 ChildThreadImpl::Options::Options() 247 ChildThreadImpl::Options::Options()
208 : channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 248 : channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
209 switches::kProcessChannelID)), 249 switches::kProcessChannelID)),
210 use_mojo_channel(false) { 250 use_mojo_channel(false) {
211 } 251 }
212 252
213 ChildThreadImpl::Options::~Options() { 253 ChildThreadImpl::Options::~Options() {
214 } 254 }
215 255
216 ChildThreadImpl::Options::Builder::Builder() { 256 ChildThreadImpl::Options::Builder::Builder() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return browser_process_io_runner_; 314 return browser_process_io_runner_;
275 return ChildProcess::current()->io_message_loop_proxy(); 315 return ChildProcess::current()->io_message_loop_proxy();
276 } 316 }
277 317
278 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) { 318 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) {
279 bool create_pipe_now = true; 319 bool create_pipe_now = true;
280 if (use_mojo_channel) { 320 if (use_mojo_channel) {
281 VLOG(1) << "Mojo is enabled on child"; 321 VLOG(1) << "Mojo is enabled on child";
282 scoped_refptr<base::SequencedTaskRunner> io_task_runner = GetIOTaskRunner(); 322 scoped_refptr<base::SequencedTaskRunner> io_task_runner = GetIOTaskRunner();
283 DCHECK(io_task_runner); 323 DCHECK(io_task_runner);
284 channel_->Init(IPC::ChannelMojo::CreateClientFactory( 324 if (IsInBrowserProcess())
285 nullptr, io_task_runner, channel_name_), 325 single_process_channel_delegate_.reset(
286 create_pipe_now); 326 new SingleProcessChannelDelegate(io_task_runner));
327 ipc_support_.reset(new IPC::ScopedIPCSupport(io_task_runner));
328 channel_->Init(
329 IPC::ChannelMojo::CreateClientFactory(
330 single_process_channel_delegate_.get(),
331 channel_name_),
332 create_pipe_now);
287 return; 333 return;
288 } 334 }
289 335
290 VLOG(1) << "Mojo is disabled on child"; 336 VLOG(1) << "Mojo is disabled on child";
291 channel_->Init(channel_name_, IPC::Channel::MODE_CLIENT, create_pipe_now); 337 channel_->Init(channel_name_, IPC::Channel::MODE_CLIENT, create_pipe_now);
292 } 338 }
293 339
294 void ChildThreadImpl::Init(const Options& options) { 340 void ChildThreadImpl::Init(const Options& options) {
295 channel_name_ = options.channel_name; 341 channel_name_ = options.channel_name;
296 342
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 // doesn't cause such issues. TODO(gab): Remove this once the experiment is 749 // doesn't cause such issues. TODO(gab): Remove this once the experiment is
704 // over (http://crbug.com/458594). 750 // over (http://crbug.com/458594).
705 base::FieldTrial* trial = 751 base::FieldTrial* trial =
706 base::FieldTrialList::Find("BackgroundRendererProcesses"); 752 base::FieldTrialList::Find("BackgroundRendererProcesses");
707 if (trial && trial->group_name() == "AllowBackgroundModeFromRenderer") 753 if (trial && trial->group_name() == "AllowBackgroundModeFromRenderer")
708 base::Process::Current().SetProcessBackgrounded(background); 754 base::Process::Current().SetProcessBackgrounded(background);
709 #endif // OS_WIN 755 #endif // OS_WIN
710 } 756 }
711 757
712 } // namespace content 758 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/test/render_thread_impl_browser_test_ipc_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698