OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/nacl/nacl_thread.h" | 5 #include "chrome/nacl/nacl_thread.h" |
6 | 6 |
7 #include "chrome/common/notification_service.h" | 7 #include "chrome/common/notification_service.h" |
8 #include "chrome/common/nacl_messages.h" | 8 #include "chrome/common/nacl_messages.h" |
9 | 9 |
10 // This is ugly. We need an interface header file for the exported | 10 // This is ugly. We need an interface header file for the exported |
11 // sel_ldr interfaces. | 11 // sel_ldr interfaces. |
12 // TODO(gregoryd,sehr): Add an interface header. | 12 // TODO(gregoryd,sehr): Add an interface header. |
13 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
14 typedef HANDLE NaClHandle; | 14 typedef HANDLE NaClHandle; |
15 #else | 15 #else |
16 typedef int NaClHandle; | 16 typedef int NaClHandle; |
17 #endif // NaClHandle | 17 #endif // NaClHandle |
18 | 18 |
19 int SelMain(const int desc, const NaClHandle handle); | 19 // This is currently necessary because we have a conflict between |
| 20 // NaCl's "struct NaClThread" and Chromium's "class NaClThread". |
| 21 extern "C" int NaClMainForChromium(int handle_count, const NaClHandle* handles); |
20 | 22 |
21 NaClThread::NaClThread() { | 23 NaClThread::NaClThread() { |
22 } | 24 } |
23 | 25 |
24 NaClThread::~NaClThread() { | 26 NaClThread::~NaClThread() { |
25 } | 27 } |
26 | 28 |
27 NaClThread* NaClThread::current() { | 29 NaClThread* NaClThread::current() { |
28 return static_cast<NaClThread*>(ChildThread::current()); | 30 return static_cast<NaClThread*>(ChildThread::current()); |
29 } | 31 } |
30 | 32 |
31 void NaClThread::OnControlMessageReceived(const IPC::Message& msg) { | 33 void NaClThread::OnControlMessageReceived(const IPC::Message& msg) { |
32 IPC_BEGIN_MESSAGE_MAP(NaClThread, msg) | 34 IPC_BEGIN_MESSAGE_MAP(NaClThread, msg) |
33 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStartSelLdr) | 35 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStartSelLdr) |
34 IPC_END_MESSAGE_MAP() | 36 IPC_END_MESSAGE_MAP() |
35 } | 37 } |
36 | 38 |
37 void NaClThread::OnStartSelLdr(int channel_descriptor, | 39 void NaClThread::OnStartSelLdr(int channel_descriptor, |
38 nacl::FileDescriptor handle) { | 40 nacl::FileDescriptor handle) { |
39 SelMain(channel_descriptor, nacl::ToNativeHandle(handle)); | 41 NaClHandle nacl_handle = nacl::ToNativeHandle(handle); |
| 42 NaClMainForChromium(/* handle_count= */ 1, &nacl_handle); |
40 } | 43 } |
OLD | NEW |