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 bool update_needed = false; | |
636 ResourceMetadataHeader header; | |
637 if (GetHeader(&header) == FILE_ERROR_OK) | |
hashimoto
2016/09/29 08:43:43
GetHeader() shouldn't fail here.
If it fails, it's
harukam
2016/09/29 09:39:45
Acknowledged.
| |
638 update_needed = !header.starred_property_initialized(); | |
639 | |
640 if (update_needed) { | |
641 FileError error = SetLargestChangestamp(0); | |
hashimoto
2016/09/29 08:43:43
Instead of SetLargestChangestamp() & PutHeader(),
harukam
2016/09/29 09:39:46
Thanks.
| |
642 if (error == FILE_ERROR_OK && GetHeader(&header) == FILE_ERROR_OK) { | |
643 header.set_starred_property_initialized(true); | |
644 PutHeader(header); | |
hashimoto
2016/09/29 08:43:43
Please check for an error here.
harukam
2016/09/29 09:39:46
Done.
| |
645 } | |
646 } | |
647 } | |
648 | |
633 UMA_HISTOGRAM_ENUMERATION("Drive.MetadataDBInitResult", | 649 UMA_HISTOGRAM_ENUMERATION("Drive.MetadataDBInitResult", |
634 init_result, | 650 init_result, |
635 DB_INIT_MAX_VALUE); | 651 DB_INIT_MAX_VALUE); |
636 return !!resource_map_; | 652 return !!resource_map_; |
637 } | 653 } |
638 | 654 |
639 void ResourceMetadataStorage::RecoverCacheInfoFromTrashedResourceMap( | 655 void ResourceMetadataStorage::RecoverCacheInfoFromTrashedResourceMap( |
640 RecoveredCacheInfoMap* out_info) { | 656 RecoveredCacheInfoMap* out_info) { |
641 const base::FilePath trashed_resource_map_path = | 657 const base::FilePath trashed_resource_map_path = |
642 directory_path_.Append(kTrashedResourceMapDBName); | 658 directory_path_.Append(kTrashedResourceMapDBName); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1061 RecordCheckValidityFailure( | 1077 RecordCheckValidityFailure( |
1062 CHECK_VALIDITY_FAILURE_CHILD_ENTRY_COUNT_MISMATCH); | 1078 CHECK_VALIDITY_FAILURE_CHILD_ENTRY_COUNT_MISMATCH); |
1063 return false; | 1079 return false; |
1064 } | 1080 } |
1065 | 1081 |
1066 return true; | 1082 return true; |
1067 } | 1083 } |
1068 | 1084 |
1069 } // namespace internal | 1085 } // namespace internal |
1070 } // namespace drive | 1086 } // namespace drive |
OLD | NEW |