| 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 20 matching lines...) Expand all Loading... |
| 31 #include "base/file_util.h" | 31 #include "base/file_util.h" |
| 32 #include "base/logging.h" | 32 #include "base/logging.h" |
| 33 #include "base/perftimer.h" | 33 #include "base/perftimer.h" |
| 34 #include "base/scoped_ptr.h" | 34 #include "base/scoped_ptr.h" |
| 35 #include "base/string_number_conversions.h" | 35 #include "base/string_number_conversions.h" |
| 36 #include "base/string_util.h" | 36 #include "base/string_util.h" |
| 37 #include "base/stl_util-inl.h" | 37 #include "base/stl_util-inl.h" |
| 38 #include "base/time.h" | 38 #include "base/time.h" |
| 39 #include "chrome/browser/sync/engine/syncer.h" | 39 #include "chrome/browser/sync/engine/syncer.h" |
| 40 #include "chrome/browser/sync/engine/syncer_util.h" | 40 #include "chrome/browser/sync/engine/syncer_util.h" |
| 41 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" | |
| 42 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | |
| 43 #include "chrome/browser/sync/protocol/password_specifics.pb.h" | |
| 44 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" | |
| 45 #include "chrome/browser/sync/protocol/service_constants.h" | 41 #include "chrome/browser/sync/protocol/service_constants.h" |
| 46 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" | 42 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" |
| 47 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" | 43 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" |
| 48 #include "chrome/browser/sync/syncable/directory_backing_store.h" | 44 #include "chrome/browser/sync/syncable/directory_backing_store.h" |
| 49 #include "chrome/browser/sync/syncable/directory_manager.h" | 45 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 50 #include "chrome/browser/sync/syncable/syncable-inl.h" | 46 #include "chrome/browser/sync/syncable/syncable-inl.h" |
| 51 #include "chrome/browser/sync/syncable/syncable_changes_version.h" | 47 #include "chrome/browser/sync/syncable/syncable_changes_version.h" |
| 52 #include "chrome/browser/sync/syncable/syncable_columns.h" | 48 #include "chrome/browser/sync/syncable/syncable_columns.h" |
| 53 #include "chrome/browser/sync/util/crypto_helpers.h" | 49 #include "chrome/browser/sync/util/crypto_helpers.h" |
| 54 #include "chrome/common/deprecated/event_sys-inl.h" | 50 #include "chrome/common/deprecated/event_sys-inl.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 kernel_->unapplied_update_metahandles->insert(entry->ref(META_HANDLE)); | 267 kernel_->unapplied_update_metahandles->insert(entry->ref(META_HANDLE)); |
| 272 DCHECK(!entry->is_dirty()); | 268 DCHECK(!entry->is_dirty()); |
| 273 } | 269 } |
| 274 } | 270 } |
| 275 | 271 |
| 276 DirectoryBackingStore* Directory::CreateBackingStore( | 272 DirectoryBackingStore* Directory::CreateBackingStore( |
| 277 const string& dir_name, const FilePath& backing_filepath) { | 273 const string& dir_name, const FilePath& backing_filepath) { |
| 278 return new DirectoryBackingStore(dir_name, backing_filepath); | 274 return new DirectoryBackingStore(dir_name, backing_filepath); |
| 279 } | 275 } |
| 280 | 276 |
| 277 void Directory::SetEncryptedDataTypes(const ModelTypeSet& encrypted_types) { |
| 278 // Sanity check, passwords should always be encrypted. |
| 279 DCHECK(encrypted_types.count(syncable::PASSWORDS) > 0); |
| 280 kernel_->encrypted_datatypes = encrypted_types; |
| 281 } |
| 282 |
| 281 DirOpenResult Directory::OpenImpl(const FilePath& file_path, | 283 DirOpenResult Directory::OpenImpl(const FilePath& file_path, |
| 282 const string& name) { | 284 const string& name) { |
| 283 DCHECK_EQ(static_cast<DirectoryBackingStore*>(NULL), store_); | 285 DCHECK_EQ(static_cast<DirectoryBackingStore*>(NULL), store_); |
| 284 FilePath db_path(file_path); | 286 FilePath db_path(file_path); |
| 285 file_util::AbsolutePath(&db_path); | 287 file_util::AbsolutePath(&db_path); |
| 286 store_ = CreateBackingStore(name, db_path); | 288 store_ = CreateBackingStore(name, db_path); |
| 287 | 289 |
| 288 KernelLoadInfo info; | 290 KernelLoadInfo info; |
| 289 // Temporary indices before kernel_ initialized in case Load fails. We 0(1) | 291 // Temporary indices before kernel_ initialized in case Load fails. We 0(1) |
| 290 // swap these later. | 292 // swap these later. |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 : directory_(directory), | 1098 : directory_(directory), |
| 1097 dirkernel_(NULL), | 1099 dirkernel_(NULL), |
| 1098 name_(NULL), | 1100 name_(NULL), |
| 1099 source_file_(NULL), | 1101 source_file_(NULL), |
| 1100 line_(0), | 1102 line_(0), |
| 1101 writer_(INVALID) { | 1103 writer_(INVALID) { |
| 1102 } | 1104 } |
| 1103 | 1105 |
| 1104 BaseTransaction::~BaseTransaction() {} | 1106 BaseTransaction::~BaseTransaction() {} |
| 1105 | 1107 |
| 1108 void BaseTransaction::SetEncryptedDataTypes( |
| 1109 const ModelTypeSet& encrypted_types) { |
| 1110 directory()->SetEncryptedDataTypes(encrypted_types); |
| 1111 } |
| 1112 |
| 1106 void BaseTransaction::UnlockAndLog(OriginalEntries* originals_arg) { | 1113 void BaseTransaction::UnlockAndLog(OriginalEntries* originals_arg) { |
| 1107 // Triggers the CALCULATE_CHANGES and TRANSACTION_ENDING events while | 1114 // Triggers the CALCULATE_CHANGES and TRANSACTION_ENDING events while |
| 1108 // holding dir_kernel_'s transaction_mutex and changes_channel mutex. | 1115 // holding dir_kernel_'s transaction_mutex and changes_channel mutex. |
| 1109 // Releases all mutexes upon completion. | 1116 // Releases all mutexes upon completion. |
| 1110 if (!NotifyTransactionChangingAndEnding(originals_arg)) { | 1117 if (!NotifyTransactionChangingAndEnding(originals_arg)) { |
| 1111 return; | 1118 return; |
| 1112 } | 1119 } |
| 1113 | 1120 |
| 1114 // Triggers the TRANSACTION_COMPLETE event (and does not hold any mutexes). | 1121 // Triggers the TRANSACTION_COMPLETE event (and does not hold any mutexes). |
| 1115 NotifyTransactionComplete(); | 1122 NotifyTransactionComplete(); |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 } | 1714 } |
| 1708 | 1715 |
| 1709 std::ostream& operator<<(std::ostream& s, const Blob& blob) { | 1716 std::ostream& operator<<(std::ostream& s, const Blob& blob) { |
| 1710 for (Blob::const_iterator i = blob.begin(); i != blob.end(); ++i) | 1717 for (Blob::const_iterator i = blob.begin(); i != blob.end(); ++i) |
| 1711 s << std::hex << std::setw(2) | 1718 s << std::hex << std::setw(2) |
| 1712 << std::setfill('0') << static_cast<unsigned int>(*i); | 1719 << std::setfill('0') << static_cast<unsigned int>(*i); |
| 1713 return s << std::dec; | 1720 return s << std::dec; |
| 1714 } | 1721 } |
| 1715 | 1722 |
| 1716 } // namespace syncable | 1723 } // namespace syncable |
| OLD | NEW |