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

Unified Diff: webkit/blob/local_file_reader.h

Issue 10038019: Add FileReader interface and implement FileSystemFileReader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/blob/file_reader.h ('k') | webkit/blob/local_file_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/blob/local_file_reader.h
diff --git a/webkit/blob/local_file_reader.h b/webkit/blob/local_file_reader.h
index 2b2c67e01196284b43dda99fb05f8fdcdc8b42c9..23abe7b2653a9ae92dc8f91db970334337fe22d3 100644
--- a/webkit/blob/local_file_reader.h
+++ b/webkit/blob/local_file_reader.h
@@ -9,29 +9,28 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/file_path.h"
+#include "base/platform_file.h"
#include "base/memory/weak_ptr.h"
#include "base/time.h"
-#include "net/base/completion_callback.h"
#include "webkit/blob/blob_export.h"
+#include "webkit/blob/file_reader.h"
namespace base {
class MessageLoopProxy;
}
-namespace net {
-class FileStream;
-class IOBuffer;
-}
-
namespace webkit_blob {
// A thin wrapper of net::FileStream with range support for sliced file
// handling.
-class BLOB_EXPORT LocalFileReader {
+class BLOB_EXPORT LocalFileReader : public FileReader {
public:
typedef base::Callback<void(int error, scoped_ptr<net::FileStream> stream)>
OpenFileStreamCallback;
+ // A convenient method to translate platform file error to net error code.
+ static int PlatformFileErrorToNetError(base::PlatformFileError file_error);
+
// Creates a new FileReader for a local file |file_path|.
// |initial_offset| specifies the offset in the file where the first read
// should start. If the given offset is out of the file range any
@@ -42,22 +41,20 @@ class BLOB_EXPORT LocalFileReader {
// actual modification time to see if the file has been modified, and if
// it does any succeeding read operations should fail with
// ERR_UPLOAD_FILE_CHANGED error.
+ // TODO(kinuko): Consider using SequencedWorkerPool.
LocalFileReader(base::MessageLoopProxy* file_thread_proxy,
const FilePath& file_path,
int64 initial_offset,
const base::Time& expected_modification_time);
+ virtual ~LocalFileReader();
- ~LocalFileReader();
-
- // Reads from the current cursor position asynchronously.
- // This works mostly same as how net::FileStream::Read() works except that
- // it internally opens (and seeks) the file if it is not opened yet.
- // It is invalid to call Read while there is an in-flight Read operation.
- int Read(net::IOBuffer* buf, int buf_len,
- const net::CompletionCallback& callback);
+ // FileReader overrides.
+ virtual int Read(net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback) OVERRIDE;
- // Returns the number of bytes available to read from the beginning of
- // the file (or initial_offset) until the end of the file (rv >= 0 cases).
+ // Returns the length of the file if it could successfully retrieve the
+ // file info *and* its last modification time equals to
+ // expected_modification_time_ (rv >= 0 cases).
// Otherwise, a negative error code is returned (rv < 0 cases).
int GetLength(const net::Int64CompletionCallback& callback);
« no previous file with comments | « webkit/blob/file_reader.h ('k') | webkit/blob/local_file_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698