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 "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 const CreateSnapshotFileSuccessCallback& success_callback, | 85 const CreateSnapshotFileSuccessCallback& success_callback, |
86 const ErrorCallback& error_callback) = 0; | 86 const ErrorCallback& error_callback) = 0; |
87 | 87 |
88 // Platform-specific implementations that are streaming don't create a local | 88 // Platform-specific implementations that are streaming don't create a local |
89 // snapshot file. Blobs are instead FileSystemURL backed and read in a stream. | 89 // snapshot file. Blobs are instead FileSystemURL backed and read in a stream. |
90 virtual bool IsStreaming() = 0; | 90 virtual bool IsStreaming() = 0; |
91 | 91 |
92 // Reads up to |buf_len| bytes from |device_file_path| into |buf|. Invokes the | 92 // Reads up to |buf_len| bytes from |device_file_path| into |buf|. Invokes the |
93 // appropriate callback asynchronously when complete. Only valid when | 93 // appropriate callback asynchronously when complete. Only valid when |
94 // IsStreaming() is true. | 94 // IsStreaming() is true. |
95 virtual void ReadBytes( | 95 virtual void ReadBytes(const base::FilePath& device_file_path, |
96 const base::FilePath& device_file_path, | 96 const scoped_refptr<net::IOBuffer>& buf, |
97 net::IOBuffer* buf, int64 offset, int buf_len, | 97 int64 offset, |
98 const ReadBytesSuccessCallback& success_callback, | 98 int buf_len, |
99 const ErrorCallback& error_callback) = 0; | 99 const ReadBytesSuccessCallback& success_callback, |
| 100 const ErrorCallback& error_callback) = 0; |
100 | 101 |
101 // Called when the | 102 // Called when the |
102 // (1) Browser application is in shutdown mode (or) | 103 // (1) Browser application is in shutdown mode (or) |
103 // (2) Last extension using this MTP device is destroyed (or) | 104 // (2) Last extension using this MTP device is destroyed (or) |
104 // (3) Attached MTP device is removed (or) | 105 // (3) Attached MTP device is removed (or) |
105 // (4) User revoked the MTP device gallery permission. | 106 // (4) User revoked the MTP device gallery permission. |
106 // Ownership of |MTPDeviceAsyncDelegate| is handed off to the delegate | 107 // Ownership of |MTPDeviceAsyncDelegate| is handed off to the delegate |
107 // implementation class by this call. This function should take care of | 108 // implementation class by this call. This function should take care of |
108 // cancelling all the pending tasks before deleting itself. | 109 // cancelling all the pending tasks before deleting itself. |
109 virtual void CancelPendingTasksAndDeleteDelegate() = 0; | 110 virtual void CancelPendingTasksAndDeleteDelegate() = 0; |
110 | 111 |
111 protected: | 112 protected: |
112 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). | 113 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). |
113 virtual ~MTPDeviceAsyncDelegate() {} | 114 virtual ~MTPDeviceAsyncDelegate() {} |
114 }; | 115 }; |
115 | 116 |
116 typedef base::Callback<void(MTPDeviceAsyncDelegate*)> | 117 typedef base::Callback<void(MTPDeviceAsyncDelegate*)> |
117 CreateMTPDeviceAsyncDelegateCallback; | 118 CreateMTPDeviceAsyncDelegateCallback; |
118 | 119 |
119 void CreateMTPDeviceAsyncDelegate( | 120 void CreateMTPDeviceAsyncDelegate( |
120 const base::FilePath::StringType& device_location, | 121 const base::FilePath::StringType& device_location, |
121 const CreateMTPDeviceAsyncDelegateCallback& callback); | 122 const CreateMTPDeviceAsyncDelegateCallback& callback); |
122 | 123 |
123 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ | 124 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ |
OLD | NEW |