| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/directory_loader.h" | 5 #include "chrome/browser/chromeos/drive/directory_loader.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 if (error != FILE_ERROR_OK) | 48 if (error != FILE_ERROR_OK) |
| 49 return error; | 49 return error; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Get entry. | 52 // Get entry. |
| 53 error = resource_metadata->GetResourceEntryById(local_id, entry); | 53 error = resource_metadata->GetResourceEntryById(local_id, entry); |
| 54 if (error != FILE_ERROR_OK) | 54 if (error != FILE_ERROR_OK) |
| 55 return error; | 55 return error; |
| 56 | 56 |
| 57 // Get the local changestamp. | 57 // Get the local changestamp. |
| 58 *local_changestamp = resource_metadata->GetLargestChangestamp(); | 58 return resource_metadata->GetLargestChangestamp(local_changestamp); |
| 59 return FILE_ERROR_OK; | |
| 60 } | 59 } |
| 61 | 60 |
| 62 FileError UpdateChangestamp(ResourceMetadata* resource_metadata, | 61 FileError UpdateChangestamp(ResourceMetadata* resource_metadata, |
| 63 const DirectoryFetchInfo& directory_fetch_info, | 62 const DirectoryFetchInfo& directory_fetch_info, |
| 64 base::FilePath* directory_path) { | 63 base::FilePath* directory_path) { |
| 65 // Update the directory changestamp. | 64 // Update the directory changestamp. |
| 66 ResourceEntry directory; | 65 ResourceEntry directory; |
| 67 FileError error = resource_metadata->GetResourceEntryById( | 66 FileError error = resource_metadata->GetResourceEntryById( |
| 68 directory_fetch_info.local_id(), &directory); | 67 directory_fetch_info.local_id(), &directory); |
| 69 if (error != FILE_ERROR_OK) | 68 if (error != FILE_ERROR_OK) |
| 70 return error; | 69 return error; |
| 71 | 70 |
| 72 if (!directory.file_info().is_directory()) | 71 if (!directory.file_info().is_directory()) |
| 73 return FILE_ERROR_NOT_A_DIRECTORY; | 72 return FILE_ERROR_NOT_A_DIRECTORY; |
| 74 | 73 |
| 75 directory.mutable_directory_specific_info()->set_changestamp( | 74 directory.mutable_directory_specific_info()->set_changestamp( |
| 76 directory_fetch_info.changestamp()); | 75 directory_fetch_info.changestamp()); |
| 77 error = resource_metadata->RefreshEntry(directory); | 76 error = resource_metadata->RefreshEntry(directory); |
| 78 if (error != FILE_ERROR_OK) | 77 if (error != FILE_ERROR_OK) |
| 79 return error; | 78 return error; |
| 80 | 79 |
| 81 // Get the directory path. | 80 // Get the directory path. |
| 82 *directory_path = resource_metadata->GetFilePath( | 81 return resource_metadata->GetFilePath(directory_fetch_info.local_id(), |
| 83 directory_fetch_info.local_id()); | 82 directory_path); |
| 84 return FILE_ERROR_OK; | |
| 85 } | 83 } |
| 86 | 84 |
| 87 } // namespace | 85 } // namespace |
| 88 | 86 |
| 89 struct DirectoryLoader::ReadDirectoryCallbackState { | 87 struct DirectoryLoader::ReadDirectoryCallbackState { |
| 90 ReadDirectoryEntriesCallback entries_callback; | 88 ReadDirectoryEntriesCallback entries_callback; |
| 91 FileOperationCallback completion_callback; | 89 FileOperationCallback completion_callback; |
| 92 std::set<std::string> sent_entry_names; | 90 std::set<std::string> sent_entry_names; |
| 93 }; | 91 }; |
| 94 | 92 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 | 570 |
| 573 // Also notify the observers. | 571 // Also notify the observers. |
| 574 if (error == FILE_ERROR_OK && !directory_path->empty()) { | 572 if (error == FILE_ERROR_OK && !directory_path->empty()) { |
| 575 FOR_EACH_OBSERVER(ChangeListLoaderObserver, observers_, | 573 FOR_EACH_OBSERVER(ChangeListLoaderObserver, observers_, |
| 576 OnDirectoryChanged(*directory_path)); | 574 OnDirectoryChanged(*directory_path)); |
| 577 } | 575 } |
| 578 } | 576 } |
| 579 | 577 |
| 580 } // namespace internal | 578 } // namespace internal |
| 581 } // namespace drive | 579 } // namespace drive |
| OLD | NEW |