Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" | 5 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/sys_info.h" | |
| 10 #include "chrome/browser/chromeos/drive/drive.pb.h" | 11 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 11 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | 12 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
| 12 #include "chrome/browser/chromeos/drive/drive_resource_metadata_storage.h" | 13 #include "chrome/browser/chromeos/drive/drive_resource_metadata_storage.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 | 15 |
| 15 using content::BrowserThread; | 16 using content::BrowserThread; |
| 16 | 17 |
| 17 namespace drive { | 18 namespace drive { |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 35 } | 36 } |
| 36 | 37 |
| 37 // Runs |callback| with |result|. Used to implement GetChildDirectories(). | 38 // Runs |callback| with |result|. Used to implement GetChildDirectories(). |
| 38 void RunGetChildDirectoriesCallbackWithResult( | 39 void RunGetChildDirectoriesCallbackWithResult( |
| 39 const GetChildDirectoriesCallback& callback, | 40 const GetChildDirectoriesCallback& callback, |
| 40 scoped_ptr<std::set<base::FilePath> > result) { | 41 scoped_ptr<std::set<base::FilePath> > result) { |
| 41 DCHECK(!callback.is_null()); | 42 DCHECK(!callback.is_null()); |
| 42 callback.Run(*result); | 43 callback.Run(*result); |
| 43 } | 44 } |
| 44 | 45 |
| 46 // Returns true if enough disk space is avilable for DB operation. | |
| 47 // TODO(hashimoto): Merge this with DriveCache's FreeDiskSpaceGetterInterface. | |
| 48 bool EnoughDiskSpaceIsAvailableForDBOperation(const base::FilePath& path) { | |
| 49 const int64 kRequiredDiskSpaceInMB = 128; | |
|
hidehiko
2013/04/18 12:45:48
Could you add comments the background about why 12
hashimoto
2013/04/18 13:06:56
Done.
| |
| 50 return base::SysInfo::AmountOfFreeDiskSpace(path) >= | |
| 51 kRequiredDiskSpaceInMB*(1 << 20); | |
|
hidehiko
2013/04/18 12:45:48
nit: s/*/ * /
hashimoto
2013/04/18 13:06:56
Done.
| |
| 52 } | |
| 53 | |
| 45 } // namespace | 54 } // namespace |
| 46 | 55 |
| 47 std::string DirectoryFetchInfo::ToString() const { | 56 std::string DirectoryFetchInfo::ToString() const { |
| 48 return ("resource_id: " + resource_id_ + | 57 return ("resource_id: " + resource_id_ + |
| 49 ", changestamp: " + base::Int64ToString(changestamp_)); | 58 ", changestamp: " + base::Int64ToString(changestamp_)); |
| 50 } | 59 } |
| 51 | 60 |
| 52 EntryInfoResult::EntryInfoResult() : error(DRIVE_FILE_ERROR_FAILED) { | 61 EntryInfoResult::EntryInfoResult() : error(DRIVE_FILE_ERROR_FAILED) { |
| 53 } | 62 } |
| 54 | 63 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 callback); | 203 callback); |
| 195 } | 204 } |
| 196 | 205 |
| 197 DriveResourceMetadata::~DriveResourceMetadata() { | 206 DriveResourceMetadata::~DriveResourceMetadata() { |
| 198 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 207 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 199 } | 208 } |
| 200 | 209 |
| 201 DriveFileError DriveResourceMetadata::InitializeOnBlockingPool() { | 210 DriveFileError DriveResourceMetadata::InitializeOnBlockingPool() { |
| 202 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 211 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 203 | 212 |
| 213 if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) | |
| 214 return DRIVE_FILE_ERROR_NO_SPACE; | |
| 215 | |
| 204 // Initialize the storage. | 216 // Initialize the storage. |
| 205 if (!storage_->Initialize()) | 217 if (!storage_->Initialize()) |
| 206 return DRIVE_FILE_ERROR_FAILED; | 218 return DRIVE_FILE_ERROR_FAILED; |
| 207 | 219 |
| 208 SetUpDefaultEntries(); | 220 SetUpDefaultEntries(); |
| 209 | 221 |
| 210 return DRIVE_FILE_OK; | 222 return DRIVE_FILE_OK; |
| 211 } | 223 } |
| 212 | 224 |
| 213 void DriveResourceMetadata::SetUpDefaultEntries() { | 225 void DriveResourceMetadata::SetUpDefaultEntries() { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 228 } | 240 } |
| 229 | 241 |
| 230 void DriveResourceMetadata::DestroyOnBlockingPool() { | 242 void DriveResourceMetadata::DestroyOnBlockingPool() { |
| 231 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 243 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 232 delete this; | 244 delete this; |
| 233 } | 245 } |
| 234 | 246 |
| 235 void DriveResourceMetadata::ResetOnBlockingPool() { | 247 void DriveResourceMetadata::ResetOnBlockingPool() { |
| 236 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 248 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 237 | 249 |
| 250 // TODO(hashimoto): Return DRIVE_FILE_ERROR_NO_SPACE here. | |
| 251 if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) { | |
| 252 LOG(ERROR) << "Required disk space not available."; | |
| 253 return; | |
| 254 } | |
| 255 | |
| 238 RemoveAllOnBlockingPool(); | 256 RemoveAllOnBlockingPool(); |
| 239 storage_->SetLargestChangestamp(0); | 257 storage_->SetLargestChangestamp(0); |
| 240 } | 258 } |
| 241 | 259 |
| 242 void DriveResourceMetadata::GetLargestChangestamp( | 260 void DriveResourceMetadata::GetLargestChangestamp( |
| 243 const GetChangestampCallback& callback) { | 261 const GetChangestampCallback& callback) { |
| 244 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 245 DCHECK(!callback.is_null()); | 263 DCHECK(!callback.is_null()); |
| 246 base::PostTaskAndReplyWithResult( | 264 base::PostTaskAndReplyWithResult( |
| 247 blocking_task_runner_, | 265 blocking_task_runner_, |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 } | 462 } |
| 445 | 463 |
| 446 int64 DriveResourceMetadata::GetLargestChangestampOnBlockingPool() { | 464 int64 DriveResourceMetadata::GetLargestChangestampOnBlockingPool() { |
| 447 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 465 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 448 return storage_->GetLargestChangestamp(); | 466 return storage_->GetLargestChangestamp(); |
| 449 } | 467 } |
| 450 | 468 |
| 451 DriveFileError DriveResourceMetadata::SetLargestChangestampOnBlockingPool( | 469 DriveFileError DriveResourceMetadata::SetLargestChangestampOnBlockingPool( |
| 452 int64 value) { | 470 int64 value) { |
| 453 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 471 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 472 | |
| 473 if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) | |
| 474 return DRIVE_FILE_ERROR_NO_SPACE; | |
| 475 | |
| 454 storage_->SetLargestChangestamp(value); | 476 storage_->SetLargestChangestamp(value); |
| 455 return DRIVE_FILE_OK; | 477 return DRIVE_FILE_OK; |
| 456 } | 478 } |
| 457 | 479 |
| 458 DriveResourceMetadata::FileMoveResult | 480 DriveResourceMetadata::FileMoveResult |
| 459 DriveResourceMetadata::MoveEntryToDirectoryOnBlockingPool( | 481 DriveResourceMetadata::MoveEntryToDirectoryOnBlockingPool( |
| 460 const base::FilePath& file_path, | 482 const base::FilePath& file_path, |
| 461 const base::FilePath& directory_path) { | 483 const base::FilePath& directory_path) { |
| 462 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 484 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 463 DCHECK(!directory_path.empty()); | 485 DCHECK(!directory_path.empty()); |
| 464 DCHECK(!file_path.empty()); | 486 DCHECK(!file_path.empty()); |
| 465 | 487 |
| 488 if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) | |
| 489 return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); | |
| 490 | |
| 466 scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(file_path); | 491 scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(file_path); |
| 467 if (!entry) | 492 if (!entry) |
| 468 return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); | 493 return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); |
| 469 | 494 |
| 470 // Cannot move an entry without its parent. (i.e. the root) | 495 // Cannot move an entry without its parent. (i.e. the root) |
| 471 if (entry->parent_resource_id().empty()) | 496 if (entry->parent_resource_id().empty()) |
| 472 return FileMoveResult(DRIVE_FILE_ERROR_INVALID_OPERATION); | 497 return FileMoveResult(DRIVE_FILE_ERROR_INVALID_OPERATION); |
| 473 | 498 |
| 474 scoped_ptr<DriveEntryProto> destination = FindEntryByPathSync(directory_path); | 499 scoped_ptr<DriveEntryProto> destination = FindEntryByPathSync(directory_path); |
| 475 base::FilePath moved_file_path; | 500 base::FilePath moved_file_path; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 491 | 516 |
| 492 DriveResourceMetadata::FileMoveResult | 517 DriveResourceMetadata::FileMoveResult |
| 493 DriveResourceMetadata::RenameEntryOnBlockingPool( | 518 DriveResourceMetadata::RenameEntryOnBlockingPool( |
| 494 const base::FilePath& file_path, | 519 const base::FilePath& file_path, |
| 495 const std::string& new_name) { | 520 const std::string& new_name) { |
| 496 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 521 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 497 DCHECK(!file_path.empty()); | 522 DCHECK(!file_path.empty()); |
| 498 DCHECK(!new_name.empty()); | 523 DCHECK(!new_name.empty()); |
| 499 | 524 |
| 500 DVLOG(1) << "RenameEntry " << file_path.value() << " to " << new_name; | 525 DVLOG(1) << "RenameEntry " << file_path.value() << " to " << new_name; |
| 526 | |
| 527 if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) | |
| 528 return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); | |
| 529 | |
| 501 scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(file_path); | 530 scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(file_path); |
| 502 if (!entry) | 531 if (!entry) |
| 503 return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); | 532 return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); |
| 504 | 533 |
| 505 if (base::FilePath::FromUTF8Unsafe(new_name) == file_path.BaseName()) | 534 if (base::FilePath::FromUTF8Unsafe(new_name) == file_path.BaseName()) |
| 506 return FileMoveResult(DRIVE_FILE_ERROR_EXISTS); | 535 return FileMoveResult(DRIVE_FILE_ERROR_EXISTS); |
| 507 | 536 |
| 508 entry->set_title(new_name); | 537 entry->set_title(new_name); |
| 509 scoped_ptr<GetEntryInfoWithFilePathResult> result = | 538 scoped_ptr<GetEntryInfoWithFilePathResult> result = |
| 510 RefreshEntryOnBlockingPool(*entry); | 539 RefreshEntryOnBlockingPool(*entry); |
| 511 return FileMoveResult(result->error, result->path); | 540 return FileMoveResult(result->error, result->path); |
| 512 } | 541 } |
| 513 | 542 |
| 514 DriveResourceMetadata::FileMoveResult | 543 DriveResourceMetadata::FileMoveResult |
| 515 DriveResourceMetadata::RemoveEntryOnBlockingPool( | 544 DriveResourceMetadata::RemoveEntryOnBlockingPool( |
| 516 const std::string& resource_id) { | 545 const std::string& resource_id) { |
| 517 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 546 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 518 | 547 |
| 548 if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) | |
|
hidehiko
2013/04/18 12:45:48
Is it necessary to check disk space for removing o
hashimoto
2013/04/18 13:06:56
Yes, sometimes it results in adding an entry to th
| |
| 549 return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); | |
| 550 | |
| 519 // Disallow deletion of special entries "/drive" and "/drive/other". | 551 // Disallow deletion of special entries "/drive" and "/drive/other". |
| 520 if (util::IsSpecialResourceId(resource_id)) | 552 if (util::IsSpecialResourceId(resource_id)) |
| 521 return FileMoveResult(DRIVE_FILE_ERROR_ACCESS_DENIED); | 553 return FileMoveResult(DRIVE_FILE_ERROR_ACCESS_DENIED); |
| 522 | 554 |
| 523 scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(resource_id); | 555 scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(resource_id); |
| 524 if (!entry) | 556 if (!entry) |
| 525 return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); | 557 return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); |
| 526 | 558 |
| 527 RemoveDirectoryChild(entry->resource_id()); | 559 RemoveDirectoryChild(entry->resource_id()); |
| 528 return FileMoveResult(DRIVE_FILE_OK, | 560 return FileMoveResult(DRIVE_FILE_OK, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 first_path, | 660 first_path, |
| 629 second_path, | 661 second_path, |
| 630 callback)); | 662 callback)); |
| 631 } | 663 } |
| 632 | 664 |
| 633 scoped_ptr<DriveResourceMetadata::GetEntryInfoWithFilePathResult> | 665 scoped_ptr<DriveResourceMetadata::GetEntryInfoWithFilePathResult> |
| 634 DriveResourceMetadata::RefreshEntryOnBlockingPool( | 666 DriveResourceMetadata::RefreshEntryOnBlockingPool( |
| 635 const DriveEntryProto& entry_proto) { | 667 const DriveEntryProto& entry_proto) { |
| 636 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 668 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 637 | 669 |
| 670 if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) { | |
| 671 return make_scoped_ptr( | |
| 672 new GetEntryInfoWithFilePathResult(DRIVE_FILE_ERROR_NO_SPACE)); | |
| 673 } | |
| 674 | |
| 638 scoped_ptr<DriveEntryProto> entry = | 675 scoped_ptr<DriveEntryProto> entry = |
| 639 storage_->GetEntry(entry_proto.resource_id()); | 676 storage_->GetEntry(entry_proto.resource_id()); |
| 640 if (!entry) { | 677 if (!entry) { |
| 641 return make_scoped_ptr( | 678 return make_scoped_ptr( |
| 642 new GetEntryInfoWithFilePathResult(DRIVE_FILE_ERROR_NOT_FOUND)); | 679 new GetEntryInfoWithFilePathResult(DRIVE_FILE_ERROR_NOT_FOUND)); |
| 643 } | 680 } |
| 644 | 681 |
| 645 if (entry->parent_resource_id().empty() || // Rejct root. | 682 if (entry->parent_resource_id().empty() || // Rejct root. |
| 646 entry->file_info().is_directory() != // Reject incompatible input. | 683 entry->file_info().is_directory() != // Reject incompatible input. |
| 647 entry_proto.file_info().is_directory()) { | 684 entry_proto.file_info().is_directory()) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 671 result_entry_proto.Pass())); | 708 result_entry_proto.Pass())); |
| 672 } | 709 } |
| 673 | 710 |
| 674 DriveResourceMetadata::FileMoveResult | 711 DriveResourceMetadata::FileMoveResult |
| 675 DriveResourceMetadata::RefreshDirectoryOnBlockingPool( | 712 DriveResourceMetadata::RefreshDirectoryOnBlockingPool( |
| 676 const DirectoryFetchInfo& directory_fetch_info, | 713 const DirectoryFetchInfo& directory_fetch_info, |
| 677 const DriveEntryProtoMap& entry_proto_map) { | 714 const DriveEntryProtoMap& entry_proto_map) { |
| 678 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 715 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 679 DCHECK(!directory_fetch_info.empty()); | 716 DCHECK(!directory_fetch_info.empty()); |
| 680 | 717 |
| 718 if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) | |
| 719 return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); | |
| 720 | |
| 681 scoped_ptr<DriveEntryProto> directory = storage_->GetEntry( | 721 scoped_ptr<DriveEntryProto> directory = storage_->GetEntry( |
| 682 directory_fetch_info.resource_id()); | 722 directory_fetch_info.resource_id()); |
| 683 | 723 |
| 684 if (!directory) | 724 if (!directory) |
| 685 return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); | 725 return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); |
| 686 | 726 |
| 687 if (!directory->file_info().is_directory()) | 727 if (!directory->file_info().is_directory()) |
| 688 return FileMoveResult(DRIVE_FILE_ERROR_NOT_A_DIRECTORY); | 728 return FileMoveResult(DRIVE_FILE_ERROR_NOT_A_DIRECTORY); |
| 689 | 729 |
| 690 directory->mutable_directory_specific_info()->set_changestamp( | 730 directory->mutable_directory_specific_info()->set_changestamp( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 727 } | 767 } |
| 728 | 768 |
| 729 return FileMoveResult(DRIVE_FILE_OK, GetFilePath(directory->resource_id())); | 769 return FileMoveResult(DRIVE_FILE_OK, GetFilePath(directory->resource_id())); |
| 730 } | 770 } |
| 731 | 771 |
| 732 DriveResourceMetadata::FileMoveResult | 772 DriveResourceMetadata::FileMoveResult |
| 733 DriveResourceMetadata::AddEntryOnBlockingPool( | 773 DriveResourceMetadata::AddEntryOnBlockingPool( |
| 734 const DriveEntryProto& entry_proto) { | 774 const DriveEntryProto& entry_proto) { |
| 735 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 775 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 736 | 776 |
| 777 if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) | |
| 778 return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); | |
| 779 | |
| 737 scoped_ptr<DriveEntryProto> existing_entry = | 780 scoped_ptr<DriveEntryProto> existing_entry = |
| 738 storage_->GetEntry(entry_proto.resource_id()); | 781 storage_->GetEntry(entry_proto.resource_id()); |
| 739 if (existing_entry) | 782 if (existing_entry) |
| 740 return FileMoveResult(DRIVE_FILE_ERROR_EXISTS); | 783 return FileMoveResult(DRIVE_FILE_ERROR_EXISTS); |
| 741 | 784 |
| 742 scoped_ptr<DriveEntryProto> parent = | 785 scoped_ptr<DriveEntryProto> parent = |
| 743 GetDirectory(entry_proto.parent_resource_id()); | 786 GetDirectory(entry_proto.parent_resource_id()); |
| 744 if (!parent) | 787 if (!parent) |
| 745 return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); | 788 return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); |
| 746 | 789 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 798 if (entry->file_info().is_directory()) { | 841 if (entry->file_info().is_directory()) { |
| 799 child_directories->insert(GetFilePath(entry->resource_id())); | 842 child_directories->insert(GetFilePath(entry->resource_id())); |
| 800 GetDescendantDirectoryPaths(entry->resource_id(), child_directories); | 843 GetDescendantDirectoryPaths(entry->resource_id(), child_directories); |
| 801 } | 844 } |
| 802 } | 845 } |
| 803 } | 846 } |
| 804 | 847 |
| 805 void DriveResourceMetadata::RemoveAllOnBlockingPool() { | 848 void DriveResourceMetadata::RemoveAllOnBlockingPool() { |
| 806 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 849 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 807 | 850 |
| 851 // TODO(hashimoto): Return DRIVE_FILE_ERROR_NO_SPACE here. | |
| 852 if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) { | |
| 853 LOG(ERROR) << "Required disk space not available."; | |
| 854 return; | |
| 855 } | |
| 856 | |
| 808 RemoveDirectoryChildren(util::kDriveGrandRootSpecialResourceId); | 857 RemoveDirectoryChildren(util::kDriveGrandRootSpecialResourceId); |
| 809 SetUpDefaultEntries(); | 858 SetUpDefaultEntries(); |
| 810 } | 859 } |
| 811 | 860 |
| 812 void DriveResourceMetadata::IterateEntriesOnBlockingPool( | 861 void DriveResourceMetadata::IterateEntriesOnBlockingPool( |
| 813 const IterateCallback& callback) { | 862 const IterateCallback& callback) { |
| 814 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 863 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 815 DCHECK(!callback.is_null()); | 864 DCHECK(!callback.is_null()); |
| 816 | 865 |
| 817 storage_->Iterate(callback); | 866 storage_->Iterate(callback); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 944 storage_->GetChildren(directory_resource_id, &children); | 993 storage_->GetChildren(directory_resource_id, &children); |
| 945 for (size_t i = 0; i < children.size(); ++i) { | 994 for (size_t i = 0; i < children.size(); ++i) { |
| 946 scoped_ptr<DriveEntryProto> child = storage_->GetEntry(children[i]); | 995 scoped_ptr<DriveEntryProto> child = storage_->GetEntry(children[i]); |
| 947 DCHECK(child); | 996 DCHECK(child); |
| 948 entries->push_back(*child); | 997 entries->push_back(*child); |
| 949 } | 998 } |
| 950 return entries.Pass(); | 999 return entries.Pass(); |
| 951 } | 1000 } |
| 952 | 1001 |
| 953 } // namespace drive | 1002 } // namespace drive |
| OLD | NEW |