| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "files/c/tests/test_utils.h" | 5 #include "files/c/tests/test_utils.h" |
| 6 | 6 |
| 7 #include "files/c/lib/template_util.h" | 7 #include "files/c/lib/template_util.h" |
| 8 #include "files/interfaces/file.mojom.h" | 8 #include "files/interfaces/file.mojom.h" |
| 9 #include "files/interfaces/types.mojom.h" | 9 #include "files/interfaces/types.mojom.h" |
| 10 #include "mojo/public/cpp/environment/logging.h" | 10 #include "mojo/public/cpp/environment/logging.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 MOJO_CHECK(path); | 33 MOJO_CHECK(path); |
| 34 mojo::files::DirectoryPtr& dir = *root; | 34 mojo::files::DirectoryPtr& dir = *root; |
| 35 | 35 |
| 36 mojo::files::FilePtr file; | 36 mojo::files::FilePtr file; |
| 37 mojo::files::Error error = mojo::files::Error::INTERNAL; | 37 mojo::files::Error error = mojo::files::Error::INTERNAL; |
| 38 dir->OpenFile(path, mojo::GetProxy(&file), open_flags, Capture(&error)); | 38 dir->OpenFile(path, mojo::GetProxy(&file), open_flags, Capture(&error)); |
| 39 MOJO_CHECK(dir.WaitForIncomingResponse()); | 39 MOJO_CHECK(dir.WaitForIncomingResponse()); |
| 40 if (error != mojo::files::Error::OK) | 40 if (error != mojo::files::Error::OK) |
| 41 return nullptr; | 41 return nullptr; |
| 42 | 42 |
| 43 return file.Pass(); | 43 return file; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void CreateTestFileAt(mojo::files::DirectoryPtr* root, | 46 void CreateTestFileAt(mojo::files::DirectoryPtr* root, |
| 47 const char* path, | 47 const char* path, |
| 48 size_t size) { | 48 size_t size) { |
| 49 mojo::files::FilePtr file = OpenFileAt( | 49 mojo::files::FilePtr file = OpenFileAt( |
| 50 root, path, mojo::files::kOpenFlagWrite | mojo::files::kOpenFlagCreate | | 50 root, path, mojo::files::kOpenFlagWrite | mojo::files::kOpenFlagCreate | |
| 51 mojo::files::kOpenFlagExclusive); | 51 mojo::files::kOpenFlagExclusive); |
| 52 MOJO_CHECK(file); | 52 MOJO_CHECK(file); |
| 53 | 53 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Capture(&error, &bytes_read)); | 94 Capture(&error, &bytes_read)); |
| 95 MOJO_CHECK(file.WaitForIncomingResponse()); | 95 MOJO_CHECK(file.WaitForIncomingResponse()); |
| 96 if (!bytes_read.size()) | 96 if (!bytes_read.size()) |
| 97 return std::string(); | 97 return std::string(); |
| 98 return std::string(reinterpret_cast<const char*>(&bytes_read[0]), | 98 return std::string(reinterpret_cast<const char*>(&bytes_read[0]), |
| 99 bytes_read.size()); | 99 bytes_read.size()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace test | 102 } // namespace test |
| 103 } // namespace mojio | 103 } // namespace mojio |
| OLD | NEW |