OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef WEBKIT_BLOB_LOCAL_FILE_READER_H_ | 5 #ifndef WEBKIT_BLOB_LOCAL_FILE_READER_H_ |
6 #define WEBKIT_BLOB_LOCAL_FILE_READER_H_ | 6 #define WEBKIT_BLOB_LOCAL_FILE_READER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // Reads from the current cursor position asynchronously. | 50 // Reads from the current cursor position asynchronously. |
51 // This works mostly same as how net::FileStream::Read() works except that | 51 // This works mostly same as how net::FileStream::Read() works except that |
52 // it internally opens (and seeks) the file if it is not opened yet. | 52 // it internally opens (and seeks) the file if it is not opened yet. |
53 // It is invalid to call Read while there is an in-flight Read operation. | 53 // It is invalid to call Read while there is an in-flight Read operation. |
54 int Read(net::IOBuffer* buf, int buf_len, | 54 int Read(net::IOBuffer* buf, int buf_len, |
55 const net::CompletionCallback& callback); | 55 const net::CompletionCallback& callback); |
56 | 56 |
57 // Returns the number of bytes available to read from the beginning of | 57 // Returns the number of bytes available to read from the beginning of |
58 // the file (or initial_offset) until the end of the file (rv >= 0 cases). | 58 // the file (or initial_offset) until the end of the file (rv >= 0 cases). |
59 // Otherwise, a negative error code is returned (rv < 0 cases). | 59 // Otherwise, a negative error code is returned (rv < 0 cases). |
60 int GetLength(const net::CompletionCallback& callback); | 60 int GetLength(const net::Int64CompletionCallback& callback); |
61 | 61 |
62 private: | 62 private: |
63 class OpenFileStreamHelper; | 63 class OpenFileStreamHelper; |
64 | 64 |
65 int Open(const OpenFileStreamCallback& callback); | 65 int Open(const OpenFileStreamCallback& callback); |
66 void DidOpen(net::IOBuffer* buf, | 66 void DidOpen(net::IOBuffer* buf, |
67 int buf_len, | 67 int buf_len, |
68 const net::CompletionCallback& callback, | 68 const net::CompletionCallback& callback, |
69 int open_error, | 69 int open_error, |
70 scoped_ptr<net::FileStream> stream); | 70 scoped_ptr<net::FileStream> stream); |
71 | 71 |
72 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; | 72 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; |
73 scoped_ptr<net::FileStream> stream_impl_; | 73 scoped_ptr<net::FileStream> stream_impl_; |
74 const FilePath file_path_; | 74 const FilePath file_path_; |
75 const int64 initial_offset_; | 75 const int64 initial_offset_; |
76 const base::Time expected_modification_time_; | 76 const base::Time expected_modification_time_; |
77 bool has_pending_open_; | 77 bool has_pending_open_; |
78 base::WeakPtrFactory<LocalFileReader> weak_factory_; | 78 base::WeakPtrFactory<LocalFileReader> weak_factory_; |
79 }; | 79 }; |
80 | 80 |
81 } // namespace webkit_blob | 81 } // namespace webkit_blob |
82 | 82 |
83 #endif // WEBKIT_BLOB_LOCAL_FILE_READER_H_ | 83 #endif // WEBKIT_BLOB_LOCAL_FILE_READER_H_ |
OLD | NEW |