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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste m.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste m.h"
6 6
7 #include <sys/statvfs.h> 7 #include <sys/statvfs.h>
8 8
9 #include "base/posix/eintr_wrapper.h" 9 #include "base/posix/eintr_wrapper.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 profile_id, *operation_id, type, 146 profile_id, *operation_id, type,
147 source_url, destination_url, size)); 147 source_url, destination_url, size));
148 } 148 }
149 149
150 // Notifies the copy completion to extensions via event router. 150 // Notifies the copy completion to extensions via event router.
151 void NotifyCopyCompletion( 151 void NotifyCopyCompletion(
152 void* profile_id, 152 void* profile_id,
153 fileapi::FileSystemOperationRunner::OperationID operation_id, 153 fileapi::FileSystemOperationRunner::OperationID operation_id,
154 const FileSystemURL& source_url, 154 const FileSystemURL& source_url,
155 const FileSystemURL& destination_url, 155 const FileSystemURL& destination_url,
156 base::PlatformFileError error) { 156 base::File::Error error) {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 158
159 file_manager::EventRouter* event_router = 159 file_manager::EventRouter* event_router =
160 GetEventRouterByProfileId(profile_id); 160 GetEventRouterByProfileId(profile_id);
161 if (event_router) 161 if (event_router)
162 event_router->OnCopyCompleted( 162 event_router->OnCopyCompleted(
163 operation_id, 163 operation_id,
164 source_url.ToGURL(), destination_url.ToGURL(), error); 164 source_url.ToGURL(), destination_url.ToGURL(), error);
165 } 165 }
166 166
167 // Callback invoked upon completion of Copy() (regardless of succeeded or 167 // Callback invoked upon completion of Copy() (regardless of succeeded or
168 // failed). 168 // failed).
169 void OnCopyCompleted( 169 void OnCopyCompleted(
170 void* profile_id, 170 void* profile_id,
171 fileapi::FileSystemOperationRunner::OperationID* operation_id, 171 fileapi::FileSystemOperationRunner::OperationID* operation_id,
172 const FileSystemURL& source_url, 172 const FileSystemURL& source_url,
173 const FileSystemURL& destination_url, 173 const FileSystemURL& destination_url,
174 base::PlatformFileError error) { 174 base::File::Error error) {
175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
176 176
177 BrowserThread::PostTask( 177 BrowserThread::PostTask(
178 BrowserThread::UI, FROM_HERE, 178 BrowserThread::UI, FROM_HERE,
179 base::Bind(&NotifyCopyCompletion, 179 base::Bind(&NotifyCopyCompletion,
180 profile_id, *operation_id, 180 profile_id, *operation_id,
181 source_url, destination_url, error)); 181 source_url, destination_url, error));
182 } 182 }
183 183
184 // Starts the copy operation via FileSystemOperationRunner. 184 // Starts the copy operation via FileSystemOperationRunner.
(...skipping 13 matching lines...) Expand all
198 source_url, destination_url, 198 source_url, destination_url,
199 fileapi::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED, 199 fileapi::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED,
200 base::Bind(&OnCopyProgress, 200 base::Bind(&OnCopyProgress,
201 profile_id, base::Unretained(operation_id)), 201 profile_id, base::Unretained(operation_id)),
202 base::Bind(&OnCopyCompleted, 202 base::Bind(&OnCopyCompleted,
203 profile_id, base::Owned(operation_id), 203 profile_id, base::Owned(operation_id),
204 source_url, destination_url)); 204 source_url, destination_url));
205 return *operation_id; 205 return *operation_id;
206 } 206 }
207 207
208 void OnCopyCancelled(base::PlatformFileError error) { 208 void OnCopyCancelled(base::File::Error error) {
209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
210 210
211 // We just ignore the status if the copy is actually cancelled or not, 211 // We just ignore the status if the copy is actually cancelled or not,
212 // because failing cancellation means the operation is not running now. 212 // because failing cancellation means the operation is not running now.
213 DLOG_IF(WARNING, error != base::PLATFORM_FILE_OK) 213 DLOG_IF(WARNING, error != base::File::FILE_OK)
214 << "Failed to cancel copy: " << error; 214 << "Failed to cancel copy: " << error;
215 } 215 }
216 216
217 // Cancels the running copy operation identified by |operation_id|. 217 // Cancels the running copy operation identified by |operation_id|.
218 void CancelCopyOnIOThread( 218 void CancelCopyOnIOThread(
219 scoped_refptr<fileapi::FileSystemContext> file_system_context, 219 scoped_refptr<fileapi::FileSystemContext> file_system_context,
220 fileapi::FileSystemOperationRunner::OperationID operation_id) { 220 fileapi::FileSystemOperationRunner::OperationID operation_id) {
221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
222 222
223 file_system_context->operation_runner()->Cancel( 223 file_system_context->operation_runner()->Cancel(
224 operation_id, base::Bind(&OnCopyCancelled)); 224 operation_id, base::Bind(&OnCopyCancelled));
225 } 225 }
226 226
227 } // namespace 227 } // namespace
228 228
229 void FileBrowserPrivateRequestFileSystemFunction::DidFail( 229 void FileBrowserPrivateRequestFileSystemFunction::DidFail(
230 base::PlatformFileError error_code) { 230 base::File::Error error_code) {
231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
232 232
233 error_ = base::StringPrintf("File error %d", static_cast<int>(error_code)); 233 error_ = base::StringPrintf("File error %d", static_cast<int>(error_code));
234 SendResponse(false); 234 SendResponse(false);
235 } 235 }
236 236
237 bool FileBrowserPrivateRequestFileSystemFunction:: 237 bool FileBrowserPrivateRequestFileSystemFunction::
238 SetupFileSystemAccessPermissions( 238 SetupFileSystemAccessPermissions(
239 scoped_refptr<fileapi::FileSystemContext> file_system_context, 239 scoped_refptr<fileapi::FileSystemContext> file_system_context,
240 int child_id, 240 int child_id,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 scoped_refptr<fileapi::FileSystemContext> file_system_context = 287 scoped_refptr<fileapi::FileSystemContext> file_system_context =
288 file_manager::util::GetFileSystemContextForRenderViewHost( 288 file_manager::util::GetFileSystemContextForRenderViewHost(
289 GetProfile(), render_view_host()); 289 GetProfile(), render_view_host());
290 290
291 // Set up file permission access. 291 // Set up file permission access.
292 const int child_id = render_view_host()->GetProcess()->GetID(); 292 const int child_id = render_view_host()->GetProcess()->GetID();
293 if (!SetupFileSystemAccessPermissions(file_system_context, 293 if (!SetupFileSystemAccessPermissions(file_system_context,
294 child_id, 294 child_id,
295 GetExtension())) { 295 GetExtension())) {
296 DidFail(base::PLATFORM_FILE_ERROR_SECURITY); 296 DidFail(base::File::FILE_ERROR_SECURITY);
297 return false; 297 return false;
298 } 298 }
299 299
300 // Set permissions for the Drive mount point immediately when we kick of 300 // Set permissions for the Drive mount point immediately when we kick of
301 // first instance of file manager. The actual mount event will be sent to 301 // first instance of file manager. The actual mount event will be sent to
302 // UI only when we perform proper authentication. 302 // UI only when we perform proper authentication.
303 // 303 //
304 // Note that we call this function even when Drive is disabled by the 304 // Note that we call this function even when Drive is disabled by the
305 // setting. Otherwise, we need to call this when the setting is changed at 305 // setting. Otherwise, we need to call this when the setting is changed at
306 // a later time, which complicates the code. 306 // a later time, which complicates the code.
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 // We don't much take care about the result of cancellation. 573 // We don't much take care about the result of cancellation.
574 BrowserThread::PostTask( 574 BrowserThread::PostTask(
575 BrowserThread::IO, 575 BrowserThread::IO,
576 FROM_HERE, 576 FROM_HERE,
577 base::Bind(&CancelCopyOnIOThread, file_system_context, params->copy_id)); 577 base::Bind(&CancelCopyOnIOThread, file_system_context, params->copy_id));
578 SendResponse(true); 578 SendResponse(true);
579 return true; 579 return true;
580 } 580 }
581 581
582 } // namespace extensions 582 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698