| 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/resource_metadata.h" | 5 #include "chrome/browser/chromeos/drive/resource_metadata.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 380 |
| 381 // Make sure that the new parent exists and it is a directory. | 381 // Make sure that the new parent exists and it is a directory. |
| 382 ResourceEntry new_parent; | 382 ResourceEntry new_parent; |
| 383 error = storage_->GetEntry(entry.parent_local_id(), &new_parent); | 383 error = storage_->GetEntry(entry.parent_local_id(), &new_parent); |
| 384 if (error != FILE_ERROR_OK) | 384 if (error != FILE_ERROR_OK) |
| 385 return error; | 385 return error; |
| 386 | 386 |
| 387 if (!new_parent.file_info().is_directory()) | 387 if (!new_parent.file_info().is_directory()) |
| 388 return FILE_ERROR_NOT_A_DIRECTORY; | 388 return FILE_ERROR_NOT_A_DIRECTORY; |
| 389 | 389 |
| 390 // Do not overwrite cache states. |
| 391 // Cache state should be changed via FileCache. |
| 392 ResourceEntry updated_entry(entry); |
| 393 if (old_entry.file_specific_info().has_cache_state()) { |
| 394 *updated_entry.mutable_file_specific_info()->mutable_cache_state() = |
| 395 old_entry.file_specific_info().cache_state(); |
| 396 } else if (updated_entry.file_specific_info().has_cache_state()) { |
| 397 updated_entry.mutable_file_specific_info()->clear_cache_state(); |
| 398 } |
| 390 // Remove from the old parent and add it to the new parent with the new data. | 399 // Remove from the old parent and add it to the new parent with the new data. |
| 391 return PutEntryUnderDirectory(entry); | 400 return PutEntryUnderDirectory(updated_entry); |
| 392 } | 401 } |
| 393 | 402 |
| 394 FileError ResourceMetadata::GetSubDirectoriesRecursively( | 403 FileError ResourceMetadata::GetSubDirectoriesRecursively( |
| 395 const std::string& id, | 404 const std::string& id, |
| 396 std::set<base::FilePath>* sub_directories) { | 405 std::set<base::FilePath>* sub_directories) { |
| 397 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 406 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 398 | 407 |
| 399 std::vector<std::string> children; | 408 std::vector<std::string> children; |
| 400 FileError error = storage_->GetChildren(id, &children); | 409 FileError error = storage_->GetChildren(id, &children); |
| 401 if (error != FILE_ERROR_OK) | 410 if (error != FILE_ERROR_OK) |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 593 |
| 585 error = cache_->Remove(id); | 594 error = cache_->Remove(id); |
| 586 if (error != FILE_ERROR_OK) | 595 if (error != FILE_ERROR_OK) |
| 587 return error; | 596 return error; |
| 588 | 597 |
| 589 return storage_->RemoveEntry(id); | 598 return storage_->RemoveEntry(id); |
| 590 } | 599 } |
| 591 | 600 |
| 592 } // namespace internal | 601 } // namespace internal |
| 593 } // namespace drive | 602 } // namespace drive |
| OLD | NEW |