| 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 "components/filesystem/directory_impl.h" | 5 #include "components/filesystem/directory_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "components/filesystem/file_impl.h" | 15 #include "components/filesystem/file_impl.h" |
| 16 #include "components/filesystem/lock_table.h" | 16 #include "components/filesystem/lock_table.h" |
| 17 #include "components/filesystem/util.h" | 17 #include "components/filesystem/util.h" |
| 18 #include "mojo/common/common_type_converters.h" | 18 #include "mojo/common/common_type_converters.h" |
| 19 #include "mojo/platform_handle/platform_handle_functions.h" | 19 #include "mojo/public/cpp/system/platform_handle.h" |
| 20 | 20 |
| 21 namespace filesystem { | 21 namespace filesystem { |
| 22 | 22 |
| 23 DirectoryImpl::DirectoryImpl(mojo::InterfaceRequest<mojom::Directory> request, | 23 DirectoryImpl::DirectoryImpl(mojo::InterfaceRequest<mojom::Directory> request, |
| 24 base::FilePath directory_path, | 24 base::FilePath directory_path, |
| 25 scoped_refptr<SharedTempDir> temp_dir, | 25 scoped_refptr<SharedTempDir> temp_dir, |
| 26 scoped_refptr<LockTable> lock_table) | 26 scoped_refptr<LockTable> lock_table) |
| 27 : binding_(this, std::move(request)), | 27 : binding_(this, std::move(request)), |
| 28 directory_path_(directory_path), | 28 directory_path_(directory_path), |
| 29 temp_dir_(std::move(temp_dir)), | 29 temp_dir_(std::move(temp_dir)), |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 *error = mojom::FileError::NOT_A_FILE; | 345 *error = mojom::FileError::NOT_A_FILE; |
| 346 return mojo::ScopedHandle(); | 346 return mojo::ScopedHandle(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 base::File base_file(path, open_flags); | 349 base::File base_file(path, open_flags); |
| 350 if (!base_file.IsValid()) { | 350 if (!base_file.IsValid()) { |
| 351 *error = GetError(base_file); | 351 *error = GetError(base_file); |
| 352 return mojo::ScopedHandle(); | 352 return mojo::ScopedHandle(); |
| 353 } | 353 } |
| 354 | 354 |
| 355 MojoHandle mojo_handle; | |
| 356 MojoResult create_result = MojoCreatePlatformHandleWrapper( | |
| 357 base_file.TakePlatformFile(), &mojo_handle); | |
| 358 if (create_result != MOJO_RESULT_OK) { | |
| 359 *error = mojom::FileError::FAILED; | |
| 360 return mojo::ScopedHandle(); | |
| 361 } | |
| 362 | |
| 363 *error = mojom::FileError::OK; | 355 *error = mojom::FileError::OK; |
| 364 return mojo::ScopedHandle(mojo::Handle(mojo_handle)); | 356 return mojo::WrapPlatformFile(base_file.TakePlatformFile()); |
| 365 } | 357 } |
| 366 | 358 |
| 367 } // namespace filesystem | 359 } // namespace filesystem |
| OLD | NEW |