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 "components/nacl/loader/nacl_listener.h" | 5 #include "components/nacl/loader/nacl_listener.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 }; | 217 }; |
218 | 218 |
219 void NaClListener::Listen() { | 219 void NaClListener::Listen() { |
220 std::string channel_name = | 220 std::string channel_name = |
221 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 221 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
222 switches::kProcessChannelID); | 222 switches::kProcessChannelID); |
223 channel_ = IPC::SyncChannel::Create(this, io_thread_.task_runner().get(), | 223 channel_ = IPC::SyncChannel::Create(this, io_thread_.task_runner().get(), |
224 &shutdown_event_); | 224 &shutdown_event_); |
225 filter_ = channel_->CreateSyncMessageFilter(); | 225 filter_ = channel_->CreateSyncMessageFilter(); |
226 channel_->AddFilter(new FileTokenMessageFilter()); | 226 channel_->AddFilter(new FileTokenMessageFilter()); |
227 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true); | |
228 IPC::AttachmentBroker* global = IPC::AttachmentBroker::GetGlobal(); | 227 IPC::AttachmentBroker* global = IPC::AttachmentBroker::GetGlobal(); |
229 if (global && !global->IsPrivilegedBroker()) | 228 if (global && !global->IsPrivilegedBroker()) |
230 global->RegisterBrokerCommunicationChannel(channel_.get()); | 229 global->RegisterBrokerCommunicationChannel(channel_.get()); |
| 230 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true); |
231 main_loop_ = base::MessageLoop::current(); | 231 main_loop_ = base::MessageLoop::current(); |
232 main_loop_->Run(); | 232 main_loop_->Run(); |
233 } | 233 } |
234 | 234 |
235 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { | 235 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { |
236 bool handled = true; | 236 bool handled = true; |
237 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) | 237 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) |
238 IPC_MESSAGE_HANDLER(NaClProcessMsg_AddPrefetchedResource, | 238 IPC_MESSAGE_HANDLER(NaClProcessMsg_AddPrefetchedResource, |
239 OnAddPrefetchedResource) | 239 OnAddPrefetchedResource) |
240 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart) | 240 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart) |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 446 } |
447 | 447 |
448 void NaClListener::OnFileTokenResolved( | 448 void NaClListener::OnFileTokenResolved( |
449 uint64_t token_lo, | 449 uint64_t token_lo, |
450 uint64_t token_hi, | 450 uint64_t token_hi, |
451 IPC::PlatformFileForTransit ipc_fd, | 451 IPC::PlatformFileForTransit ipc_fd, |
452 base::FilePath file_path) { | 452 base::FilePath file_path) { |
453 resolved_cb_.Run(ipc_fd, file_path); | 453 resolved_cb_.Run(ipc_fd, file_path); |
454 resolved_cb_.Reset(); | 454 resolved_cb_.Reset(); |
455 } | 455 } |
OLD | NEW |