OLD | NEW |
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/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/statvfs.h> | 8 #include <sys/statvfs.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <utime.h> | 10 #include <utime.h> |
11 | 11 |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/posix/eintr_wrapper.h" | 13 #include "base/posix/eintr_wrapper.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/task_runner_util.h" | 15 #include "base/task_runner_util.h" |
16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
17 #include "chrome/browser/chromeos/drive/drive.pb.h" | 17 #include "chrome/browser/chromeos/drive/drive.pb.h" |
18 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | |
19 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 18 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
20 #include "chrome/browser/chromeos/drive/file_system_util.h" | 19 #include "chrome/browser/chromeos/drive/file_system_util.h" |
21 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" | 20 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" |
22 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a
pi.h" | 21 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a
pi.h" |
23 #include "chrome/browser/chromeos/extensions/file_manager/fileapi_util.h" | 22 #include "chrome/browser/chromeos/extensions/file_manager/fileapi_util.h" |
24 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 23 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
25 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 24 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
26 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
27 #include "chromeos/disks/disk_mount_manager.h" | 26 #include "chromeos/disks/disk_mount_manager.h" |
28 #include "content/public/browser/browser_context.h" | 27 #include "content/public/browser/browser_context.h" |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 std::string mount_url; | 433 std::string mount_url; |
435 if (!args_->GetString(0, &mount_url)) | 434 if (!args_->GetString(0, &mount_url)) |
436 return false; | 435 return false; |
437 | 436 |
438 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( | 437 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( |
439 render_view_host(), profile(), GURL(mount_url)); | 438 render_view_host(), profile(), GURL(mount_url)); |
440 if (file_path.empty()) | 439 if (file_path.empty()) |
441 return false; | 440 return false; |
442 | 441 |
443 if (file_path == drive::util::GetDriveMountPointPath()) { | 442 if (file_path == drive::util::GetDriveMountPointPath()) { |
444 drive::DriveIntegrationService* integration_service = | 443 drive::FileSystemInterface* file_system = |
445 drive::DriveIntegrationServiceFactory::GetForProfile(profile_); | 444 drive::util::GetFileSystemByProfile(profile()); |
446 // |integration_service| is NULL if Drive is disabled. | 445 if (!file_system) { |
447 if (!integration_service) { | 446 // |file_system| is NULL if Drive is disabled. |
448 // If stats couldn't be gotten for drive, result should be left | 447 // If stats couldn't be gotten for drive, result should be left |
449 // undefined. See comments in GetDriveAvailableSpaceCallback(). | 448 // undefined. See comments in GetDriveAvailableSpaceCallback(). |
450 SendResponse(true); | 449 SendResponse(true); |
451 return true; | 450 return true; |
452 } | 451 } |
453 | 452 |
454 drive::FileSystemInterface* file_system = | |
455 integration_service->file_system(); | |
456 | |
457 file_system->GetAvailableSpace( | 453 file_system->GetAvailableSpace( |
458 base::Bind(&FileBrowserPrivateGetSizeStatsFunction:: | 454 base::Bind(&FileBrowserPrivateGetSizeStatsFunction:: |
459 GetDriveAvailableSpaceCallback, | 455 GetDriveAvailableSpaceCallback, |
460 this)); | 456 this)); |
461 | |
462 } else { | 457 } else { |
463 uint64* total_size = new uint64(0); | 458 uint64* total_size = new uint64(0); |
464 uint64* remaining_size = new uint64(0); | 459 uint64* remaining_size = new uint64(0); |
465 BrowserThread::PostBlockingPoolTaskAndReply( | 460 BrowserThread::PostBlockingPoolTaskAndReply( |
466 FROM_HERE, | 461 FROM_HERE, |
467 base::Bind(&GetSizeStatsOnBlockingPool, | 462 base::Bind(&GetSizeStatsOnBlockingPool, |
468 file_path.value(), | 463 file_path.value(), |
469 total_size, | 464 total_size, |
470 remaining_size), | 465 remaining_size), |
471 base::Bind(&FileBrowserPrivateGetSizeStatsFunction:: | 466 base::Bind(&FileBrowserPrivateGetSizeStatsFunction:: |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 FileBrowserPrivateCancelCopyFunction::~FileBrowserPrivateCancelCopyFunction() { | 642 FileBrowserPrivateCancelCopyFunction::~FileBrowserPrivateCancelCopyFunction() { |
648 } | 643 } |
649 | 644 |
650 bool FileBrowserPrivateCancelCopyFunction::RunImpl() { | 645 bool FileBrowserPrivateCancelCopyFunction::RunImpl() { |
651 // TODO(hidehiko): Implement cancelCopy function. | 646 // TODO(hidehiko): Implement cancelCopy function. |
652 NOTIMPLEMENTED(); | 647 NOTIMPLEMENTED(); |
653 return false; | 648 return false; |
654 } | 649 } |
655 | 650 |
656 } // namespace extensions | 651 } // namespace extensions |
OLD | NEW |