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 "components/drive/resource_metadata_storage.h" | 5 #include "components/drive/resource_metadata_storage.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 } else { | 623 } else { |
624 init_result = DB_INIT_FAILED; | 624 init_result = DB_INIT_FAILED; |
625 resource_map_.reset(); | 625 resource_map_.reset(); |
626 } | 626 } |
627 } else { | 627 } else { |
628 LOG(ERROR) << "Failed to create resource map DB: " << status.ToString(); | 628 LOG(ERROR) << "Failed to create resource map DB: " << status.ToString(); |
629 init_result = LevelDBStatusToDBInitStatus(status); | 629 init_result = LevelDBStatusToDBInitStatus(status); |
630 } | 630 } |
631 } | 631 } |
632 | 632 |
| 633 // Update local resouces if 'starred' property has not been initialized. |
| 634 if (resource_map_) { |
| 635 ResourceMetadataHeader header; |
| 636 if (GetHeader(&header) != FILE_ERROR_OK) |
| 637 return false; |
| 638 |
| 639 if (!header.starred_property_initialized()) { |
| 640 // largest changestamp == 0 means data in DB is obsolete. |
| 641 // So data for all entries will be reloaded. |
| 642 header.set_largest_changestamp(0); |
| 643 header.set_starred_property_initialized(true); |
| 644 FileError error = PutHeader(header); |
| 645 |
| 646 if (error != FILE_ERROR_OK) |
| 647 return false; |
| 648 } |
| 649 } |
| 650 |
633 UMA_HISTOGRAM_ENUMERATION("Drive.MetadataDBInitResult", | 651 UMA_HISTOGRAM_ENUMERATION("Drive.MetadataDBInitResult", |
634 init_result, | 652 init_result, |
635 DB_INIT_MAX_VALUE); | 653 DB_INIT_MAX_VALUE); |
636 return !!resource_map_; | 654 return !!resource_map_; |
637 } | 655 } |
638 | 656 |
639 void ResourceMetadataStorage::RecoverCacheInfoFromTrashedResourceMap( | 657 void ResourceMetadataStorage::RecoverCacheInfoFromTrashedResourceMap( |
640 RecoveredCacheInfoMap* out_info) { | 658 RecoveredCacheInfoMap* out_info) { |
641 const base::FilePath trashed_resource_map_path = | 659 const base::FilePath trashed_resource_map_path = |
642 directory_path_.Append(kTrashedResourceMapDBName); | 660 directory_path_.Append(kTrashedResourceMapDBName); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 RecordCheckValidityFailure( | 1079 RecordCheckValidityFailure( |
1062 CHECK_VALIDITY_FAILURE_CHILD_ENTRY_COUNT_MISMATCH); | 1080 CHECK_VALIDITY_FAILURE_CHILD_ENTRY_COUNT_MISMATCH); |
1063 return false; | 1081 return false; |
1064 } | 1082 } |
1065 | 1083 |
1066 return true; | 1084 return true; |
1067 } | 1085 } |
1068 | 1086 |
1069 } // namespace internal | 1087 } // namespace internal |
1070 } // namespace drive | 1088 } // namespace drive |
OLD | NEW |