| 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 <stdint.h> |
| 9 |
| 8 #include "base/bind.h" | 10 #include "base/bind.h" |
| 9 #include "base/files/file.h" | 11 #include "base/files/file.h" |
| 12 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 12 #include "storage/browser/fileapi/file_stream_reader.h" | 15 #include "storage/browser/fileapi/file_stream_reader.h" |
| 13 #include "storage/browser/fileapi/file_system_url.h" | 16 #include "storage/browser/fileapi/file_system_url.h" |
| 14 #include "storage/browser/storage_browser_export.h" | 17 #include "storage/browser/storage_browser_export.h" |
| 15 | 18 |
| 16 namespace base { | 19 namespace base { |
| 17 class FilePath; | 20 class FilePath; |
| 18 } | 21 } |
| 19 | 22 |
| 20 namespace storage { | 23 namespace storage { |
| 21 class FileSystemContext; | 24 class FileSystemContext; |
| 22 } | 25 } |
| 23 | 26 |
| 24 class MTPFileStreamReader | 27 class MTPFileStreamReader |
| 25 : public NON_EXPORTED_BASE(storage::FileStreamReader) { | 28 : public NON_EXPORTED_BASE(storage::FileStreamReader) { |
| 26 public: | 29 public: |
| 27 MTPFileStreamReader(storage::FileSystemContext* file_system_context, | 30 MTPFileStreamReader(storage::FileSystemContext* file_system_context, |
| 28 const storage::FileSystemURL& url, | 31 const storage::FileSystemURL& url, |
| 29 int64 initial_offset, | 32 int64_t initial_offset, |
| 30 const base::Time& expected_modification_time, | 33 const base::Time& expected_modification_time, |
| 31 bool do_media_header_validation); | 34 bool do_media_header_validation); |
| 32 | 35 |
| 33 ~MTPFileStreamReader() override; | 36 ~MTPFileStreamReader() override; |
| 34 | 37 |
| 35 // FileStreamReader overrides. | 38 // FileStreamReader overrides. |
| 36 int Read(net::IOBuffer* buf, | 39 int Read(net::IOBuffer* buf, |
| 37 int buf_len, | 40 int buf_len, |
| 38 const net::CompletionCallback& callback) override; | 41 const net::CompletionCallback& callback) override; |
| 39 int64 GetLength(const net::Int64CompletionCallback& callback) override; | 42 int64_t GetLength(const net::Int64CompletionCallback& callback) override; |
| 40 | 43 |
| 41 private: | 44 private: |
| 42 void FinishValidateMediaHeader( | 45 void FinishValidateMediaHeader( |
| 43 net::IOBuffer* header_buf, | 46 net::IOBuffer* header_buf, |
| 44 net::IOBuffer* buf, int buf_len, | 47 net::IOBuffer* buf, int buf_len, |
| 45 const net::CompletionCallback& callback, | 48 const net::CompletionCallback& callback, |
| 46 const base::File::Info& file_info, | 49 const base::File::Info& file_info, |
| 47 int header_bytes_read); | 50 int header_bytes_read); |
| 48 | 51 |
| 49 void FinishRead(const net::CompletionCallback& callback, | 52 void FinishRead(const net::CompletionCallback& callback, |
| 50 const base::File::Info& file_info, int bytes_read); | 53 const base::File::Info& file_info, int bytes_read); |
| 51 | 54 |
| 52 void FinishGetLength(const net::Int64CompletionCallback& callback, | 55 void FinishGetLength(const net::Int64CompletionCallback& callback, |
| 53 const base::File::Info& file_info); | 56 const base::File::Info& file_info); |
| 54 | 57 |
| 55 scoped_refptr<storage::FileSystemContext> file_system_context_; | 58 scoped_refptr<storage::FileSystemContext> file_system_context_; |
| 56 storage::FileSystemURL url_; | 59 storage::FileSystemURL url_; |
| 57 int64 current_offset_; | 60 int64_t current_offset_; |
| 58 const base::Time expected_modification_time_; | 61 const base::Time expected_modification_time_; |
| 59 | 62 |
| 60 bool media_header_validated_; | 63 bool media_header_validated_; |
| 61 | 64 |
| 62 base::WeakPtrFactory<MTPFileStreamReader> weak_factory_; | 65 base::WeakPtrFactory<MTPFileStreamReader> weak_factory_; |
| 63 | 66 |
| 64 DISALLOW_COPY_AND_ASSIGN(MTPFileStreamReader); | 67 DISALLOW_COPY_AND_ASSIGN(MTPFileStreamReader); |
| 65 }; | 68 }; |
| 66 | 69 |
| 67 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_ | 70 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_FILE_STREAM_READER_H_ |
| OLD | NEW |