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

Side by Side Diff: services/files/file_impl.cc

Issue 1397133002: Remove callers of mojo::Array<size_t> constructor in favor of ::New (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 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 | « services/files/directory_impl.cc ('k') | services/js/system/tests/js_to_cpp_tests.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 "services/files/file_impl.h" 5 #include "services/files/file_impl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // multithreaded.) Maybe we should do an |ftell()| and always use |pread()|. 91 // multithreaded.) Maybe we should do an |ftell()| and always use |pread()|.
92 // TODO(vtl): Possibly, at least sometimes we should not change the file 92 // TODO(vtl): Possibly, at least sometimes we should not change the file
93 // position. See TODO in file.mojom. 93 // position. See TODO in file.mojom.
94 if (lseek(file_fd_.get(), static_cast<off_t>(offset), 94 if (lseek(file_fd_.get(), static_cast<off_t>(offset),
95 WhenceToStandardWhence(whence)) < 0) { 95 WhenceToStandardWhence(whence)) < 0) {
96 callback.Run(ErrnoToError(errno), Array<uint8_t>()); 96 callback.Run(ErrnoToError(errno), Array<uint8_t>());
97 return; 97 return;
98 } 98 }
99 } 99 }
100 100
101 Array<uint8_t> bytes_read(num_bytes_to_read); 101 auto bytes_read = Array<uint8_t>::New(num_bytes_to_read);
102 ssize_t num_bytes_read = HANDLE_EINTR( 102 ssize_t num_bytes_read = HANDLE_EINTR(
103 read(file_fd_.get(), &bytes_read.front(), num_bytes_to_read)); 103 read(file_fd_.get(), &bytes_read.front(), num_bytes_to_read));
104 if (num_bytes_read < 0) { 104 if (num_bytes_read < 0) {
105 callback.Run(ErrnoToError(errno), Array<uint8_t>()); 105 callback.Run(ErrnoToError(errno), Array<uint8_t>());
106 return; 106 return;
107 } 107 }
108 108
109 DCHECK_LE(static_cast<size_t>(num_bytes_read), num_bytes_to_read); 109 DCHECK_LE(static_cast<size_t>(num_bytes_read), num_bytes_to_read);
110 bytes_read.resize(static_cast<size_t>(num_bytes_read)); 110 bytes_read.resize(static_cast<size_t>(num_bytes_read));
111 callback.Run(Error::OK, bytes_read.Pass()); 111 callback.Run(Error::OK, bytes_read.Pass());
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 return; 348 return;
349 } 349 }
350 350
351 // TODO(vtl): The "correct" error code should be one that can be translated to 351 // TODO(vtl): The "correct" error code should be one that can be translated to
352 // ENOTTY! 352 // ENOTTY!
353 callback.Run(Error::UNAVAILABLE, Array<uint32_t>()); 353 callback.Run(Error::UNAVAILABLE, Array<uint32_t>());
354 } 354 }
355 355
356 } // namespace files 356 } // namespace files
357 } // namespace mojo 357 } // namespace mojo
OLDNEW
« no previous file with comments | « services/files/directory_impl.cc ('k') | services/js/system/tests/js_to_cpp_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698