OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "components/nacl/loader/nacl_listener.h" | 6 #include "components/nacl/loader/nacl_listener.h" |
7 | 7 |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "components/nacl/common/nacl_messages.h" | 26 #include "components/nacl/common/nacl_messages.h" |
27 #include "components/nacl/common/nacl_renderer_messages.h" | 27 #include "components/nacl/common/nacl_renderer_messages.h" |
28 #include "components/nacl/common/nacl_switches.h" | 28 #include "components/nacl/common/nacl_switches.h" |
29 #include "components/nacl/loader/nacl_ipc_adapter.h" | 29 #include "components/nacl/loader/nacl_ipc_adapter.h" |
30 #include "components/nacl/loader/nacl_validation_db.h" | 30 #include "components/nacl/loader/nacl_validation_db.h" |
31 #include "components/nacl/loader/nacl_validation_query.h" | 31 #include "components/nacl/loader/nacl_validation_query.h" |
32 #include "content/public/common/mojo_channel_switches.h" | 32 #include "content/public/common/mojo_channel_switches.h" |
33 #include "ipc/attachment_broker_unprivileged.h" | |
34 #include "ipc/ipc_channel_handle.h" | 33 #include "ipc/ipc_channel_handle.h" |
35 #include "ipc/ipc_switches.h" | 34 #include "ipc/ipc_switches.h" |
36 #include "ipc/ipc_sync_channel.h" | 35 #include "ipc/ipc_sync_channel.h" |
37 #include "ipc/ipc_sync_message_filter.h" | 36 #include "ipc/ipc_sync_message_filter.h" |
38 #include "mojo/edk/embedder/embedder.h" | 37 #include "mojo/edk/embedder/embedder.h" |
39 #include "mojo/edk/embedder/scoped_ipc_support.h" | 38 #include "mojo/edk/embedder/scoped_ipc_support.h" |
40 #include "native_client/src/public/chrome_main.h" | 39 #include "native_client/src/public/chrome_main.h" |
41 #include "native_client/src/public/nacl_app.h" | 40 #include "native_client/src/public/nacl_app.h" |
42 #include "native_client/src/public/nacl_desc.h" | 41 #include "native_client/src/public/nacl_desc.h" |
43 | 42 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 : shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, | 165 : shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
167 base::WaitableEvent::InitialState::NOT_SIGNALED), | 166 base::WaitableEvent::InitialState::NOT_SIGNALED), |
168 io_thread_("NaCl_IOThread"), | 167 io_thread_("NaCl_IOThread"), |
169 #if defined(OS_LINUX) | 168 #if defined(OS_LINUX) |
170 prereserved_sandbox_size_(0), | 169 prereserved_sandbox_size_(0), |
171 #endif | 170 #endif |
172 #if defined(OS_POSIX) | 171 #if defined(OS_POSIX) |
173 number_of_cores_(-1), // unknown/error | 172 number_of_cores_(-1), // unknown/error |
174 #endif | 173 #endif |
175 is_started_(false) { | 174 is_started_(false) { |
176 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); | |
177 io_thread_.StartWithOptions( | 175 io_thread_.StartWithOptions( |
178 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 176 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
179 DCHECK(g_listener == NULL); | 177 DCHECK(g_listener == NULL); |
180 g_listener = this; | 178 g_listener = this; |
181 | 179 |
182 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( | 180 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( |
183 io_thread_.task_runner().get())); | 181 io_thread_.task_runner().get())); |
184 #if defined(OS_WIN) | 182 #if defined(OS_WIN) |
185 mojo::edk::ScopedPlatformHandle platform_channel( | 183 mojo::edk::ScopedPlatformHandle platform_channel( |
186 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( | 184 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 mojo::edk::CreateChildMessagePipe( | 242 mojo::edk::CreateChildMessagePipe( |
245 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 243 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
246 switches::kMojoChannelToken))); | 244 switches::kMojoChannelToken))); |
247 DCHECK(handle.is_valid()); | 245 DCHECK(handle.is_valid()); |
248 IPC::ChannelHandle channel_handle(handle.release()); | 246 IPC::ChannelHandle channel_handle(handle.release()); |
249 | 247 |
250 channel_ = IPC::SyncChannel::Create(this, io_thread_.task_runner().get(), | 248 channel_ = IPC::SyncChannel::Create(this, io_thread_.task_runner().get(), |
251 &shutdown_event_); | 249 &shutdown_event_); |
252 filter_ = channel_->CreateSyncMessageFilter(); | 250 filter_ = channel_->CreateSyncMessageFilter(); |
253 channel_->AddFilter(new FileTokenMessageFilter()); | 251 channel_->AddFilter(new FileTokenMessageFilter()); |
254 IPC::AttachmentBroker* global = IPC::AttachmentBroker::GetGlobal(); | |
255 if (global && !global->IsPrivilegedBroker()) | |
256 global->RegisterBrokerCommunicationChannel(channel_.get()); | |
257 channel_->Init(channel_handle, IPC::Channel::MODE_CLIENT, true); | 252 channel_->Init(channel_handle, IPC::Channel::MODE_CLIENT, true); |
258 main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 253 main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
259 base::RunLoop().Run(); | 254 base::RunLoop().Run(); |
260 } | 255 } |
261 | 256 |
262 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { | 257 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { |
263 bool handled = true; | 258 bool handled = true; |
264 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) | 259 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) |
265 IPC_MESSAGE_HANDLER(NaClProcessMsg_AddPrefetchedResource, | 260 IPC_MESSAGE_HANDLER(NaClProcessMsg_AddPrefetchedResource, |
266 OnAddPrefetchedResource) | 261 OnAddPrefetchedResource) |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 } | 469 } |
475 | 470 |
476 void NaClListener::OnFileTokenResolved( | 471 void NaClListener::OnFileTokenResolved( |
477 uint64_t token_lo, | 472 uint64_t token_lo, |
478 uint64_t token_hi, | 473 uint64_t token_hi, |
479 IPC::PlatformFileForTransit ipc_fd, | 474 IPC::PlatformFileForTransit ipc_fd, |
480 base::FilePath file_path) { | 475 base::FilePath file_path) { |
481 resolved_cb_.Run(ipc_fd, file_path); | 476 resolved_cb_.Run(ipc_fd, file_path); |
482 resolved_cb_.Reset(); | 477 resolved_cb_.Reset(); |
483 } | 478 } |
OLD | NEW |