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/file_impl.h" | 5 #include "components/filesystem/file_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <limits> | 9 #include <limits> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/scoped_file.h" | 13 #include "base/files/scoped_file.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "components/filesystem/lock_table.h" | 16 #include "components/filesystem/lock_table.h" |
17 #include "components/filesystem/shared_temp_dir.h" | 17 #include "components/filesystem/shared_temp_dir.h" |
18 #include "components/filesystem/util.h" | 18 #include "components/filesystem/util.h" |
19 #include "mojo/common/common_type_converters.h" | 19 #include "mojo/common/common_type_converters.h" |
20 #include "mojo/platform_handle/platform_handle_functions.h" | 20 #include "mojo/public/cpp/system/platform_handle.h" |
21 | 21 |
22 static_assert(sizeof(off_t) <= sizeof(int64_t), "off_t too big"); | 22 static_assert(sizeof(off_t) <= sizeof(int64_t), "off_t too big"); |
23 static_assert(sizeof(size_t) >= sizeof(uint32_t), "size_t too small"); | 23 static_assert(sizeof(size_t) >= sizeof(uint32_t), "size_t too small"); |
24 | 24 |
25 using base::Time; | 25 using base::Time; |
26 using mojo::ScopedHandle; | 26 using mojo::ScopedHandle; |
27 | 27 |
28 namespace filesystem { | 28 namespace filesystem { |
29 namespace { | 29 namespace { |
30 | 30 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 347 |
348 // Perform one additional check right before we send the file's file | 348 // Perform one additional check right before we send the file's file |
349 // descriptor over mojo. This is theoretically redundant, but given that | 349 // descriptor over mojo. This is theoretically redundant, but given that |
350 // passing a file descriptor to a directory is a sandbox escape on Windows, | 350 // passing a file descriptor to a directory is a sandbox escape on Windows, |
351 // we should be absolutely paranoid. | 351 // we should be absolutely paranoid. |
352 if (info.is_directory) { | 352 if (info.is_directory) { |
353 callback.Run(mojom::FileError::NOT_A_FILE, ScopedHandle()); | 353 callback.Run(mojom::FileError::NOT_A_FILE, ScopedHandle()); |
354 return; | 354 return; |
355 } | 355 } |
356 | 356 |
357 MojoHandle mojo_handle; | 357 callback.Run(mojom::FileError::OK, |
358 MojoResult create_result = MojoCreatePlatformHandleWrapper( | 358 mojo::WrapPlatformFile(new_file.TakePlatformFile())); |
359 new_file.TakePlatformFile(), &mojo_handle); | |
360 if (create_result != MOJO_RESULT_OK) { | |
361 callback.Run(mojom::FileError::FAILED, ScopedHandle()); | |
362 return; | |
363 } | |
364 | |
365 callback.Run(mojom::FileError::OK, ScopedHandle(mojo::Handle(mojo_handle))); | |
366 } | 359 } |
367 | 360 |
368 } // namespace filesystem | 361 } // namespace filesystem |
OLD | NEW |