| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DRIVE_FILE_STREAM_READER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 class DriveEntryProto; | 109 class DriveEntryProto; |
| 110 | 110 |
| 111 // The stream reader for a file in DriveFileSystem. Instances of this class | 111 // The stream reader for a file in DriveFileSystem. Instances of this class |
| 112 // should live on IO thread. | 112 // should live on IO thread. |
| 113 class DriveFileStreamReader { | 113 class DriveFileStreamReader { |
| 114 public: | 114 public: |
| 115 // Callback to return the DriveFileSystemInterface instance. This is an | 115 // Callback to return the DriveFileSystemInterface instance. This is an |
| 116 // injecting point for testing. | 116 // injecting point for testing. |
| 117 // Note that the callback will be copied between threads (IO and UI), and | 117 // Note that the callback will be copied between threads (IO and UI), and |
| 118 // will be called on UI thread. | 118 // will be called on UI thread. |
| 119 typedef base::Callback<DriveFileSystemInterface*()> DriveFileSystemGetter; | 119 typedef base::Callback<DriveFileSystemInterface*()> FileSystemGetter; |
| 120 | 120 |
| 121 // Callback to return the result of Initialize(). | 121 // Callback to return the result of Initialize(). |
| 122 typedef base::Callback<void(FileError error, | 122 typedef base::Callback<void(FileError error, |
| 123 scoped_ptr<DriveEntryProto> entry)> | 123 scoped_ptr<DriveEntryProto> entry)> |
| 124 InitializeCompletionCallback; | 124 InitializeCompletionCallback; |
| 125 | 125 |
| 126 explicit DriveFileStreamReader( | 126 explicit DriveFileStreamReader( |
| 127 const DriveFileSystemGetter& drive_file_system_getter); | 127 const FileSystemGetter& file_system_getter); |
| 128 ~DriveFileStreamReader(); | 128 ~DriveFileStreamReader(); |
| 129 | 129 |
| 130 // Returns true if the reader is initialized. | 130 // Returns true if the reader is initialized. |
| 131 bool IsInitialized() const; | 131 bool IsInitialized() const; |
| 132 | 132 |
| 133 // Initializes the stream for the |drive_file_path|. | 133 // Initializes the stream for the |drive_file_path|. |
| 134 // |callback| must not be null. | 134 // |callback| must not be null. |
| 135 // TODO(hidehiko): Support reading range (crbug.com/168258). | 135 // TODO(hidehiko): Support reading range (crbug.com/168258). |
| 136 void Initialize(const base::FilePath& drive_file_path, | 136 void Initialize(const base::FilePath& drive_file_path, |
| 137 const InitializeCompletionCallback& callback); | 137 const InitializeCompletionCallback& callback); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 167 | 167 |
| 168 // Called when the data is received from the server. | 168 // Called when the data is received from the server. |
| 169 void OnGetContent(google_apis::GDataErrorCode error_code, | 169 void OnGetContent(google_apis::GDataErrorCode error_code, |
| 170 scoped_ptr<std::string> data); | 170 scoped_ptr<std::string> data); |
| 171 | 171 |
| 172 // Called when GetFileContentByPath is completed. | 172 // Called when GetFileContentByPath is completed. |
| 173 void OnGetFileContentByPathCompletion( | 173 void OnGetFileContentByPathCompletion( |
| 174 const InitializeCompletionCallback& callback, | 174 const InitializeCompletionCallback& callback, |
| 175 FileError error); | 175 FileError error); |
| 176 | 176 |
| 177 const DriveFileSystemGetter drive_file_system_getter_; | 177 const FileSystemGetter file_system_getter_; |
| 178 scoped_ptr<internal::ReaderProxy> reader_proxy_; | 178 scoped_ptr<internal::ReaderProxy> reader_proxy_; |
| 179 | 179 |
| 180 // This should remain the last member so it'll be destroyed first and | 180 // This should remain the last member so it'll be destroyed first and |
| 181 // invalidate its weak pointers before other members are destroyed. | 181 // invalidate its weak pointers before other members are destroyed. |
| 182 base::WeakPtrFactory<DriveFileStreamReader> weak_ptr_factory_; | 182 base::WeakPtrFactory<DriveFileStreamReader> weak_ptr_factory_; |
| 183 DISALLOW_COPY_AND_ASSIGN(DriveFileStreamReader); | 183 DISALLOW_COPY_AND_ASSIGN(DriveFileStreamReader); |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 // TODO(hidehiko): Add thin wrapper class inheriting | 186 // TODO(hidehiko): Add thin wrapper class inheriting |
| 187 // webkit_blob::FileStreamReader for the DriveFileStreamReader. | 187 // webkit_blob::FileStreamReader for the DriveFileStreamReader. |
| 188 | 188 |
| 189 } // namespace drive | 189 } // namespace drive |
| 190 | 190 |
| 191 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ | 191 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ |
| OLD | NEW |