1 // Copyright 2014 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 CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_
9 #include "base/files/file.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "webkit/browser/blob/file_stream_reader.h"
13 #include "webkit/browser/fileapi/file_system_url.h"
14 #include "webkit/browser/webkit_storage_browser_export.h"
21 class FileSystemContext;
24 class MTPFileStreamReader
25 : public NON_EXPORTED_BASE(webkit_blob::FileStreamReader) {
27 MTPFileStreamReader(fileapi::FileSystemContext* file_system_context,
28 const fileapi::FileSystemURL& url,
30 const base::Time& expected_modification_time,
31 bool do_media_header_validation);
33 virtual ~MTPFileStreamReader();
35 // FileStreamReader overrides.
36 virtual int Read(net::IOBuffer* buf, int buf_len,
37 const net::CompletionCallback& callback) OVERRIDE;
38 virtual int64 GetLength(
39 const net::Int64CompletionCallback& callback) OVERRIDE;
42 void FinishValidateMediaHeader(
43 net::IOBuffer* header_buf,
44 net::IOBuffer* buf, int buf_len,
45 const net::CompletionCallback& callback,
46 const base::File::Info& file_info,
47 int header_bytes_read);
49 void FinishRead(const net::CompletionCallback& callback,
50 const base::File::Info& file_info, int bytes_read);
52 void FinishGetLength(const net::Int64CompletionCallback& callback,
53 const base::File::Info& file_info);
55 scoped_refptr<fileapi::FileSystemContext> file_system_context_;
56 fileapi::FileSystemURL url_;
57 int64 current_offset_;
58 const base::Time expected_modification_time_;
60 bool media_header_validated_;
62 base::WeakPtrFactory<MTPFileStreamReader> weak_factory_;
64 DISALLOW_COPY_AND_ASSIGN(MTPFileStreamReader);
67 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_