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

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

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 years, 7 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 for (size_t i = 0; i < profiles.size(); ++i) { 251 for (size_t i = 0; i < profiles.size(); ++i) {
252 if (!profiles[i]->IsOffTheRecord()) { 252 if (!profiles[i]->IsOffTheRecord()) {
253 file_manager::util::SetupProfileFileAccessPermissions(child_id, 253 file_manager::util::SetupProfileFileAccessPermissions(child_id,
254 profiles[i]); 254 profiles[i]);
255 } 255 }
256 } 256 }
257 257
258 return true; 258 return true;
259 } 259 }
260 260
261 bool FileBrowserPrivateRequestFileSystemFunction::RunImpl() { 261 bool FileBrowserPrivateRequestFileSystemFunction::RunAsync() {
262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
263 using extensions::api::file_browser_private::RequestFileSystem::Params; 263 using extensions::api::file_browser_private::RequestFileSystem::Params;
264 const scoped_ptr<Params> params(Params::Create(*args_)); 264 const scoped_ptr<Params> params(Params::Create(*args_));
265 EXTENSION_FUNCTION_VALIDATE(params); 265 EXTENSION_FUNCTION_VALIDATE(params);
266 266
267 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess()) 267 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess())
268 return false; 268 return false;
269 269
270 set_log_on_completion(true); 270 set_log_on_completion(true);
271 271
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 SendResponse(true); 333 SendResponse(true);
334 } 334 }
335 335
336 void FileWatchFunctionBase::Respond(bool success) { 336 void FileWatchFunctionBase::Respond(bool success) {
337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
338 338
339 SetResult(base::Value::CreateBooleanValue(success)); 339 SetResult(base::Value::CreateBooleanValue(success));
340 SendResponse(success); 340 SendResponse(success);
341 } 341 }
342 342
343 bool FileWatchFunctionBase::RunImpl() { 343 bool FileWatchFunctionBase::RunAsync() {
344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
345 345
346 if (!render_view_host() || !render_view_host()->GetProcess()) 346 if (!render_view_host() || !render_view_host()->GetProcess())
347 return false; 347 return false;
348 348
349 // First param is url of a file to watch. 349 // First param is url of a file to watch.
350 std::string url; 350 std::string url;
351 if (!args_->GetString(0, &url) || url.empty()) 351 if (!args_->GetString(0, &url) || url.empty())
352 return false; 352 return false;
353 353
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 const base::FilePath& unused, 387 const base::FilePath& unused,
388 const std::string& extension_id) { 388 const std::string& extension_id) {
389 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 389 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
390 390
391 file_manager::EventRouter* event_router = 391 file_manager::EventRouter* event_router =
392 file_manager::FileBrowserPrivateAPI::Get(GetProfile())->event_router(); 392 file_manager::FileBrowserPrivateAPI::Get(GetProfile())->event_router();
393 event_router->RemoveFileWatch(local_path, extension_id); 393 event_router->RemoveFileWatch(local_path, extension_id);
394 Respond(true); 394 Respond(true);
395 } 395 }
396 396
397 bool FileBrowserPrivateGetSizeStatsFunction::RunImpl() { 397 bool FileBrowserPrivateGetSizeStatsFunction::RunAsync() {
398 using extensions::api::file_browser_private::GetSizeStats::Params; 398 using extensions::api::file_browser_private::GetSizeStats::Params;
399 const scoped_ptr<Params> params(Params::Create(*args_)); 399 const scoped_ptr<Params> params(Params::Create(*args_));
400 EXTENSION_FUNCTION_VALIDATE(params); 400 EXTENSION_FUNCTION_VALIDATE(params);
401 401
402 using file_manager::VolumeManager; 402 using file_manager::VolumeManager;
403 using file_manager::VolumeInfo; 403 using file_manager::VolumeInfo;
404 VolumeManager* volume_manager = VolumeManager::Get(GetProfile()); 404 VolumeManager* volume_manager = VolumeManager::Get(GetProfile());
405 if (!volume_manager) 405 if (!volume_manager)
406 return false; 406 return false;
407 407
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 const uint64* remaining_size) { 462 const uint64* remaining_size) {
463 base::DictionaryValue* sizes = new base::DictionaryValue(); 463 base::DictionaryValue* sizes = new base::DictionaryValue();
464 SetResult(sizes); 464 SetResult(sizes);
465 465
466 sizes->SetDouble("totalSize", static_cast<double>(*total_size)); 466 sizes->SetDouble("totalSize", static_cast<double>(*total_size));
467 sizes->SetDouble("remainingSize", static_cast<double>(*remaining_size)); 467 sizes->SetDouble("remainingSize", static_cast<double>(*remaining_size));
468 468
469 SendResponse(true); 469 SendResponse(true);
470 } 470 }
471 471
472 bool FileBrowserPrivateValidatePathNameLengthFunction::RunImpl() { 472 bool FileBrowserPrivateValidatePathNameLengthFunction::RunAsync() {
473 using extensions::api::file_browser_private::ValidatePathNameLength::Params; 473 using extensions::api::file_browser_private::ValidatePathNameLength::Params;
474 const scoped_ptr<Params> params(Params::Create(*args_)); 474 const scoped_ptr<Params> params(Params::Create(*args_));
475 EXTENSION_FUNCTION_VALIDATE(params); 475 EXTENSION_FUNCTION_VALIDATE(params);
476 476
477 scoped_refptr<fileapi::FileSystemContext> file_system_context = 477 scoped_refptr<fileapi::FileSystemContext> file_system_context =
478 file_manager::util::GetFileSystemContextForRenderViewHost( 478 file_manager::util::GetFileSystemContextForRenderViewHost(
479 GetProfile(), render_view_host()); 479 GetProfile(), render_view_host());
480 480
481 fileapi::FileSystemURL filesystem_url( 481 fileapi::FileSystemURL filesystem_url(
482 file_system_context->CrackURL(GURL(params->parent_directory_url))); 482 file_system_context->CrackURL(GURL(params->parent_directory_url)));
(...skipping 18 matching lines...) Expand all
501 return true; 501 return true;
502 } 502 }
503 503
504 void FileBrowserPrivateValidatePathNameLengthFunction::OnFilePathLimitRetrieved( 504 void FileBrowserPrivateValidatePathNameLengthFunction::OnFilePathLimitRetrieved(
505 size_t current_length, 505 size_t current_length,
506 size_t max_length) { 506 size_t max_length) {
507 SetResult(new base::FundamentalValue(current_length <= max_length)); 507 SetResult(new base::FundamentalValue(current_length <= max_length));
508 SendResponse(true); 508 SendResponse(true);
509 } 509 }
510 510
511 bool FileBrowserPrivateFormatVolumeFunction::RunImpl() { 511 bool FileBrowserPrivateFormatVolumeFunction::RunAsync() {
512 using extensions::api::file_browser_private::FormatVolume::Params; 512 using extensions::api::file_browser_private::FormatVolume::Params;
513 const scoped_ptr<Params> params(Params::Create(*args_)); 513 const scoped_ptr<Params> params(Params::Create(*args_));
514 EXTENSION_FUNCTION_VALIDATE(params); 514 EXTENSION_FUNCTION_VALIDATE(params);
515 515
516 using file_manager::VolumeManager; 516 using file_manager::VolumeManager;
517 using file_manager::VolumeInfo; 517 using file_manager::VolumeInfo;
518 VolumeManager* volume_manager = VolumeManager::Get(GetProfile()); 518 VolumeManager* volume_manager = VolumeManager::Get(GetProfile());
519 if (!volume_manager) 519 if (!volume_manager)
520 return false; 520 return false;
521 521
522 VolumeInfo volume_info; 522 VolumeInfo volume_info;
523 if (!volume_manager->FindVolumeInfoById(params->volume_id, &volume_info)) 523 if (!volume_manager->FindVolumeInfoById(params->volume_id, &volume_info))
524 return false; 524 return false;
525 525
526 DiskMountManager::GetInstance()->FormatMountedDevice( 526 DiskMountManager::GetInstance()->FormatMountedDevice(
527 volume_info.mount_path.AsUTF8Unsafe()); 527 volume_info.mount_path.AsUTF8Unsafe());
528 SendResponse(true); 528 SendResponse(true);
529 return true; 529 return true;
530 } 530 }
531 531
532 bool FileBrowserPrivateStartCopyFunction::RunImpl() { 532 bool FileBrowserPrivateStartCopyFunction::RunAsync() {
533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
534 534
535 using extensions::api::file_browser_private::StartCopy::Params; 535 using extensions::api::file_browser_private::StartCopy::Params;
536 const scoped_ptr<Params> params(Params::Create(*args_)); 536 const scoped_ptr<Params> params(Params::Create(*args_));
537 EXTENSION_FUNCTION_VALIDATE(params); 537 EXTENSION_FUNCTION_VALIDATE(params);
538 538
539 if (params->source_url.empty() || params->parent.empty() || 539 if (params->source_url.empty() || params->parent.empty() ||
540 params->new_name.empty()) { 540 params->new_name.empty()) {
541 // Error code in format of DOMError.name. 541 // Error code in format of DOMError.name.
542 SetError("EncodingError"); 542 SetError("EncodingError");
(...skipping 28 matching lines...) Expand all
571 } 571 }
572 572
573 void FileBrowserPrivateStartCopyFunction::RunAfterStartCopy( 573 void FileBrowserPrivateStartCopyFunction::RunAfterStartCopy(
574 int operation_id) { 574 int operation_id) {
575 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 575 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
576 576
577 SetResult(base::Value::CreateIntegerValue(operation_id)); 577 SetResult(base::Value::CreateIntegerValue(operation_id));
578 SendResponse(true); 578 SendResponse(true);
579 } 579 }
580 580
581 bool FileBrowserPrivateCancelCopyFunction::RunImpl() { 581 bool FileBrowserPrivateCancelCopyFunction::RunAsync() {
582 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 582 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
583 583
584 using extensions::api::file_browser_private::CancelCopy::Params; 584 using extensions::api::file_browser_private::CancelCopy::Params;
585 const scoped_ptr<Params> params(Params::Create(*args_)); 585 const scoped_ptr<Params> params(Params::Create(*args_));
586 EXTENSION_FUNCTION_VALIDATE(params); 586 EXTENSION_FUNCTION_VALIDATE(params);
587 587
588 scoped_refptr<fileapi::FileSystemContext> file_system_context = 588 scoped_refptr<fileapi::FileSystemContext> file_system_context =
589 file_manager::util::GetFileSystemContextForRenderViewHost( 589 file_manager::util::GetFileSystemContextForRenderViewHost(
590 GetProfile(), render_view_host()); 590 GetProfile(), render_view_host());
591 591
592 // We don't much take care about the result of cancellation. 592 // We don't much take care about the result of cancellation.
593 BrowserThread::PostTask( 593 BrowserThread::PostTask(
594 BrowserThread::IO, 594 BrowserThread::IO,
595 FROM_HERE, 595 FROM_HERE,
596 base::Bind(&CancelCopyOnIOThread, file_system_context, params->copy_id)); 596 base::Bind(&CancelCopyOnIOThread, file_system_context, params->copy_id));
597 SendResponse(true); 597 SendResponse(true);
598 return true; 598 return true;
599 } 599 }
600 600
601 } // namespace extensions 601 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698