Index: chrome/browser/chromeos/drive/drive_file_stream_reader.h |
diff --git a/chrome/browser/chromeos/drive/drive_file_stream_reader.h b/chrome/browser/chromeos/drive/drive_file_stream_reader.h |
index 0f4df2c3e5f494b11a9418d3efba0412e491c186..ed9d7f3c7a2932cd206d4409da551be8a1c88aa6 100644 |
--- a/chrome/browser/chromeos/drive/drive_file_stream_reader.h |
+++ b/chrome/browser/chromeos/drive/drive_file_stream_reader.h |
@@ -5,11 +5,69 @@ |
#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ |
#define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ |
+#include <string> |
+ |
#include "base/basictypes.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "chrome/browser/chromeos/drive/drive_file_error.h" |
+#include "net/base/completion_callback.h" |
#include "webkit/blob/file_stream_reader.h" |
+namespace net { |
+class FileStream; |
+class IOBuffer; |
+} // namespace net |
+ |
namespace drive { |
+namespace internal { |
+ |
+// An interface to dispatch the reading operation. If the file is locally |
+// cached, LocalReaderProxy defined below will be used. Otherwise (i.e. the |
+// file is being downloaded from the server), NetworkReaderProxy will be used. |
+// Conceptually this is a part of implementation details for |
hashimoto
2013/04/16 08:38:29
nit: Is this sentence needed? The name of the name
hidehiko
2013/04/16 08:57:11
Ok. Removed.
|
+// DriveFileStreamReader but exposed under internal namespace for testing |
+// purpose. |
+class ReaderProxy { |
+ public: |
+ virtual ~ReaderProxy() {} |
+ |
+ // Called from DriveFileStreamReader::Read method. |
+ virtual int Read(net::IOBuffer* buffer, int buffer_length, |
+ const net::CompletionCallback& callback) = 0; |
+ |
+ // Called when the data from the server is received. |
+ virtual void OnGetContent(scoped_ptr<std::string> data) = 0; |
hashimoto
2013/04/16 08:38:29
Does this method need to be in this interface?
Onl
hidehiko
2013/04/16 08:57:11
Yes, this needs to be a part of this interface, ot
|
+ |
+ // Called when an error is found, during the network downloading. |
+ virtual void OnError(DriveFileError error) = 0; |
hashimoto
2013/04/16 08:38:29
ditto.
hidehiko
2013/04/16 08:57:11
Acknowledged.
|
+}; |
+ |
+// The read operation implementation for the locally cached files. |
+class LocalReaderProxy : public ReaderProxy { |
+ public: |
+ // The |file_stream| should be the instance which is already opened. |
+ // This class takes its ownership. |
+ explicit LocalReaderProxy(scoped_ptr<net::FileStream> file_stream); |
+ virtual ~LocalReaderProxy(); |
+ |
+ // ReaderProxy overrides. |
+ virtual int Read(net::IOBuffer* buffer, int buffer_length, |
+ const net::CompletionCallback& callback) OVERRIDE; |
+ virtual void OnGetContent(scoped_ptr<std::string> data) OVERRIDE; |
+ virtual void OnError(DriveFileError error) OVERRIDE; |
+ |
+ private: |
+ scoped_ptr<net::FileStream> file_stream_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(LocalReaderProxy); |
+}; |
+ |
+// TODO(hidehiko): implement the NetworkReaderProxy. |
+ |
+} // namespace internal |
+// TODO(hidehiko): Simplify the interface by getting rid of |
+// webkit_blob::FileStreamReader inheritance. |
class DriveFileStreamReader : public webkit_blob::FileStreamReader { |
public: |
DriveFileStreamReader(); |