Chromium Code Reviews| 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/sync/syncable/directory.h" | 5 #include "components/sync/syncable/directory.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/base64.h" | 13 #include "base/base64.h" |
| 14 #include "base/files/file_enumerator.h" | |
| 14 #include "base/guid.h" | 15 #include "base/guid.h" |
| 16 #include "base/logging.h" | |
| 15 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 16 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 17 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 19 #include "base/trace_event/memory_dump_manager.h" | 21 #include "base/trace_event/memory_dump_manager.h" |
| 20 #include "base/trace_event/memory_usage_estimator.h" | 22 #include "base/trace_event/memory_usage_estimator.h" |
| 21 #include "base/trace_event/process_memory_dump.h" | 23 #include "base/trace_event/process_memory_dump.h" |
| 22 #include "base/trace_event/trace_event.h" | 24 #include "base/trace_event/trace_event.h" |
| 23 #include "components/sync/base/attachment_id_proto.h" | 25 #include "components/sync/base/attachment_id_proto.h" |
| 24 #include "components/sync/base/unique_position.h" | 26 #include "components/sync/base/unique_position.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 | 427 |
| 426 { | 428 { |
| 427 // Update the indices that depend on the PARENT_ID field. | 429 // Update the indices that depend on the PARENT_ID field. |
| 428 ScopedParentChildIndexUpdater index_updater(lock, entry, | 430 ScopedParentChildIndexUpdater index_updater(lock, entry, |
| 429 &kernel_->parent_child_index); | 431 &kernel_->parent_child_index); |
| 430 entry->put(PARENT_ID, new_parent_id); | 432 entry->put(PARENT_ID, new_parent_id); |
| 431 } | 433 } |
| 432 return true; | 434 return true; |
| 433 } | 435 } |
| 434 | 436 |
| 437 // static | |
| 438 void Directory::DeleteDirectoryFiles(const base::FilePath& directory_path) { | |
| 439 // We assume that the directory database files are all top level files, and | |
| 440 // use no folders. We also assume that there might be chuild folders under | |
|
maxbogue
2016/12/20 00:54:06
child
skym
2016/12/20 16:12:45
Done.
| |
| 441 // |directory_path| that are used for non-directory things, like storing | |
| 442 // ModelTypeStore/LevelDB data, and we expressly do not want to delete those. | |
| 443 if (base::DirectoryExists(directory_path)) { | |
| 444 base::FileEnumerator fe(directory_path, false, base::FileEnumerator::FILES); | |
| 445 for (base::FilePath current = fe.Next(); !current.empty(); | |
| 446 current = fe.Next()) { | |
| 447 if (!base::DeleteFile(current, false)) { | |
| 448 LOG(DFATAL) << "Could not delete the Sync Data folder."; | |
|
maxbogue
2016/12/20 00:54:06
Maybe "Could not delete all sync directory files."
skym
2016/12/20 16:12:45
Done.
| |
| 449 } | |
| 450 } | |
| 451 } | |
| 452 } | |
| 453 | |
| 435 void Directory::RemoveFromAttachmentIndex( | 454 void Directory::RemoveFromAttachmentIndex( |
| 436 const ScopedKernelLock& lock, | 455 const ScopedKernelLock& lock, |
| 437 const int64_t metahandle, | 456 const int64_t metahandle, |
| 438 const sync_pb::AttachmentMetadata& attachment_metadata) { | 457 const sync_pb::AttachmentMetadata& attachment_metadata) { |
| 439 for (int i = 0; i < attachment_metadata.record_size(); ++i) { | 458 for (int i = 0; i < attachment_metadata.record_size(); ++i) { |
| 440 AttachmentIdUniqueId unique_id = | 459 AttachmentIdUniqueId unique_id = |
| 441 attachment_metadata.record(i).id().unique_id(); | 460 attachment_metadata.record(i).id().unique_id(); |
| 442 IndexByAttachmentId::iterator iter = | 461 IndexByAttachmentId::iterator iter = |
| 443 kernel_->index_by_attachment_id.find(unique_id); | 462 kernel_->index_by_attachment_id.find(unique_id); |
| 444 if (iter != kernel_->index_by_attachment_id.end()) { | 463 if (iter != kernel_->index_by_attachment_id.end()) { |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1588 Directory::Kernel* Directory::kernel() { | 1607 Directory::Kernel* Directory::kernel() { |
| 1589 return kernel_; | 1608 return kernel_; |
| 1590 } | 1609 } |
| 1591 | 1610 |
| 1592 const Directory::Kernel* Directory::kernel() const { | 1611 const Directory::Kernel* Directory::kernel() const { |
| 1593 return kernel_; | 1612 return kernel_; |
| 1594 } | 1613 } |
| 1595 | 1614 |
| 1596 } // namespace syncable | 1615 } // namespace syncable |
| 1597 } // namespace syncer | 1616 } // namespace syncer |
| OLD | NEW |