OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_ |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/file.h" |
9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "webkit/browser/blob/file_stream_reader.h" | 12 #include "webkit/browser/blob/file_stream_reader.h" |
12 #include "webkit/browser/fileapi/file_system_url.h" | 13 #include "webkit/browser/fileapi/file_system_url.h" |
13 #include "webkit/browser/webkit_storage_browser_export.h" | 14 #include "webkit/browser/webkit_storage_browser_export.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class FilePath; | 17 class FilePath; |
17 struct PlatformFileInfo; | |
18 } | 18 } |
19 | 19 |
20 namespace fileapi { | 20 namespace fileapi { |
21 class FileSystemContext; | 21 class FileSystemContext; |
22 } | 22 } |
23 | 23 |
24 class MTPFileStreamReader | 24 class MTPFileStreamReader |
25 : public NON_EXPORTED_BASE(webkit_blob::FileStreamReader) { | 25 : public NON_EXPORTED_BASE(webkit_blob::FileStreamReader) { |
26 public: | 26 public: |
27 MTPFileStreamReader(fileapi::FileSystemContext* file_system_context, | 27 MTPFileStreamReader(fileapi::FileSystemContext* file_system_context, |
28 const fileapi::FileSystemURL& url, | 28 const fileapi::FileSystemURL& url, |
29 int64 initial_offset, | 29 int64 initial_offset, |
30 const base::Time& expected_modification_time); | 30 const base::Time& expected_modification_time); |
31 | 31 |
32 virtual ~MTPFileStreamReader(); | 32 virtual ~MTPFileStreamReader(); |
33 | 33 |
34 // FileStreamReader overrides. | 34 // FileStreamReader overrides. |
35 virtual int Read(net::IOBuffer* buf, int buf_len, | 35 virtual int Read(net::IOBuffer* buf, int buf_len, |
36 const net::CompletionCallback& callback) OVERRIDE; | 36 const net::CompletionCallback& callback) OVERRIDE; |
37 virtual int64 GetLength( | 37 virtual int64 GetLength( |
38 const net::Int64CompletionCallback& callback) OVERRIDE; | 38 const net::Int64CompletionCallback& callback) OVERRIDE; |
39 | 39 |
40 private: | 40 private: |
41 void OnFileInfoForRead(net::IOBuffer* buf, int buf_len, | 41 void OnFileInfoForRead(net::IOBuffer* buf, int buf_len, |
42 const net::CompletionCallback& callback, | 42 const net::CompletionCallback& callback, |
43 const base::PlatformFileInfo& file_info); | 43 const base::File::Info& file_info); |
44 | 44 |
45 void FinishRead(const net::CompletionCallback& callback, | 45 void FinishRead(const net::CompletionCallback& callback, |
46 int bytes_read); | 46 int bytes_read); |
47 | 47 |
48 void FinishGetLength(const net::Int64CompletionCallback& callback, | 48 void FinishGetLength(const net::Int64CompletionCallback& callback, |
49 const base::PlatformFileInfo& file_info); | 49 const base::File::Info& file_info); |
50 | 50 |
51 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 51 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
52 fileapi::FileSystemURL url_; | 52 fileapi::FileSystemURL url_; |
53 int64 current_offset_; | 53 int64 current_offset_; |
54 const base::Time expected_modification_time_; | 54 const base::Time expected_modification_time_; |
55 base::WeakPtrFactory<MTPFileStreamReader> weak_factory_; | 55 base::WeakPtrFactory<MTPFileStreamReader> weak_factory_; |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(MTPFileStreamReader); | 57 DISALLOW_COPY_AND_ASSIGN(MTPFileStreamReader); |
58 }; | 58 }; |
59 | 59 |
60 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_ | 60 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_ |
OLD | NEW |