| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sync/syncable/syncable.h" | 5 #include "chrome/browser/sync/syncable/syncable.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 snapshot->kernel_info.next_id -= 65536; | 571 snapshot->kernel_info.next_id -= 65536; |
| 572 snapshot->kernel_info_status = kernel_->info_status; | 572 snapshot->kernel_info_status = kernel_->info_status; |
| 573 // This one we reset on failure. | 573 // This one we reset on failure. |
| 574 kernel_->info_status = KERNEL_SHARE_INFO_VALID; | 574 kernel_->info_status = KERNEL_SHARE_INFO_VALID; |
| 575 } | 575 } |
| 576 | 576 |
| 577 bool Directory::SaveChanges() { | 577 bool Directory::SaveChanges() { |
| 578 bool success = false; | 578 bool success = false; |
| 579 DCHECK(store_); | 579 DCHECK(store_); |
| 580 | 580 |
| 581 AutoLock scoped_lock(kernel_->save_changes_mutex); | 581 base::AutoLock scoped_lock(kernel_->save_changes_mutex); |
| 582 | 582 |
| 583 // Snapshot and save. | 583 // Snapshot and save. |
| 584 SaveChangesSnapshot snapshot; | 584 SaveChangesSnapshot snapshot; |
| 585 TakeSnapshotForSaveChanges(&snapshot); | 585 TakeSnapshotForSaveChanges(&snapshot); |
| 586 success = store_->SaveChanges(snapshot); | 586 success = store_->SaveChanges(snapshot); |
| 587 | 587 |
| 588 // Handle success or failure. | 588 // Handle success or failure. |
| 589 if (success) | 589 if (success) |
| 590 VacuumAfterSaveChanges(snapshot); | 590 VacuumAfterSaveChanges(snapshot); |
| 591 else | 591 else |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 | 1122 |
| 1123 if (NULL == originals.get() || originals->empty()) { | 1123 if (NULL == originals.get() || originals->empty()) { |
| 1124 dirkernel_->transaction_mutex.Release(); | 1124 dirkernel_->transaction_mutex.Release(); |
| 1125 return false; | 1125 return false; |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 | 1128 |
| 1129 { | 1129 { |
| 1130 // Scoped_lock is only active through the calculate_changes and | 1130 // Scoped_lock is only active through the calculate_changes and |
| 1131 // transaction_ending events. | 1131 // transaction_ending events. |
| 1132 AutoLock scoped_lock(dirkernel_->changes_channel_mutex); | 1132 base::AutoLock scoped_lock(dirkernel_->changes_channel_mutex); |
| 1133 | 1133 |
| 1134 // Tell listeners to calculate changes while we still have the mutex. | 1134 // Tell listeners to calculate changes while we still have the mutex. |
| 1135 DirectoryChangeEvent event = { DirectoryChangeEvent::CALCULATE_CHANGES, | 1135 DirectoryChangeEvent event = { DirectoryChangeEvent::CALCULATE_CHANGES, |
| 1136 originals.get(), this, writer_ }; | 1136 originals.get(), this, writer_ }; |
| 1137 dirkernel_->changes_channel.Notify(event); | 1137 dirkernel_->changes_channel.Notify(event); |
| 1138 | 1138 |
| 1139 // Necessary for reads to be performed prior to transaction mutex release. | 1139 // Necessary for reads to be performed prior to transaction mutex release. |
| 1140 // Allows the listener to use the current transaction to perform reads. | 1140 // Allows the listener to use the current transaction to perform reads. |
| 1141 DirectoryChangeEvent ending_event = | 1141 DirectoryChangeEvent ending_event = |
| 1142 { DirectoryChangeEvent::TRANSACTION_ENDING, | 1142 { DirectoryChangeEvent::TRANSACTION_ENDING, |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 | 1730 |
| 1731 FastDump& operator<<(FastDump& dump, const Blob& blob) { | 1731 FastDump& operator<<(FastDump& dump, const Blob& blob) { |
| 1732 if (blob.empty()) | 1732 if (blob.empty()) |
| 1733 return dump; | 1733 return dump; |
| 1734 string buffer(base::HexEncode(&blob[0], blob.size())); | 1734 string buffer(base::HexEncode(&blob[0], blob.size())); |
| 1735 dump.out_->sputn(buffer.c_str(), buffer.size()); | 1735 dump.out_->sputn(buffer.c_str(), buffer.size()); |
| 1736 return dump; | 1736 return dump; |
| 1737 } | 1737 } |
| 1738 | 1738 |
| 1739 } // namespace syncable | 1739 } // namespace syncable |
| OLD | NEW |