OLD | NEW |
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 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 ChildThreadImpl::Options::Builder::Builder() { | 260 ChildThreadImpl::Options::Builder::Builder() { |
261 } | 261 } |
262 | 262 |
263 ChildThreadImpl::Options::Builder& | 263 ChildThreadImpl::Options::Builder& |
264 ChildThreadImpl::Options::Builder::InBrowserProcess( | 264 ChildThreadImpl::Options::Builder::InBrowserProcess( |
265 const InProcessChildThreadParams& params) { | 265 const InProcessChildThreadParams& params) { |
266 options_.browser_process_io_runner = params.io_runner(); | 266 options_.browser_process_io_runner = params.io_runner(); |
267 options_.channel_name = params.channel_name(); | 267 options_.channel_name = params.channel_name(); |
268 options_.in_process_message_pipe_handle = params.handle(); | 268 options_.in_process_message_pipe_handle = params.handle(); |
| 269 options_.in_process_application_token = params.application_token(); |
269 return *this; | 270 return *this; |
270 } | 271 } |
271 | 272 |
272 ChildThreadImpl::Options::Builder& | 273 ChildThreadImpl::Options::Builder& |
273 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) { | 274 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) { |
274 options_.use_mojo_channel = use_mojo_channel; | 275 options_.use_mojo_channel = use_mojo_channel; |
275 return *this; | 276 return *this; |
276 } | 277 } |
277 | 278 |
278 ChildThreadImpl::Options::Builder& | 279 ChildThreadImpl::Options::Builder& |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 InitializeMojoIPCChannel(); | 384 InitializeMojoIPCChannel(); |
384 } | 385 } |
385 | 386 |
386 if (MojoShellConnectionImpl::Get()) { | 387 if (MojoShellConnectionImpl::Get()) { |
387 base::ElapsedTimer timer; | 388 base::ElapsedTimer timer; |
388 MojoShellConnectionImpl::Get()->BindToRequestFromCommandLine(); | 389 MojoShellConnectionImpl::Get()->BindToRequestFromCommandLine(); |
389 UMA_HISTOGRAM_TIMES("Mojo.Shell.ChildConnectionTime", timer.Elapsed()); | 390 UMA_HISTOGRAM_TIMES("Mojo.Shell.ChildConnectionTime", timer.Elapsed()); |
390 } | 391 } |
391 | 392 |
392 mojo_application_.reset(new MojoApplication(GetIOTaskRunner())); | 393 mojo_application_.reset(new MojoApplication(GetIOTaskRunner())); |
| 394 std::string mojo_application_token; |
| 395 if (!IsInBrowserProcess()) { |
| 396 mojo_application_token = |
| 397 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 398 switches::kMojoApplicationChannelToken); |
| 399 } else { |
| 400 mojo_application_token = options.in_process_application_token; |
| 401 } |
| 402 if (!mojo_application_token.empty()) |
| 403 mojo_application_->InitWithToken(mojo_application_token); |
393 | 404 |
394 sync_message_filter_ = channel_->CreateSyncMessageFilter(); | 405 sync_message_filter_ = channel_->CreateSyncMessageFilter(); |
395 thread_safe_sender_ = new ThreadSafeSender( | 406 thread_safe_sender_ = new ThreadSafeSender( |
396 message_loop_->task_runner(), sync_message_filter_.get()); | 407 message_loop_->task_runner(), sync_message_filter_.get()); |
397 | 408 |
398 resource_dispatcher_.reset(new ResourceDispatcher( | 409 resource_dispatcher_.reset(new ResourceDispatcher( |
399 this, message_loop()->task_runner())); | 410 this, message_loop()->task_runner())); |
400 websocket_dispatcher_.reset(new WebSocketDispatcher); | 411 websocket_dispatcher_.reset(new WebSocketDispatcher); |
401 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 412 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
402 | 413 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 void ChildThreadImpl::EnsureConnected() { | 720 void ChildThreadImpl::EnsureConnected() { |
710 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 721 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
711 base::Process::Current().Terminate(0, false); | 722 base::Process::Current().Terminate(0, false); |
712 } | 723 } |
713 | 724 |
714 bool ChildThreadImpl::IsInBrowserProcess() const { | 725 bool ChildThreadImpl::IsInBrowserProcess() const { |
715 return browser_process_io_runner_; | 726 return browser_process_io_runner_; |
716 } | 727 } |
717 | 728 |
718 } // namespace content | 729 } // namespace content |
OLD | NEW |