OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/files/file.h" | 11 #include "base/files/file.h" |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "storage/browser/fileapi/async_file_util.h" | 13 #include "storage/browser/fileapi/async_file_util.h" |
12 #include "storage/browser/fileapi/watcher_manager.h" | 14 #include "storage/browser/fileapi/watcher_manager.h" |
13 #include "url/gurl.h" | 15 #include "url/gurl.h" |
14 | 16 |
15 namespace base { | 17 namespace base { |
16 class FilePath; | 18 class FilePath; |
17 } | 19 } |
(...skipping 29 matching lines...) Expand all Loading... |
47 typedef base::Callback< | 49 typedef base::Callback< |
48 void(const base::File::Info& file_info, | 50 void(const base::File::Info& file_info, |
49 const base::FilePath& local_path)> CreateSnapshotFileSuccessCallback; | 51 const base::FilePath& local_path)> CreateSnapshotFileSuccessCallback; |
50 | 52 |
51 // A callback to be called when ReadBytes method call succeeds. | 53 // A callback to be called when ReadBytes method call succeeds. |
52 typedef base::Callback< | 54 typedef base::Callback< |
53 void(const base::File::Info& file_info, | 55 void(const base::File::Info& file_info, |
54 int bytes_read)> ReadBytesSuccessCallback; | 56 int bytes_read)> ReadBytesSuccessCallback; |
55 | 57 |
56 struct ReadBytesRequest { | 58 struct ReadBytesRequest { |
57 ReadBytesRequest(uint32 file_id, | 59 ReadBytesRequest(uint32_t file_id, |
58 net::IOBuffer* buf, int64 offset, int buf_len, | 60 net::IOBuffer* buf, |
| 61 int64_t offset, |
| 62 int buf_len, |
59 const ReadBytesSuccessCallback& success_callback, | 63 const ReadBytesSuccessCallback& success_callback, |
60 const ErrorCallback& error_callback); | 64 const ErrorCallback& error_callback); |
61 ~ReadBytesRequest(); | 65 ~ReadBytesRequest(); |
62 | 66 |
63 uint32 file_id; | 67 uint32_t file_id; |
64 scoped_refptr<net::IOBuffer> buf; | 68 scoped_refptr<net::IOBuffer> buf; |
65 int64 offset; | 69 int64_t offset; |
66 int buf_len; | 70 int buf_len; |
67 ReadBytesSuccessCallback success_callback; | 71 ReadBytesSuccessCallback success_callback; |
68 ErrorCallback error_callback; | 72 ErrorCallback error_callback; |
69 }; | 73 }; |
70 | 74 |
71 // A callback to be called to create a temporary file. Path to the temporary | 75 // A callback to be called to create a temporary file. Path to the temporary |
72 // file is returned as base::FilePath. The caller is responsible to manage | 76 // file is returned as base::FilePath. The caller is responsible to manage |
73 // life time of the temporary file. | 77 // life time of the temporary file. |
74 typedef base::Callback<base::FilePath()> CreateTemporaryFileCallback; | 78 typedef base::Callback<base::FilePath()> CreateTemporaryFileCallback; |
75 | 79 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 130 |
127 // Platform-specific implementations that are streaming don't create a local | 131 // Platform-specific implementations that are streaming don't create a local |
128 // snapshot file. Blobs are instead FileSystemURL backed and read in a stream. | 132 // snapshot file. Blobs are instead FileSystemURL backed and read in a stream. |
129 virtual bool IsStreaming() = 0; | 133 virtual bool IsStreaming() = 0; |
130 | 134 |
131 // Reads up to |buf_len| bytes from |device_file_path| into |buf|. Invokes the | 135 // Reads up to |buf_len| bytes from |device_file_path| into |buf|. Invokes the |
132 // appropriate callback asynchronously when complete. Only valid when | 136 // appropriate callback asynchronously when complete. Only valid when |
133 // IsStreaming() is true. | 137 // IsStreaming() is true. |
134 virtual void ReadBytes(const base::FilePath& device_file_path, | 138 virtual void ReadBytes(const base::FilePath& device_file_path, |
135 const scoped_refptr<net::IOBuffer>& buf, | 139 const scoped_refptr<net::IOBuffer>& buf, |
136 int64 offset, | 140 int64_t offset, |
137 int buf_len, | 141 int buf_len, |
138 const ReadBytesSuccessCallback& success_callback, | 142 const ReadBytesSuccessCallback& success_callback, |
139 const ErrorCallback& error_callback) = 0; | 143 const ErrorCallback& error_callback) = 0; |
140 | 144 |
141 // Returns true if storage is opened for read only. | 145 // Returns true if storage is opened for read only. |
142 virtual bool IsReadOnly() const = 0; | 146 virtual bool IsReadOnly() const = 0; |
143 | 147 |
144 // Copies a file |source_file_path| to |device_file_path|. | 148 // Copies a file |source_file_path| to |device_file_path|. |
145 // |create_temporary_file_callback| can be used to create a temporary file. | 149 // |create_temporary_file_callback| can be used to create a temporary file. |
146 virtual void CopyFileLocal( | 150 virtual void CopyFileLocal( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 215 |
212 typedef base::Callback<void(MTPDeviceAsyncDelegate*)> | 216 typedef base::Callback<void(MTPDeviceAsyncDelegate*)> |
213 CreateMTPDeviceAsyncDelegateCallback; | 217 CreateMTPDeviceAsyncDelegateCallback; |
214 | 218 |
215 void CreateMTPDeviceAsyncDelegate( | 219 void CreateMTPDeviceAsyncDelegate( |
216 const base::FilePath::StringType& device_location, | 220 const base::FilePath::StringType& device_location, |
217 const bool read_only, | 221 const bool read_only, |
218 const CreateMTPDeviceAsyncDelegateCallback& callback); | 222 const CreateMTPDeviceAsyncDelegateCallback& callback); |
219 | 223 |
220 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ | 224 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ |
OLD | NEW |