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 <stdint.h> | 7 #include <stdint.h> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 const WriteCallback& callback) { | 95 const WriteCallback& callback) { |
96 DCHECK(!bytes_to_write.is_null()); | 96 DCHECK(!bytes_to_write.is_null()); |
97 if (!file_.IsValid()) { | 97 if (!file_.IsValid()) { |
98 callback.Run(GetError(file_), 0); | 98 callback.Run(GetError(file_), 0); |
99 return; | 99 return; |
100 } | 100 } |
101 // Who knows what |write()| would return if the size is that big (and it | 101 // Who knows what |write()| would return if the size is that big (and it |
102 // actually wrote that much). | 102 // actually wrote that much). |
103 if (bytes_to_write.size() > | 103 if (bytes_to_write.size() > |
104 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
105 static_cast<size_t>(std::numeric_limits<int>::max())) { | 105 std::numeric_limits<INT>::max()) { |
106 #else | 106 #else |
107 static_cast<size_t>(std::numeric_limits<ssize_t>::max())) { | 107 static_cast<size_t>(std::numeric_limits<ssize_t>::max())) { |
108 #endif | 108 #endif |
109 callback.Run(FILE_ERROR_INVALID_OPERATION, 0); | 109 callback.Run(FILE_ERROR_INVALID_OPERATION, 0); |
110 return; | 110 return; |
111 } | 111 } |
112 if (FileError error = IsOffsetValid(offset)) { | 112 if (FileError error = IsOffsetValid(offset)) { |
113 callback.Run(error, 0); | 113 callback.Run(error, 0); |
114 return; | 114 return; |
115 } | 115 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 new_file.TakePlatformFile(), &mojo_handle); | 302 new_file.TakePlatformFile(), &mojo_handle); |
303 if (create_result != MOJO_RESULT_OK) { | 303 if (create_result != MOJO_RESULT_OK) { |
304 callback.Run(FILE_ERROR_FAILED, ScopedHandle()); | 304 callback.Run(FILE_ERROR_FAILED, ScopedHandle()); |
305 return; | 305 return; |
306 } | 306 } |
307 | 307 |
308 callback.Run(FILE_ERROR_OK, ScopedHandle(mojo::Handle(mojo_handle)).Pass()); | 308 callback.Run(FILE_ERROR_OK, ScopedHandle(mojo::Handle(mojo_handle)).Pass()); |
309 } | 309 } |
310 | 310 |
311 } // namespace filesystem | 311 } // namespace filesystem |
OLD | NEW |