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