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::Callback<void()> CopyFileFromLocalSuccessCallback; | |
Lei Zhang
2015/02/24 23:35:48
Isn't base::Callback<void()> just base::Closure, l
yawano
2015/02/26 07:27:54
Done.
| |
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 // Copies a file from |source_file_path| to |device_file_path|. | |
106 virtual void CopyFileFromLocal( | |
107 const base::FilePath& source_file_path, | |
108 const base::FilePath& device_file_path, | |
109 const CopyFileFromLocalSuccessCallback& success_callback, | |
110 const ErrorCallback& error_callback) = 0; | |
111 | |
102 // Called when the | 112 // Called when the |
103 // (1) Browser application is in shutdown mode (or) | 113 // (1) Browser application is in shutdown mode (or) |
104 // (2) Last extension using this MTP device is destroyed (or) | 114 // (2) Last extension using this MTP device is destroyed (or) |
105 // (3) Attached MTP device is removed (or) | 115 // (3) Attached MTP device is removed (or) |
106 // (4) User revoked the MTP device gallery permission. | 116 // (4) User revoked the MTP device gallery permission. |
107 // Ownership of |MTPDeviceAsyncDelegate| is handed off to the delegate | 117 // Ownership of |MTPDeviceAsyncDelegate| is handed off to the delegate |
108 // implementation class by this call. This function should take care of | 118 // implementation class by this call. This function should take care of |
109 // cancelling all the pending tasks before deleting itself. | 119 // cancelling all the pending tasks before deleting itself. |
110 virtual void CancelPendingTasksAndDeleteDelegate() = 0; | 120 virtual void CancelPendingTasksAndDeleteDelegate() = 0; |
111 | 121 |
112 protected: | 122 protected: |
113 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). | 123 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). |
114 virtual ~MTPDeviceAsyncDelegate() {} | 124 virtual ~MTPDeviceAsyncDelegate() {} |
115 }; | 125 }; |
116 | 126 |
117 typedef base::Callback<void(MTPDeviceAsyncDelegate*)> | 127 typedef base::Callback<void(MTPDeviceAsyncDelegate*)> |
118 CreateMTPDeviceAsyncDelegateCallback; | 128 CreateMTPDeviceAsyncDelegateCallback; |
119 | 129 |
120 void CreateMTPDeviceAsyncDelegate( | 130 void CreateMTPDeviceAsyncDelegate( |
121 const base::FilePath::StringType& device_location, | 131 const base::FilePath::StringType& device_location, |
122 const CreateMTPDeviceAsyncDelegateCallback& callback); | 132 const CreateMTPDeviceAsyncDelegateCallback& callback); |
123 | 133 |
124 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ | 134 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ |
OLD | NEW |