OLD | NEW |
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 "chrome/browser/chromeos/drive/local_file_reader.h" | 5 #include "chrome/browser/chromeos/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" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 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(base::File::FROM_BEGIN, offset, | 55 int rv = file_stream_.Seek( |
56 Bind(&LocalFileReader::DidSeek, | 56 offset, Bind(&LocalFileReader::DidSeek, weak_ptr_factory_.GetWeakPtr(), |
57 weak_ptr_factory_.GetWeakPtr(), | 57 callback, offset)); |
58 callback, offset)); | |
59 DCHECK_EQ(rv, net::ERR_IO_PENDING); | 58 DCHECK_EQ(rv, net::ERR_IO_PENDING); |
60 } | 59 } |
61 | 60 |
62 void LocalFileReader::DidSeek(const net::CompletionCallback& callback, | 61 void LocalFileReader::DidSeek(const net::CompletionCallback& callback, |
63 int64 offset, | 62 int64 offset, |
64 int64 error) { | 63 int64 error) { |
65 callback.Run(error == offset ? net::OK : net::ERR_FAILED); | 64 callback.Run(error == offset ? net::OK : net::ERR_FAILED); |
66 } | 65 } |
67 | 66 |
68 } // namespace util | 67 } // namespace util |
69 } // namespace drive | 68 } // namespace drive |
OLD | NEW |