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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 } | 997 } |
998 } | 998 } |
999 | 999 |
1000 BaseTransaction::BaseTransaction(Directory* directory, const char* name, | 1000 BaseTransaction::BaseTransaction(Directory* directory, const char* name, |
1001 const char* source_file, int line, WriterTag writer) | 1001 const char* source_file, int line, WriterTag writer) |
1002 : directory_(directory), dirkernel_(directory->kernel_), name_(name), | 1002 : directory_(directory), dirkernel_(directory->kernel_), name_(name), |
1003 source_file_(source_file), line_(line), writer_(writer) { | 1003 source_file_(source_file), line_(line), writer_(writer) { |
1004 Lock(); | 1004 Lock(); |
1005 } | 1005 } |
1006 | 1006 |
| 1007 BaseTransaction::BaseTransaction(Directory* directory) : |
| 1008 source_file_(NULL), |
| 1009 name_(NULL), |
| 1010 line_(NULL), |
| 1011 writer_(INVALID), |
| 1012 dirkernel_(NULL), |
| 1013 directory_(directory) { |
| 1014 } |
| 1015 |
1007 BaseTransaction::~BaseTransaction() {} | 1016 BaseTransaction::~BaseTransaction() {} |
1008 | 1017 |
1009 void BaseTransaction::UnlockAndLog(OriginalEntries* originals_arg) { | 1018 void BaseTransaction::UnlockAndLog(OriginalEntries* originals_arg) { |
1010 // Triggers the CALCULATE_CHANGES and TRANSACTION_ENDING events while | 1019 // Triggers the CALCULATE_CHANGES and TRANSACTION_ENDING events while |
1011 // holding dir_kernel_'s transaction_mutex and changes_channel mutex. | 1020 // holding dir_kernel_'s transaction_mutex and changes_channel mutex. |
1012 // Releases all mutexes upon completion. | 1021 // Releases all mutexes upon completion. |
1013 if (!NotifyTransactionChangingAndEnding(originals_arg)) { | 1022 if (!NotifyTransactionChangingAndEnding(originals_arg)) { |
1014 return; | 1023 return; |
1015 } | 1024 } |
1016 | 1025 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 : BaseTransaction(directory, "Write", file, line, writer), | 1100 : BaseTransaction(directory, "Write", file, line, writer), |
1092 originals_(new OriginalEntries) { | 1101 originals_(new OriginalEntries) { |
1093 } | 1102 } |
1094 | 1103 |
1095 WriteTransaction::WriteTransaction(const ScopedDirLookup& scoped_dir, | 1104 WriteTransaction::WriteTransaction(const ScopedDirLookup& scoped_dir, |
1096 WriterTag writer, const char* file, int line) | 1105 WriterTag writer, const char* file, int line) |
1097 : BaseTransaction(scoped_dir.operator -> (), "Write", file, line, writer), | 1106 : BaseTransaction(scoped_dir.operator -> (), "Write", file, line, writer), |
1098 originals_(new OriginalEntries) { | 1107 originals_(new OriginalEntries) { |
1099 } | 1108 } |
1100 | 1109 |
| 1110 WriteTransaction::WriteTransaction(Directory *directory) : |
| 1111 BaseTransaction(directory), |
| 1112 originals_(new OriginalEntries) { |
| 1113 } |
| 1114 |
1101 void WriteTransaction::SaveOriginal(EntryKernel* entry) { | 1115 void WriteTransaction::SaveOriginal(EntryKernel* entry) { |
1102 if (NULL == entry) | 1116 if (NULL == entry) |
1103 return; | 1117 return; |
1104 OriginalEntries::iterator i = originals_->lower_bound(*entry); | 1118 OriginalEntries::iterator i = originals_->lower_bound(*entry); |
1105 if (i == originals_->end() || | 1119 if (i == originals_->end() || |
1106 i->ref(META_HANDLE) != entry->ref(META_HANDLE)) { | 1120 i->ref(META_HANDLE) != entry->ref(META_HANDLE)) { |
1107 originals_->insert(i, *entry); | 1121 originals_->insert(i, *entry); |
1108 } | 1122 } |
1109 } | 1123 } |
1110 | 1124 |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 | 1652 |
1639 FastDump& operator<<(FastDump& dump, const Blob& blob) { | 1653 FastDump& operator<<(FastDump& dump, const Blob& blob) { |
1640 if (blob.empty()) | 1654 if (blob.empty()) |
1641 return dump; | 1655 return dump; |
1642 string buffer(base::HexEncode(&blob[0], blob.size())); | 1656 string buffer(base::HexEncode(&blob[0], blob.size())); |
1643 dump.out_->sputn(buffer.c_str(), buffer.size()); | 1657 dump.out_->sputn(buffer.c_str(), buffer.size()); |
1644 return dump; | 1658 return dump; |
1645 } | 1659 } |
1646 | 1660 |
1647 } // namespace syncable | 1661 } // namespace syncable |
OLD | NEW |