OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MOJO_EDK_TEST_TEST_UTILS_H_ | 5 #ifndef MOJO_EDK_TEST_TEST_UTILS_H_ |
6 #define MOJO_EDK_TEST_TEST_UTILS_H_ | 6 #define MOJO_EDK_TEST_TEST_UTILS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/files/scoped_file.h" | |
14 #include "mojo/edk/embedder/platform_handle.h" | 13 #include "mojo/edk/embedder/platform_handle.h" |
15 #include "mojo/edk/embedder/scoped_platform_handle.h" | 14 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 15 #include "mojo/edk/util/scoped_file.h" |
16 | 16 |
17 namespace mojo { | 17 namespace mojo { |
18 namespace test { | 18 namespace test { |
19 | 19 |
20 // On success, |bytes_written| is updated to the number of bytes written; | 20 // On success, |bytes_written| is updated to the number of bytes written; |
21 // otherwise it is untouched. | 21 // otherwise it is untouched. |
22 bool BlockingWrite(const embedder::PlatformHandle& handle, | 22 bool BlockingWrite(const embedder::PlatformHandle& handle, |
23 const void* buffer, | 23 const void* buffer, |
24 size_t bytes_to_write, | 24 size_t bytes_to_write, |
25 size_t* bytes_written); | 25 size_t* bytes_written); |
26 | 26 |
27 // On success, |bytes_read| is updated to the number of bytes read; otherwise it | 27 // On success, |bytes_read| is updated to the number of bytes read; otherwise it |
28 // is untouched. | 28 // is untouched. |
29 bool BlockingRead(const embedder::PlatformHandle& handle, | 29 bool BlockingRead(const embedder::PlatformHandle& handle, |
30 void* buffer, | 30 void* buffer, |
31 size_t buffer_size, | 31 size_t buffer_size, |
32 size_t* bytes_read); | 32 size_t* bytes_read); |
33 | 33 |
34 // If the read is done successfully or would block, the function returns true | 34 // If the read is done successfully or would block, the function returns true |
35 // and updates |bytes_read| to the number of bytes read (0 if the read would | 35 // and updates |bytes_read| to the number of bytes read (0 if the read would |
36 // block); otherwise it returns false and leaves |bytes_read| untouched. | 36 // block); otherwise it returns false and leaves |bytes_read| untouched. |
37 // |handle| must already be in non-blocking mode. | 37 // |handle| must already be in non-blocking mode. |
38 bool NonBlockingRead(const embedder::PlatformHandle& handle, | 38 bool NonBlockingRead(const embedder::PlatformHandle& handle, |
39 void* buffer, | 39 void* buffer, |
40 size_t buffer_size, | 40 size_t buffer_size, |
41 size_t* bytes_read); | 41 size_t* bytes_read); |
42 | 42 |
43 // Gets a (scoped) |PlatformHandle| from the given (scoped) |FILE|. | 43 // Gets a (scoped) |PlatformHandle| from the given (scoped) |FILE|. |
44 embedder::ScopedPlatformHandle PlatformHandleFromFILE(base::ScopedFILE fp); | 44 embedder::ScopedPlatformHandle PlatformHandleFromFILE(util::ScopedFILE fp); |
45 | 45 |
46 // Gets a (scoped) |FILE| from a (scoped) |PlatformHandle|. | 46 // Gets a (scoped) |FILE| from a (scoped) |PlatformHandle|. |
47 base::ScopedFILE FILEFromPlatformHandle(embedder::ScopedPlatformHandle h, | 47 util::ScopedFILE FILEFromPlatformHandle(embedder::ScopedPlatformHandle h, |
48 const char* mode); | 48 const char* mode); |
49 | 49 |
50 } // namespace test | 50 } // namespace test |
51 } // namespace mojo | 51 } // namespace mojo |
52 | 52 |
53 #endif // MOJO_EDK_TEST_TEST_UTILS_H_ | 53 #endif // MOJO_EDK_TEST_TEST_UTILS_H_ |
OLD | NEW |