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> |
| 8 |
7 #include <map> | 9 #include <map> |
8 #include <set> | 10 #include <set> |
9 | 11 |
10 #include "base/bind.h" | 12 #include "base/bind.h" |
11 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
12 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
13 #include "base/location.h" | 15 #include "base/location.h" |
14 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" |
15 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
16 #include "base/metrics/sparse_histogram.h" | 19 #include "base/metrics/sparse_histogram.h" |
17 #include "base/sequenced_task_runner.h" | 20 #include "base/sequenced_task_runner.h" |
18 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
19 #include "components/drive/drive.pb.h" | 22 #include "components/drive/drive.pb.h" |
20 #include "components/drive/drive_api_util.h" | 23 #include "components/drive/drive_api_util.h" |
21 #include "third_party/leveldatabase/env_chromium.h" | 24 #include "third_party/leveldatabase/env_chromium.h" |
22 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 25 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
23 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 26 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
24 | 27 |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 RecoveredCacheInfo* info = &(*out_info)[id]; | 689 RecoveredCacheInfo* info = &(*out_info)[id]; |
687 info->is_dirty = entry.file_specific_info().cache_state().is_dirty(); | 690 info->is_dirty = entry.file_specific_info().cache_state().is_dirty(); |
688 info->md5 = entry.file_specific_info().cache_state().md5(); | 691 info->md5 = entry.file_specific_info().cache_state().md5(); |
689 info->title = entry.title(); | 692 info->title = entry.title(); |
690 } | 693 } |
691 } | 694 } |
692 } | 695 } |
693 } | 696 } |
694 | 697 |
695 FileError ResourceMetadataStorage::SetLargestChangestamp( | 698 FileError ResourceMetadataStorage::SetLargestChangestamp( |
696 int64 largest_changestamp) { | 699 int64_t largest_changestamp) { |
697 base::ThreadRestrictions::AssertIOAllowed(); | 700 base::ThreadRestrictions::AssertIOAllowed(); |
698 | 701 |
699 ResourceMetadataHeader header; | 702 ResourceMetadataHeader header; |
700 FileError error = GetHeader(&header); | 703 FileError error = GetHeader(&header); |
701 if (error != FILE_ERROR_OK) { | 704 if (error != FILE_ERROR_OK) { |
702 DLOG(ERROR) << "Failed to get the header."; | 705 DLOG(ERROR) << "Failed to get the header."; |
703 return error; | 706 return error; |
704 } | 707 } |
705 header.set_largest_changestamp(largest_changestamp); | 708 header.set_largest_changestamp(largest_changestamp); |
706 return PutHeader(header); | 709 return PutHeader(header); |
707 } | 710 } |
708 | 711 |
709 FileError ResourceMetadataStorage::GetLargestChangestamp( | 712 FileError ResourceMetadataStorage::GetLargestChangestamp( |
710 int64* largest_changestamp) { | 713 int64_t* largest_changestamp) { |
711 base::ThreadRestrictions::AssertIOAllowed(); | 714 base::ThreadRestrictions::AssertIOAllowed(); |
712 ResourceMetadataHeader header; | 715 ResourceMetadataHeader header; |
713 FileError error = GetHeader(&header); | 716 FileError error = GetHeader(&header); |
714 if (error != FILE_ERROR_OK) { | 717 if (error != FILE_ERROR_OK) { |
715 DLOG(ERROR) << "Failed to get the header."; | 718 DLOG(ERROR) << "Failed to get the header."; |
716 return error; | 719 return error; |
717 } | 720 } |
718 *largest_changestamp = header.largest_changestamp(); | 721 *largest_changestamp = header.largest_changestamp(); |
719 return FILE_ERROR_OK; | 722 return FILE_ERROR_OK; |
720 } | 723 } |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 RecordCheckValidityFailure( | 1058 RecordCheckValidityFailure( |
1056 CHECK_VALIDITY_FAILURE_CHILD_ENTRY_COUNT_MISMATCH); | 1059 CHECK_VALIDITY_FAILURE_CHILD_ENTRY_COUNT_MISMATCH); |
1057 return false; | 1060 return false; |
1058 } | 1061 } |
1059 | 1062 |
1060 return true; | 1063 return true; |
1061 } | 1064 } |
1062 | 1065 |
1063 } // namespace internal | 1066 } // namespace internal |
1064 } // namespace drive | 1067 } // namespace drive |
OLD | NEW |