Delete unused downloads page asset.
[chromium-blink-merge.git] / storage / browser / fileapi / file_system_file_stream_reader.h
blob41c0157723edd6517f298a092672b0ad9940d61b
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.
5 #ifndef STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_FILE_STREAM_READER_H_
6 #define STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_FILE_STREAM_READER_H_
8 #include "base/bind.h"
9 #include "base/files/file.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/time/time.h"
12 #include "storage/browser/blob/shareable_file_reference.h"
13 #include "storage/browser/fileapi/file_stream_reader.h"
14 #include "storage/browser/fileapi/file_system_url.h"
15 #include "storage/browser/storage_browser_export.h"
17 namespace base {
18 class FilePath;
19 class SequencedTaskRunner;
22 namespace content {
23 class FileSystemFileStreamReaderTest;
26 namespace storage {
28 class FileSystemContext;
30 // Generic FileStreamReader implementation for FileSystem files.
31 // Note: This generic implementation would work for any filesystems but
32 // remote filesystem should implement its own reader rather than relying
33 // on FileSystemOperation::GetSnapshotFile() which may force downloading
34 // the entire contents for remote files.
35 class STORAGE_EXPORT_PRIVATE FileSystemFileStreamReader
36 : public NON_EXPORTED_BASE(storage::FileStreamReader) {
37 public:
38 ~FileSystemFileStreamReader() override;
40 // FileStreamReader overrides.
41 int Read(net::IOBuffer* buf,
42 int buf_len,
43 const net::CompletionCallback& callback) override;
44 int64 GetLength(const net::Int64CompletionCallback& callback) override;
46 private:
47 friend class storage::FileStreamReader;
48 friend class content::FileSystemFileStreamReaderTest;
50 FileSystemFileStreamReader(FileSystemContext* file_system_context,
51 const FileSystemURL& url,
52 int64 initial_offset,
53 const base::Time& expected_modification_time);
55 int CreateSnapshot(const base::Closure& callback,
56 const net::CompletionCallback& error_callback);
57 void DidCreateSnapshot(
58 const base::Closure& callback,
59 const net::CompletionCallback& error_callback,
60 base::File::Error file_error,
61 const base::File::Info& file_info,
62 const base::FilePath& platform_path,
63 const scoped_refptr<storage::ShareableFileReference>& file_ref);
65 scoped_refptr<FileSystemContext> file_system_context_;
66 FileSystemURL url_;
67 const int64 initial_offset_;
68 const base::Time expected_modification_time_;
69 scoped_ptr<storage::FileStreamReader> local_file_reader_;
70 scoped_refptr<storage::ShareableFileReference> snapshot_ref_;
71 bool has_pending_create_snapshot_;
72 base::WeakPtrFactory<FileSystemFileStreamReader> weak_factory_;
74 DISALLOW_COPY_AND_ASSIGN(FileSystemFileStreamReader);
77 } // namespace storage
79 #endif // STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_FILE_STREAM_READER_H_