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_ipc_adapter.h" | 5 #include "components/nacl/loader/nacl_ipc_adapter.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/test/scoped_task_environment.h" |
14 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
15 #include "base/threading/simple_thread.h" | 16 #include "base/threading/simple_thread.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
17 #include "ipc/ipc_test_sink.h" | 18 #include "ipc/ipc_test_sink.h" |
18 #include "native_client/src/public/nacl_desc_custom.h" | 19 #include "native_client/src/public/nacl_desc_custom.h" |
19 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" | 20 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" |
20 #include "ppapi/c/ppb_file_io.h" | 21 #include "ppapi/c/ppb_file_io.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 namespace { | 24 namespace { |
(...skipping 27 matching lines...) Expand all Loading... |
51 NaClImcTypedMsgHdr msg = {&iov, 1}; | 52 NaClImcTypedMsgHdr msg = {&iov, 1}; |
52 return adapter_->BlockingReceive(&msg); | 53 return adapter_->BlockingReceive(&msg); |
53 } | 54 } |
54 | 55 |
55 int Send(void* buf, size_t buf_size) { | 56 int Send(void* buf, size_t buf_size) { |
56 NaClImcMsgIoVec iov = {buf, buf_size}; | 57 NaClImcMsgIoVec iov = {buf, buf_size}; |
57 NaClImcTypedMsgHdr msg = {&iov, 1}; | 58 NaClImcTypedMsgHdr msg = {&iov, 1}; |
58 return adapter_->Send(&msg); | 59 return adapter_->Send(&msg); |
59 } | 60 } |
60 | 61 |
61 base::MessageLoop message_loop_; | 62 base::test::ScopedTaskEnvironment scoped_task_environment_; |
62 | 63 |
63 scoped_refptr<NaClIPCAdapter> adapter_; | 64 scoped_refptr<NaClIPCAdapter> adapter_; |
64 | 65 |
65 // Messages sent from nacl to the adapter end up here. Note that we create | 66 // Messages sent from nacl to the adapter end up here. Note that we create |
66 // this pointer and pass ownership of it to the IPC adapter, who will keep | 67 // this pointer and pass ownership of it to the IPC adapter, who will keep |
67 // it alive as long as the adapter is alive. This means that when the | 68 // it alive as long as the adapter is alive. This means that when the |
68 // adapter goes away, this pointer will become invalid. | 69 // adapter goes away, this pointer will become invalid. |
69 // | 70 // |
70 // In real life the adapter needs to take ownership so the channel can be | 71 // In real life the adapter needs to take ownership so the channel can be |
71 // destroyed on the right thread. | 72 // destroyed on the right thread. |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 EXPECT_EQ(NACL_ABI_O_RDONLY, | 352 EXPECT_EQ(NACL_ABI_O_RDONLY, |
352 TranslatePepperFileReadWriteOpenFlagsForTesting( | 353 TranslatePepperFileReadWriteOpenFlagsForTesting( |
353 PP_FILEOPENFLAG_CREATE)); | 354 PP_FILEOPENFLAG_CREATE)); |
354 EXPECT_EQ(NACL_ABI_O_RDONLY, | 355 EXPECT_EQ(NACL_ABI_O_RDONLY, |
355 TranslatePepperFileReadWriteOpenFlagsForTesting( | 356 TranslatePepperFileReadWriteOpenFlagsForTesting( |
356 PP_FILEOPENFLAG_TRUNCATE)); | 357 PP_FILEOPENFLAG_TRUNCATE)); |
357 EXPECT_EQ(NACL_ABI_O_RDONLY, | 358 EXPECT_EQ(NACL_ABI_O_RDONLY, |
358 TranslatePepperFileReadWriteOpenFlagsForTesting( | 359 TranslatePepperFileReadWriteOpenFlagsForTesting( |
359 PP_FILEOPENFLAG_EXCLUSIVE)); | 360 PP_FILEOPENFLAG_EXCLUSIVE)); |
360 } | 361 } |
OLD | NEW |