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

Side by Side Diff: components/drive/local_file_reader.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/drive/local_file_reader.h ('k') | components/drive/local_file_reader_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/drive/local_file_reader.h" 5 #include "components/drive/local_file_reader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/sequenced_task_runner.h" 9 #include "base/sequenced_task_runner.h"
10 #include "net/base/completion_callback.h" 10 #include "net/base/completion_callback.h"
11 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 13
14 namespace drive { 14 namespace drive {
15 namespace util { 15 namespace util {
16 16
17 LocalFileReader::LocalFileReader( 17 LocalFileReader::LocalFileReader(
18 base::SequencedTaskRunner* sequenced_task_runner) 18 base::SequencedTaskRunner* sequenced_task_runner)
19 : file_stream_(sequenced_task_runner), 19 : file_stream_(sequenced_task_runner),
20 weak_ptr_factory_(this) { 20 weak_ptr_factory_(this) {
21 } 21 }
22 22
23 LocalFileReader::~LocalFileReader() { 23 LocalFileReader::~LocalFileReader() {
24 } 24 }
25 25
26 void LocalFileReader::Open(const base::FilePath& file_path, 26 void LocalFileReader::Open(const base::FilePath& file_path,
27 int64 offset, 27 int64_t offset,
28 const net::CompletionCallback& callback) { 28 const net::CompletionCallback& callback) {
29 DCHECK(!callback.is_null()); 29 DCHECK(!callback.is_null());
30 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | 30 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ |
31 base::File::FLAG_ASYNC; 31 base::File::FLAG_ASYNC;
32 32
33 int rv = file_stream_.Open(file_path, flags, 33 int rv = file_stream_.Open(file_path, flags,
34 Bind(&LocalFileReader::DidOpen, 34 Bind(&LocalFileReader::DidOpen,
35 weak_ptr_factory_.GetWeakPtr(), 35 weak_ptr_factory_.GetWeakPtr(),
36 callback, offset)); 36 callback, offset));
37 DCHECK_EQ(rv, net::ERR_IO_PENDING); 37 DCHECK_EQ(rv, net::ERR_IO_PENDING);
38 } 38 }
39 39
40 void LocalFileReader::Read(net::IOBuffer* in_buffer, 40 void LocalFileReader::Read(net::IOBuffer* in_buffer,
41 int buffer_length, 41 int buffer_length,
42 const net::CompletionCallback& callback) { 42 const net::CompletionCallback& callback) {
43 DCHECK(!callback.is_null()); 43 DCHECK(!callback.is_null());
44 DCHECK(file_stream_.IsOpen()); 44 DCHECK(file_stream_.IsOpen());
45 int rv = file_stream_.Read(in_buffer, buffer_length, callback); 45 int rv = file_stream_.Read(in_buffer, buffer_length, callback);
46 DCHECK_EQ(rv, net::ERR_IO_PENDING); 46 DCHECK_EQ(rv, net::ERR_IO_PENDING);
47 } 47 }
48 48
49 void LocalFileReader::DidOpen(const net::CompletionCallback& callback, 49 void LocalFileReader::DidOpen(const net::CompletionCallback& callback,
50 int64 offset, 50 int64_t offset,
51 int error) { 51 int error) {
52 if (error != net::OK) 52 if (error != net::OK)
53 return callback.Run(error); 53 return callback.Run(error);
54 54
55 int rv = file_stream_.Seek( 55 int rv = file_stream_.Seek(
56 offset, Bind(&LocalFileReader::DidSeek, weak_ptr_factory_.GetWeakPtr(), 56 offset, Bind(&LocalFileReader::DidSeek, weak_ptr_factory_.GetWeakPtr(),
57 callback, offset)); 57 callback, offset));
58 DCHECK_EQ(rv, net::ERR_IO_PENDING); 58 DCHECK_EQ(rv, net::ERR_IO_PENDING);
59 } 59 }
60 60
61 void LocalFileReader::DidSeek(const net::CompletionCallback& callback, 61 void LocalFileReader::DidSeek(const net::CompletionCallback& callback,
62 int64 offset, 62 int64_t offset,
63 int64 error) { 63 int64_t error) {
64 callback.Run(error == offset ? net::OK : net::ERR_FAILED); 64 callback.Run(error == offset ? net::OK : net::ERR_FAILED);
65 } 65 }
66 66
67 } // namespace util 67 } // namespace util
68 } // namespace drive 68 } // namespace drive
OLDNEW
« no previous file with comments | « components/drive/local_file_reader.h ('k') | components/drive/local_file_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698