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 "chrome/browser/chromeos/drive/resource_metadata_storage.h" | 5 #include "chrome/browser/chromeos/drive/resource_metadata_storage.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 235 |
236 bool ResourceMetadataStorage::Iterator::HasError() const { | 236 bool ResourceMetadataStorage::Iterator::HasError() const { |
237 base::ThreadRestrictions::AssertIOAllowed(); | 237 base::ThreadRestrictions::AssertIOAllowed(); |
238 return !it_->status().ok(); | 238 return !it_->status().ok(); |
239 } | 239 } |
240 | 240 |
241 // static | 241 // static |
242 bool ResourceMetadataStorage::UpgradeOldDB( | 242 bool ResourceMetadataStorage::UpgradeOldDB( |
243 const base::FilePath& directory_path) { | 243 const base::FilePath& directory_path) { |
244 base::ThreadRestrictions::AssertIOAllowed(); | 244 base::ThreadRestrictions::AssertIOAllowed(); |
245 COMPILE_ASSERT( | 245 static_assert( |
246 kDBVersion == 13, | 246 kDBVersion == 13, |
247 db_version_and_this_function_should_be_updated_at_the_same_time); | 247 "database version and this function must be updated at the same time"); |
248 | 248 |
249 const base::FilePath resource_map_path = | 249 const base::FilePath resource_map_path = |
250 directory_path.Append(kResourceMapDBName); | 250 directory_path.Append(kResourceMapDBName); |
251 const base::FilePath preserved_resource_map_path = | 251 const base::FilePath preserved_resource_map_path = |
252 directory_path.Append(kPreservedResourceMapDBName); | 252 directory_path.Append(kPreservedResourceMapDBName); |
253 | 253 |
254 if (base::PathExists(preserved_resource_map_path)) { | 254 if (base::PathExists(preserved_resource_map_path)) { |
255 // Preserved DB is found. The previous attempt to create a new DB should not | 255 // Preserved DB is found. The previous attempt to create a new DB should not |
256 // be successful. Discard the imperfect new DB and restore the old DB. | 256 // be successful. Discard the imperfect new DB and restore the old DB. |
257 if (!base::DeleteFile(resource_map_path, false /* recursive */) || | 257 if (!base::DeleteFile(resource_map_path, false /* recursive */) || |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 RecordCheckValidityFailure( | 1052 RecordCheckValidityFailure( |
1053 CHECK_VALIDITY_FAILURE_CHILD_ENTRY_COUNT_MISMATCH); | 1053 CHECK_VALIDITY_FAILURE_CHILD_ENTRY_COUNT_MISMATCH); |
1054 return false; | 1054 return false; |
1055 } | 1055 } |
1056 | 1056 |
1057 return true; | 1057 return true; |
1058 } | 1058 } |
1059 | 1059 |
1060 } // namespace internal | 1060 } // namespace internal |
1061 } // namespace drive | 1061 } // namespace drive |
OLD | NEW |