| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_ | |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/bind.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/platform_file.h" | |
| 12 #include "googleurl/src/gurl.h" | |
| 13 #include "webkit/blob/file_reader.h" | |
| 14 | |
| 15 class FilePath; | |
| 16 | |
| 17 namespace base { | |
| 18 class SequencedTaskRunner; | |
| 19 } | |
| 20 | |
| 21 namespace webkit_blob { | |
| 22 class LocalFileReader; | |
| 23 class ShareableFileReference; | |
| 24 } | |
| 25 | |
| 26 namespace fileapi { | |
| 27 | |
| 28 class FileSystemContext; | |
| 29 | |
| 30 // TODO(kinaba,satorux): This generic implementation would work for any | |
| 31 // filesystems but remote filesystem should implement its own reader | |
| 32 // rather than relying on FileSystemOperation::GetSnapshotFile() which | |
| 33 // may force downloading the entire contents for remote files. | |
| 34 class FileSystemFileReader : public webkit_blob::FileReader { | |
| 35 public: | |
| 36 // Creates a new FileReader for a filesystem URL |url| form |initial_offset|. | |
| 37 FileSystemFileReader(FileSystemContext* file_system_context, | |
| 38 const GURL& url, | |
| 39 int64 initial_offset); | |
| 40 virtual ~FileSystemFileReader(); | |
| 41 | |
| 42 // FileReader override. | |
| 43 virtual int Read(net::IOBuffer* buf, int buf_len, | |
| 44 const net::CompletionCallback& callback) OVERRIDE; | |
| 45 | |
| 46 private: | |
| 47 void DidCreateSnapshot( | |
| 48 const base::Closure& read_closure, | |
| 49 const net::CompletionCallback& callback, | |
| 50 base::PlatformFileError file_error, | |
| 51 const base::PlatformFileInfo& file_info, | |
| 52 const FilePath& platform_path, | |
| 53 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); | |
| 54 | |
| 55 scoped_refptr<FileSystemContext> file_system_context_; | |
| 56 const GURL url_; | |
| 57 const int64 initial_offset_; | |
| 58 scoped_ptr<webkit_blob::LocalFileReader> local_file_reader_; | |
| 59 scoped_refptr<webkit_blob::ShareableFileReference> snapshot_ref_; | |
| 60 bool has_pending_create_snapshot_; | |
| 61 base::WeakPtrFactory<FileSystemFileReader> weak_factory_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(FileSystemFileReader); | |
| 64 }; | |
| 65 | |
| 66 } // namespace fileapi | |
| 67 | |
| 68 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_READER_H_ | |
| OLD | NEW |