| 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_BROWSER_FILEAPI_FILE_SYSTEM_FILE_STREAM_READER_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_STREAM_READER_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_STREAM_READER_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_STREAM_READER_H_ |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "webkit/browser/blob/file_stream_reader.h" | 12 #include "webkit/browser/blob/file_stream_reader.h" |
| 13 #include "webkit/browser/fileapi/file_system_url.h" | 13 #include "webkit/browser/fileapi/file_system_url.h" |
| 14 #include "webkit/browser/webkit_storage_browser_export.h" | 14 #include "webkit/browser/webkit_storage_browser_export.h" |
| 15 #include "webkit/common/blob/shareable_file_reference.h" | 15 #include "webkit/common/blob/shareable_file_reference.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class FilePath; | 18 class FilePath; |
| 19 class SequencedTaskRunner; | 19 class SequencedTaskRunner; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace content { |
| 23 class FileSystemFileStreamReaderTest; |
| 24 } |
| 25 |
| 22 namespace fileapi { | 26 namespace fileapi { |
| 23 | 27 |
| 24 class FileSystemContext; | 28 class FileSystemContext; |
| 25 | 29 |
| 26 // Generic FileStreamReader implementation for FileSystem files. | 30 // Generic FileStreamReader implementation for FileSystem files. |
| 27 // Note: This generic implementation would work for any filesystems but | 31 // Note: This generic implementation would work for any filesystems but |
| 28 // remote filesystem should implement its own reader rather than relying | 32 // remote filesystem should implement its own reader rather than relying |
| 29 // on FileSystemOperation::GetSnapshotFile() which may force downloading | 33 // on FileSystemOperation::GetSnapshotFile() which may force downloading |
| 30 // the entire contents for remote files. | 34 // the entire contents for remote files. |
| 31 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemFileStreamReader | 35 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemFileStreamReader |
| 32 : public NON_EXPORTED_BASE(webkit_blob::FileStreamReader) { | 36 : public NON_EXPORTED_BASE(webkit_blob::FileStreamReader) { |
| 33 public: | 37 public: |
| 34 virtual ~FileSystemFileStreamReader(); | 38 virtual ~FileSystemFileStreamReader(); |
| 35 | 39 |
| 36 // FileStreamReader overrides. | 40 // FileStreamReader overrides. |
| 37 virtual int Read(net::IOBuffer* buf, int buf_len, | 41 virtual int Read(net::IOBuffer* buf, int buf_len, |
| 38 const net::CompletionCallback& callback) OVERRIDE; | 42 const net::CompletionCallback& callback) OVERRIDE; |
| 39 virtual int64 GetLength( | 43 virtual int64 GetLength( |
| 40 const net::Int64CompletionCallback& callback) OVERRIDE; | 44 const net::Int64CompletionCallback& callback) OVERRIDE; |
| 41 | 45 |
| 42 private: | 46 private: |
| 43 friend class webkit_blob::FileStreamReader; | 47 friend class webkit_blob::FileStreamReader; |
| 44 friend class FileSystemFileStreamReaderTest; | 48 friend class content::FileSystemFileStreamReaderTest; |
| 45 | 49 |
| 46 FileSystemFileStreamReader(FileSystemContext* file_system_context, | 50 FileSystemFileStreamReader(FileSystemContext* file_system_context, |
| 47 const FileSystemURL& url, | 51 const FileSystemURL& url, |
| 48 int64 initial_offset, | 52 int64 initial_offset, |
| 49 const base::Time& expected_modification_time); | 53 const base::Time& expected_modification_time); |
| 50 | 54 |
| 51 int CreateSnapshot(const base::Closure& callback, | 55 int CreateSnapshot(const base::Closure& callback, |
| 52 const net::CompletionCallback& error_callback); | 56 const net::CompletionCallback& error_callback); |
| 53 void DidCreateSnapshot( | 57 void DidCreateSnapshot( |
| 54 const base::Closure& callback, | 58 const base::Closure& callback, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 66 scoped_refptr<webkit_blob::ShareableFileReference> snapshot_ref_; | 70 scoped_refptr<webkit_blob::ShareableFileReference> snapshot_ref_; |
| 67 bool has_pending_create_snapshot_; | 71 bool has_pending_create_snapshot_; |
| 68 base::WeakPtrFactory<FileSystemFileStreamReader> weak_factory_; | 72 base::WeakPtrFactory<FileSystemFileStreamReader> weak_factory_; |
| 69 | 73 |
| 70 DISALLOW_COPY_AND_ASSIGN(FileSystemFileStreamReader); | 74 DISALLOW_COPY_AND_ASSIGN(FileSystemFileStreamReader); |
| 71 }; | 75 }; |
| 72 | 76 |
| 73 } // namespace fileapi | 77 } // namespace fileapi |
| 74 | 78 |
| 75 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_STREAM_READER_H_ | 79 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_STREAM_READER_H_ |
| OLD | NEW |