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