Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.h

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_
7 7
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // If the device is uninitialized, store the |task_info| in a pending task 81 // If the device is uninitialized, store the |task_info| in a pending task
82 // list and runs all the pending tasks once the device is successfully 82 // list and runs all the pending tasks once the device is successfully
83 // initialized. 83 // initialized.
84 void EnsureInitAndRunTask(const PendingTaskInfo& task_info); 84 void EnsureInitAndRunTask(const PendingTaskInfo& task_info);
85 85
86 // Writes data from the device to the snapshot file path based on the 86 // Writes data from the device to the snapshot file path based on the
87 // parameters in |current_snapshot_request_info_| by doing a call-and-reply to 87 // parameters in |current_snapshot_request_info_| by doing a call-and-reply to
88 // the UI thread. 88 // the UI thread.
89 // 89 //
90 // |snapshot_file_info| specifies the metadata details of the snapshot file. 90 // |snapshot_file_info| specifies the metadata details of the snapshot file.
91 void WriteDataIntoSnapshotFile( 91 void WriteDataIntoSnapshotFile(const base::File::Info& snapshot_file_info);
92 const base::PlatformFileInfo& snapshot_file_info);
93 92
94 // Processes the next pending request. 93 // Processes the next pending request.
95 void ProcessNextPendingRequest(); 94 void ProcessNextPendingRequest();
96 95
97 // Handles the device initialization event. |succeeded| indicates whether 96 // Handles the device initialization event. |succeeded| indicates whether
98 // device initialization succeeded. 97 // device initialization succeeded.
99 // 98 //
100 // If the device is successfully initialized, runs the next pending task. 99 // If the device is successfully initialized, runs the next pending task.
101 void OnInitCompleted(bool succeeded); 100 void OnInitCompleted(bool succeeded);
102 101
103 // Called when GetFileInfo() succeeds. |file_info| specifies the 102 // Called when GetFileInfo() succeeds. |file_info| specifies the
104 // requested file details. |success_callback| is invoked to notify the caller 103 // requested file details. |success_callback| is invoked to notify the caller
105 // about the requested file details. 104 // about the requested file details.
106 void OnDidGetFileInfo(const GetFileInfoSuccessCallback& success_callback, 105 void OnDidGetFileInfo(const GetFileInfoSuccessCallback& success_callback,
107 const base::PlatformFileInfo& file_info); 106 const base::File::Info& file_info);
108 107
109 // Called when GetFileInfo() succeeds. GetFileInfo() is invoked to 108 // Called when GetFileInfo() succeeds. GetFileInfo() is invoked to
110 // get the |root| directory metadata details. |file_info| specifies the |root| 109 // get the |root| directory metadata details. |file_info| specifies the |root|
111 // directory details. 110 // directory details.
112 // 111 //
113 // If |root| is a directory, post a task on the UI thread to read the |root| 112 // If |root| is a directory, post a task on the UI thread to read the |root|
114 // directory file entries. 113 // directory file entries.
115 // 114 //
116 // If |root| is not a directory, |error_callback| is invoked to notify the 115 // If |root| is not a directory, |error_callback| is invoked to notify the
117 // caller about the platform file error and process the next pending request. 116 // caller about the platform file error and process the next pending request.
118 void OnDidGetFileInfoToReadDirectory( 117 void OnDidGetFileInfoToReadDirectory(
119 const std::string& root, 118 const std::string& root,
120 const ReadDirectorySuccessCallback& success_callback, 119 const ReadDirectorySuccessCallback& success_callback,
121 const ErrorCallback& error_callback, 120 const ErrorCallback& error_callback,
122 const base::PlatformFileInfo& file_info); 121 const base::File::Info& file_info);
123 122
124 // Called when GetFileInfo() succeeds. GetFileInfo() is invoked to 123 // Called when GetFileInfo() succeeds. GetFileInfo() is invoked to
125 // create the snapshot file of |snapshot_request_info.device_file_path|. 124 // create the snapshot file of |snapshot_request_info.device_file_path|.
126 // |file_info| specifies the device file metadata details. 125 // |file_info| specifies the device file metadata details.
127 // 126 //
128 // Posts a task on the UI thread to copy the data contents of the device file 127 // Posts a task on the UI thread to copy the data contents of the device file
129 // to the snapshot file. 128 // to the snapshot file.
130 void OnDidGetFileInfoToCreateSnapshotFile( 129 void OnDidGetFileInfoToCreateSnapshotFile(
131 scoped_ptr<SnapshotRequestInfo> snapshot_request_info, 130 scoped_ptr<SnapshotRequestInfo> snapshot_request_info,
132 const base::PlatformFileInfo& file_info); 131 const base::File::Info& file_info);
133 132
134 // Called when ReadDirectory() succeeds. 133 // Called when ReadDirectory() succeeds.
135 // 134 //
136 // |file_list| contains the directory file entries. 135 // |file_list| contains the directory file entries.
137 // |success_callback| is invoked to notify the caller about the directory 136 // |success_callback| is invoked to notify the caller about the directory
138 // file entries. 137 // file entries.
139 void OnDidReadDirectory(const ReadDirectorySuccessCallback& success_callback, 138 void OnDidReadDirectory(const ReadDirectorySuccessCallback& success_callback,
140 const fileapi::AsyncFileUtil::EntryList& file_list); 139 const fileapi::AsyncFileUtil::EntryList& file_list);
141 140
142 // Called when WriteDataIntoSnapshotFile() succeeds. 141 // Called when WriteDataIntoSnapshotFile() succeeds.
143 // 142 //
144 // |snapshot_file_info| specifies the snapshot file metadata details. 143 // |snapshot_file_info| specifies the snapshot file metadata details.
145 // 144 //
146 // |current_snapshot_request_info_.success_callback| is invoked to notify the 145 // |current_snapshot_request_info_.success_callback| is invoked to notify the
147 // caller about |snapshot_file_info|. 146 // caller about |snapshot_file_info|.
148 void OnDidWriteDataIntoSnapshotFile( 147 void OnDidWriteDataIntoSnapshotFile(
149 const base::PlatformFileInfo& snapshot_file_info, 148 const base::File::Info& snapshot_file_info,
150 const base::FilePath& snapshot_file_path); 149 const base::FilePath& snapshot_file_path);
151 150
152 // Called when WriteDataIntoSnapshotFile() fails. 151 // Called when WriteDataIntoSnapshotFile() fails.
153 // 152 //
154 // |error| specifies the platform file error code. 153 // |error| specifies the platform file error code.
155 // 154 //
156 // |current_snapshot_request_info_.error_callback| is invoked to notify the 155 // |current_snapshot_request_info_.error_callback| is invoked to notify the
157 // caller about |error|. 156 // caller about |error|.
158 void OnWriteDataIntoSnapshotFileError(base::PlatformFileError error); 157 void OnWriteDataIntoSnapshotFileError(base::File::Error error);
159 158
160 // Handles the device file |error|. |error_callback| is invoked to notify the 159 // Handles the device file |error|. |error_callback| is invoked to notify the
161 // caller about the file error. 160 // caller about the file error.
162 void HandleDeviceFileError(const ErrorCallback& error_callback, 161 void HandleDeviceFileError(const ErrorCallback& error_callback,
163 base::PlatformFileError error); 162 base::File::Error error);
164 163
165 // MTP device initialization state. 164 // MTP device initialization state.
166 InitializationState init_state_; 165 InitializationState init_state_;
167 166
168 // Used to make sure only one task is in progress at any time. 167 // Used to make sure only one task is in progress at any time.
169 bool task_in_progress_; 168 bool task_in_progress_;
170 169
171 // Registered file system device path. This path does not 170 // Registered file system device path. This path does not
172 // correspond to a real device path (e.g. "/usb:2,2:81282"). 171 // correspond to a real device path (e.g. "/usb:2,2:81282").
173 const base::FilePath device_path_; 172 const base::FilePath device_path_;
(...skipping 12 matching lines...) Expand all
186 // request at any time. 185 // request at any time.
187 scoped_ptr<SnapshotRequestInfo> current_snapshot_request_info_; 186 scoped_ptr<SnapshotRequestInfo> current_snapshot_request_info_;
188 187
189 // For callbacks that may run after destruction. 188 // For callbacks that may run after destruction.
190 base::WeakPtrFactory<MTPDeviceDelegateImplLinux> weak_ptr_factory_; 189 base::WeakPtrFactory<MTPDeviceDelegateImplLinux> weak_ptr_factory_;
191 190
192 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); 191 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux);
193 }; 192 };
194 193
195 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H _ 194 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698