Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: components/filesystem/file_impl.cc

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/filesystem/file_impl.h ('k') | components/filesystem/file_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
8 #include <limits> 9 #include <limits>
9 10
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/files/scoped_file.h" 12 #include "base/files/scoped_file.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "build/build_config.h"
13 #include "components/filesystem/util.h" 15 #include "components/filesystem/util.h"
14 #include "mojo/platform_handle/platform_handle_functions.h" 16 #include "mojo/platform_handle/platform_handle_functions.h"
15 17
16 static_assert(sizeof(off_t) <= sizeof(int64_t), "off_t too big"); 18 static_assert(sizeof(off_t) <= sizeof(int64_t), "off_t too big");
17 static_assert(sizeof(size_t) >= sizeof(uint32_t), "size_t too small"); 19 static_assert(sizeof(size_t) >= sizeof(uint32_t), "size_t too small");
18 20
19 using base::Time; 21 using base::Time;
20 using mojo::ScopedHandle; 22 using mojo::ScopedHandle;
21 23
22 namespace filesystem { 24 namespace filesystem {
23 25
24 const size_t kMaxReadSize = 1 * 1024 * 1024; // 1 MB. 26 const size_t kMaxReadSize = 1 * 1024 * 1024; // 1 MB.
25 27
26 FileImpl::FileImpl(mojo::InterfaceRequest<File> request, 28 FileImpl::FileImpl(mojo::InterfaceRequest<File> request,
27 const base::FilePath& path, 29 const base::FilePath& path,
28 uint32 flags) 30 uint32_t flags)
29 : binding_(this, request.Pass()), file_(path, flags) { 31 : binding_(this, request.Pass()), file_(path, flags) {
30 DCHECK(file_.IsValid()); 32 DCHECK(file_.IsValid());
31 } 33 }
32 34
33 FileImpl::FileImpl(mojo::InterfaceRequest<File> request, base::File file) 35 FileImpl::FileImpl(mojo::InterfaceRequest<File> request, base::File file)
34 : binding_(this, request.Pass()), file_(file.Pass()) { 36 : binding_(this, request.Pass()), file_(file.Pass()) {
35 DCHECK(file_.IsValid()); 37 DCHECK(file_.IsValid());
36 } 38 }
37 39
38 FileImpl::~FileImpl() { 40 FileImpl::~FileImpl() {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 153 }
152 if (FileError error = IsOffsetValid(offset)) { 154 if (FileError error = IsOffsetValid(offset)) {
153 callback.Run(error, 0); 155 callback.Run(error, 0);
154 return; 156 return;
155 } 157 }
156 if (FileError error = IsWhenceValid(whence)) { 158 if (FileError error = IsWhenceValid(whence)) {
157 callback.Run(error, 0); 159 callback.Run(error, 0);
158 return; 160 return;
159 } 161 }
160 162
161 int64 position = file_.Seek(static_cast<base::File::Whence>(whence), offset); 163 int64_t position =
164 file_.Seek(static_cast<base::File::Whence>(whence), offset);
162 if (position < 0) { 165 if (position < 0) {
163 callback.Run(FILE_ERROR_FAILED, 0); 166 callback.Run(FILE_ERROR_FAILED, 0);
164 return; 167 return;
165 } 168 }
166 169
167 callback.Run(FILE_ERROR_OK, static_cast<int64>(position)); 170 callback.Run(FILE_ERROR_OK, static_cast<int64_t>(position));
168 } 171 }
169 172
170 void FileImpl::Stat(const StatCallback& callback) { 173 void FileImpl::Stat(const StatCallback& callback) {
171 if (!file_.IsValid()) { 174 if (!file_.IsValid()) {
172 callback.Run(GetError(file_), nullptr); 175 callback.Run(GetError(file_), nullptr);
173 return; 176 return;
174 } 177 }
175 178
176 base::File::Info info; 179 base::File::Info info;
177 if (!file_.GetInfo(&info)) { 180 if (!file_.GetInfo(&info)) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 new_file.TakePlatformFile(), &mojo_handle); 305 new_file.TakePlatformFile(), &mojo_handle);
303 if (create_result != MOJO_RESULT_OK) { 306 if (create_result != MOJO_RESULT_OK) {
304 callback.Run(FILE_ERROR_FAILED, ScopedHandle()); 307 callback.Run(FILE_ERROR_FAILED, ScopedHandle());
305 return; 308 return;
306 } 309 }
307 310
308 callback.Run(FILE_ERROR_OK, ScopedHandle(mojo::Handle(mojo_handle)).Pass()); 311 callback.Run(FILE_ERROR_OK, ScopedHandle(mojo::Handle(mojo_handle)).Pass());
309 } 312 }
310 313
311 } // namespace filesystem 314 } // namespace filesystem
OLDNEW
« no previous file with comments | « components/filesystem/file_impl.h ('k') | components/filesystem/file_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698