| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
| 6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <bitset> | 10 #include <bitset> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/sync/protocol/sync.pb.h" | 30 #include "chrome/browser/sync/protocol/sync.pb.h" |
| 31 #include "chrome/browser/sync/syncable/blob.h" | 31 #include "chrome/browser/sync/syncable/blob.h" |
| 32 #include "chrome/browser/sync/syncable/dir_open_result.h" | 32 #include "chrome/browser/sync/syncable/dir_open_result.h" |
| 33 #include "chrome/browser/sync/syncable/directory_event.h" | 33 #include "chrome/browser/sync/syncable/directory_event.h" |
| 34 #include "chrome/browser/sync/syncable/syncable_id.h" | 34 #include "chrome/browser/sync/syncable/syncable_id.h" |
| 35 #include "chrome/browser/sync/syncable/model_type.h" | 35 #include "chrome/browser/sync/syncable/model_type.h" |
| 36 #include "chrome/browser/sync/util/dbgq.h" | 36 #include "chrome/browser/sync/util/dbgq.h" |
| 37 #include "chrome/browser/sync/util/immutable.h" | 37 #include "chrome/browser/sync/util/immutable.h" |
| 38 #include "chrome/browser/sync/util/time.h" | 38 #include "chrome/browser/sync/util/time.h" |
| 39 | 39 |
| 40 struct PurgeInfo; | |
| 41 | |
| 42 namespace base { | 40 namespace base { |
| 43 class DictionaryValue; | 41 class DictionaryValue; |
| 44 class ListValue; | 42 class ListValue; |
| 45 } | 43 } |
| 46 | 44 |
| 47 namespace sync_api { | 45 namespace sync_api { |
| 48 class ReadTransaction; | 46 class ReadTransaction; |
| 49 class WriteNode; | 47 class WriteNode; |
| 50 class ReadNode; | 48 class ReadNode; |
| 51 } // sync_api | 49 } // sync_api |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 476 |
| 479 protected: // Don't allow creation on heap, except by sync API wrappers. | 477 protected: // Don't allow creation on heap, except by sync API wrappers. |
| 480 friend class sync_api::ReadNode; | 478 friend class sync_api::ReadNode; |
| 481 void* operator new(size_t size) { return (::operator new)(size); } | 479 void* operator new(size_t size) { return (::operator new)(size); } |
| 482 | 480 |
| 483 inline explicit Entry(BaseTransaction* trans) | 481 inline explicit Entry(BaseTransaction* trans) |
| 484 : basetrans_(trans), | 482 : basetrans_(trans), |
| 485 kernel_(NULL) { } | 483 kernel_(NULL) { } |
| 486 | 484 |
| 487 protected: | 485 protected: |
| 488 | |
| 489 BaseTransaction* const basetrans_; | 486 BaseTransaction* const basetrans_; |
| 490 | 487 |
| 491 EntryKernel* kernel_; | 488 EntryKernel* kernel_; |
| 492 | 489 |
| 493 private: | 490 private: |
| 494 // Like GetServerModelType() but without the DCHECKs. | 491 // Like GetServerModelType() but without the DCHECKs. |
| 495 ModelType GetServerModelTypeHelper() const; | 492 ModelType GetServerModelTypeHelper() const; |
| 496 | 493 |
| 497 DISALLOW_COPY_AND_ASSIGN(Entry); | 494 DISALLOW_COPY_AND_ASSIGN(Entry); |
| 498 }; | 495 }; |
| 499 | 496 |
| 500 // A mutable meta entry. Changes get committed to the database when the | 497 // A mutable meta entry. Changes get committed to the database when the |
| 501 // WriteTransaction is destroyed. | 498 // WriteTransaction is destroyed. |
| 502 class MutableEntry : public Entry { | 499 class MutableEntry : public Entry { |
| 503 friend class WriteTransaction; | 500 friend class WriteTransaction; |
| 504 friend class Directory; | 501 friend class Directory; |
| 505 void Init(WriteTransaction* trans, const Id& parent_id, | 502 void Init(WriteTransaction* trans, const Id& parent_id, |
| 506 const std::string& name); | 503 const std::string& name); |
| 504 |
| 507 public: | 505 public: |
| 508 MutableEntry(WriteTransaction* trans, Create, const Id& parent_id, | 506 MutableEntry(WriteTransaction* trans, Create, const Id& parent_id, |
| 509 const std::string& name); | 507 const std::string& name); |
| 510 MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, const Id& id); | 508 MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, const Id& id); |
| 511 MutableEntry(WriteTransaction* trans, GetByHandle, int64); | 509 MutableEntry(WriteTransaction* trans, GetByHandle, int64); |
| 512 MutableEntry(WriteTransaction* trans, GetById, const Id&); | 510 MutableEntry(WriteTransaction* trans, GetById, const Id&); |
| 513 MutableEntry(WriteTransaction* trans, GetByClientTag, const std::string& tag); | 511 MutableEntry(WriteTransaction* trans, GetByClientTag, const std::string& tag); |
| 514 MutableEntry(WriteTransaction* trans, GetByServerTag, const std::string& tag); | 512 MutableEntry(WriteTransaction* trans, GetByServerTag, const std::string& tag); |
| 515 | 513 |
| 516 inline WriteTransaction* write_transaction() const { | 514 inline WriteTransaction* write_transaction() const { |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 // We can't store only existing tags because the client would create | 1047 // We can't store only existing tags because the client would create |
| 1050 // items that had a duplicated ID in the end, resulting in a DB key | 1048 // items that had a duplicated ID in the end, resulting in a DB key |
| 1051 // violation. ID reassociation would fail after an attempted commit. | 1049 // violation. ID reassociation would fail after an attempted commit. |
| 1052 typedef Index<ClientTagIndexer>::Set ClientTagIndex; | 1050 typedef Index<ClientTagIndexer>::Set ClientTagIndex; |
| 1053 | 1051 |
| 1054 protected: | 1052 protected: |
| 1055 // Used by tests. | 1053 // Used by tests. |
| 1056 void InitKernel(const std::string& name, DirectoryChangeDelegate* delegate); | 1054 void InitKernel(const std::string& name, DirectoryChangeDelegate* delegate); |
| 1057 | 1055 |
| 1058 private: | 1056 private: |
| 1059 | |
| 1060 struct Kernel { | 1057 struct Kernel { |
| 1061 // |delegate| can be NULL. | 1058 // |delegate| can be NULL. |
| 1062 Kernel(const FilePath& db_path, const std::string& name, | 1059 Kernel(const FilePath& db_path, const std::string& name, |
| 1063 const KernelLoadInfo& info, DirectoryChangeDelegate* delegate); | 1060 const KernelLoadInfo& info, DirectoryChangeDelegate* delegate); |
| 1064 | 1061 |
| 1065 ~Kernel(); | 1062 ~Kernel(); |
| 1066 | 1063 |
| 1067 void AddRef(); // For convenience. | 1064 void AddRef(); // For convenience. |
| 1068 void Release(); | 1065 void Release(); |
| 1069 | 1066 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); | 1271 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); |
| 1275 | 1272 |
| 1276 // This function sets only the flags needed to get this entry to sync. | 1273 // This function sets only the flags needed to get this entry to sync. |
| 1277 void MarkForSyncing(syncable::MutableEntry* e); | 1274 void MarkForSyncing(syncable::MutableEntry* e); |
| 1278 | 1275 |
| 1279 } // namespace syncable | 1276 } // namespace syncable |
| 1280 | 1277 |
| 1281 std::ostream& operator <<(std::ostream&, const syncable::Blob&); | 1278 std::ostream& operator <<(std::ostream&, const syncable::Blob&); |
| 1282 | 1279 |
| 1283 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 1280 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
| OLD | NEW |