| 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_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_READER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_READER_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_READER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_READER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "chrome/browser/chromeos/drive/drive_file_stream_reader.h" | 17 #include "chrome/browser/chromeos/drive/drive_file_stream_reader.h" |
| 17 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
| 18 #include "storage/browser/fileapi/file_stream_reader.h" | 19 #include "storage/browser/fileapi/file_stream_reader.h" |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
| 22 } // namespace base | 23 } // namespace base |
| 23 | 24 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 45 // storage::FileStreamReader override. | 46 // storage::FileStreamReader override. |
| 46 int Read(net::IOBuffer* buffer, | 47 int Read(net::IOBuffer* buffer, |
| 47 int buffer_length, | 48 int buffer_length, |
| 48 const net::CompletionCallback& callback) override; | 49 const net::CompletionCallback& callback) override; |
| 49 int64_t GetLength(const net::Int64CompletionCallback& callback) override; | 50 int64_t GetLength(const net::Int64CompletionCallback& callback) override; |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 // Called upon the initialization completion of |stream_reader_|. | 53 // Called upon the initialization completion of |stream_reader_|. |
| 53 // Processes the result of the initialization with checking last | 54 // Processes the result of the initialization with checking last |
| 54 // modified time, and calls |callback| with net::Error code as its result. | 55 // modified time, and calls |callback| with net::Error code as its result. |
| 55 void OnStreamReaderInitialized( | 56 void OnStreamReaderInitialized(const net::CompletionCallback& callback, |
| 56 const net::CompletionCallback& callback, | 57 int error, |
| 57 int error, | 58 std::unique_ptr<ResourceEntry> entry); |
| 58 scoped_ptr<ResourceEntry> entry); | |
| 59 | 59 |
| 60 // Part of Read(). Called after all the initialization process is completed. | 60 // Part of Read(). Called after all the initialization process is completed. |
| 61 void ReadAfterStreamReaderInitialized( | 61 void ReadAfterStreamReaderInitialized( |
| 62 scoped_refptr<net::IOBuffer> buffer, | 62 scoped_refptr<net::IOBuffer> buffer, |
| 63 int buffer_length, | 63 int buffer_length, |
| 64 const net::CompletionCallback& callback, | 64 const net::CompletionCallback& callback, |
| 65 int initialization_result); | 65 int initialization_result); |
| 66 | 66 |
| 67 // Part of GetLength(). Called after all the initialization process is | 67 // Part of GetLength(). Called after all the initialization process is |
| 68 // completed. | 68 // completed. |
| 69 void GetLengthAfterStreamReaderInitialized( | 69 void GetLengthAfterStreamReaderInitialized( |
| 70 const net::Int64CompletionCallback& callback, | 70 const net::Int64CompletionCallback& callback, |
| 71 int initialization_result); | 71 int initialization_result); |
| 72 | 72 |
| 73 scoped_ptr<DriveFileStreamReader> stream_reader_; | 73 std::unique_ptr<DriveFileStreamReader> stream_reader_; |
| 74 const base::FilePath drive_file_path_; | 74 const base::FilePath drive_file_path_; |
| 75 const int64_t offset_; | 75 const int64_t offset_; |
| 76 const base::Time expected_modification_time_; | 76 const base::Time expected_modification_time_; |
| 77 | 77 |
| 78 // This is available only after initialize is done. | 78 // This is available only after initialize is done. |
| 79 int64_t file_size_; | 79 int64_t file_size_; |
| 80 | 80 |
| 81 // This should remain the last member so it'll be destroyed first and | 81 // This should remain the last member so it'll be destroyed first and |
| 82 // invalidate its weak pointers before other members are destroyed. | 82 // invalidate its weak pointers before other members are destroyed. |
| 83 base::WeakPtrFactory<WebkitFileStreamReaderImpl> weak_ptr_factory_; | 83 base::WeakPtrFactory<WebkitFileStreamReaderImpl> weak_ptr_factory_; |
| 84 DISALLOW_COPY_AND_ASSIGN(WebkitFileStreamReaderImpl); | 84 DISALLOW_COPY_AND_ASSIGN(WebkitFileStreamReaderImpl); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } // namespace internal | 87 } // namespace internal |
| 88 } // namespace drive | 88 } // namespace drive |
| 89 | 89 |
| 90 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_READER_IMPL_
H_ | 90 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_READER_IMPL_
H_ |
| OLD | NEW |