| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 ~ReadBytesRequest(); | 56 ~ReadBytesRequest(); |
| 57 | 57 |
| 58 uint32 file_id; | 58 uint32 file_id; |
| 59 scoped_refptr<net::IOBuffer> buf; | 59 scoped_refptr<net::IOBuffer> buf; |
| 60 int64 offset; | 60 int64 offset; |
| 61 int buf_len; | 61 int buf_len; |
| 62 ReadBytesSuccessCallback success_callback; | 62 ReadBytesSuccessCallback success_callback; |
| 63 ErrorCallback error_callback; | 63 ErrorCallback error_callback; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 // A callback to be called when CopyFileFromLocal method call succeeds. |
| 67 typedef base::Closure CopyFileFromLocalSuccessCallback; |
| 68 |
| 66 // Gets information about the given |file_path| and invokes the appropriate | 69 // Gets information about the given |file_path| and invokes the appropriate |
| 67 // callback asynchronously when complete. | 70 // callback asynchronously when complete. |
| 68 virtual void GetFileInfo( | 71 virtual void GetFileInfo( |
| 69 const base::FilePath& file_path, | 72 const base::FilePath& file_path, |
| 70 const GetFileInfoSuccessCallback& success_callback, | 73 const GetFileInfoSuccessCallback& success_callback, |
| 71 const ErrorCallback& error_callback) = 0; | 74 const ErrorCallback& error_callback) = 0; |
| 72 | 75 |
| 73 // Enumerates the |root| directory contents and invokes the appropriate | 76 // Enumerates the |root| directory contents and invokes the appropriate |
| 74 // callback asynchronously when complete. | 77 // callback asynchronously when complete. |
| 75 virtual void ReadDirectory( | 78 virtual void ReadDirectory( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 92 // Reads up to |buf_len| bytes from |device_file_path| into |buf|. Invokes the | 95 // Reads up to |buf_len| bytes from |device_file_path| into |buf|. Invokes the |
| 93 // appropriate callback asynchronously when complete. Only valid when | 96 // appropriate callback asynchronously when complete. Only valid when |
| 94 // IsStreaming() is true. | 97 // IsStreaming() is true. |
| 95 virtual void ReadBytes(const base::FilePath& device_file_path, | 98 virtual void ReadBytes(const base::FilePath& device_file_path, |
| 96 const scoped_refptr<net::IOBuffer>& buf, | 99 const scoped_refptr<net::IOBuffer>& buf, |
| 97 int64 offset, | 100 int64 offset, |
| 98 int buf_len, | 101 int buf_len, |
| 99 const ReadBytesSuccessCallback& success_callback, | 102 const ReadBytesSuccessCallback& success_callback, |
| 100 const ErrorCallback& error_callback) = 0; | 103 const ErrorCallback& error_callback) = 0; |
| 101 | 104 |
| 105 // Returns true if storage is opened for read only. |
| 106 virtual bool IsReadOnly() = 0; |
| 107 |
| 108 // Copies a file from |source_file_path| to |device_file_path|. |
| 109 virtual void CopyFileFromLocal( |
| 110 const base::FilePath& source_file_path, |
| 111 const base::FilePath& device_file_path, |
| 112 const CopyFileFromLocalSuccessCallback& success_callback, |
| 113 const ErrorCallback& error_callback) = 0; |
| 114 |
| 102 // Called when the | 115 // Called when the |
| 103 // (1) Browser application is in shutdown mode (or) | 116 // (1) Browser application is in shutdown mode (or) |
| 104 // (2) Last extension using this MTP device is destroyed (or) | 117 // (2) Last extension using this MTP device is destroyed (or) |
| 105 // (3) Attached MTP device is removed (or) | 118 // (3) Attached MTP device is removed (or) |
| 106 // (4) User revoked the MTP device gallery permission. | 119 // (4) User revoked the MTP device gallery permission. |
| 107 // Ownership of |MTPDeviceAsyncDelegate| is handed off to the delegate | 120 // Ownership of |MTPDeviceAsyncDelegate| is handed off to the delegate |
| 108 // implementation class by this call. This function should take care of | 121 // implementation class by this call. This function should take care of |
| 109 // cancelling all the pending tasks before deleting itself. | 122 // cancelling all the pending tasks before deleting itself. |
| 110 virtual void CancelPendingTasksAndDeleteDelegate() = 0; | 123 virtual void CancelPendingTasksAndDeleteDelegate() = 0; |
| 111 | 124 |
| 112 protected: | 125 protected: |
| 113 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). | 126 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). |
| 114 virtual ~MTPDeviceAsyncDelegate() {} | 127 virtual ~MTPDeviceAsyncDelegate() {} |
| 115 }; | 128 }; |
| 116 | 129 |
| 117 typedef base::Callback<void(MTPDeviceAsyncDelegate*)> | 130 typedef base::Callback<void(MTPDeviceAsyncDelegate*)> |
| 118 CreateMTPDeviceAsyncDelegateCallback; | 131 CreateMTPDeviceAsyncDelegateCallback; |
| 119 | 132 |
| 120 void CreateMTPDeviceAsyncDelegate( | 133 void CreateMTPDeviceAsyncDelegate( |
| 121 const base::FilePath::StringType& device_location, | 134 const base::FilePath::StringType& device_location, |
| 135 const bool read_only, |
| 122 const CreateMTPDeviceAsyncDelegateCallback& callback); | 136 const CreateMTPDeviceAsyncDelegateCallback& callback); |
| 123 | 137 |
| 124 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ | 138 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ |
| OLD | NEW |