| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 SYNC_API_SYNC_DATA_H_ | 5 #ifndef SYNC_API_SYNC_DATA_H_ |
| 6 #define SYNC_API_SYNC_DATA_H_ | 6 #define SYNC_API_SYNC_DATA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "sync/internal_api/public/syncable/model_type.h" | 14 #include "sync/internal_api/public/syncable/model_type.h" |
| 15 #include "sync/internal_api/public/util/immutable.h" | 15 #include "sync/internal_api/public/util/immutable.h" |
| 16 | 16 |
| 17 namespace sync_pb { | 17 namespace sync_pb { |
| 18 class EntitySpecifics; | 18 class EntitySpecifics; |
| 19 class SyncEntity; | 19 class SyncEntity; |
| 20 } // namespace sync_pb | 20 } // namespace sync_pb |
| 21 | 21 |
| 22 namespace csync { | 22 namespace syncer { |
| 23 | 23 |
| 24 typedef syncable::ModelType SyncDataType; | 24 typedef syncable::ModelType SyncDataType; |
| 25 | 25 |
| 26 // A light-weight container for immutable sync data. Pass-by-value and storage | 26 // A light-weight container for immutable sync data. Pass-by-value and storage |
| 27 // in STL containers are supported and encouraged if helpful. | 27 // in STL containers are supported and encouraged if helpful. |
| 28 class SyncData { | 28 class SyncData { |
| 29 public: | 29 public: |
| 30 // Creates an empty and invalid SyncData. | 30 // Creates an empty and invalid SyncData. |
| 31 SyncData(); | 31 SyncData(); |
| 32 ~SyncData(); | 32 ~SyncData(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 static void DestroyWrapper(Wrapper* wrapper); | 94 static void DestroyWrapper(Wrapper* wrapper); |
| 95 | 95 |
| 96 static const sync_pb::SyncEntity& Unwrap(const Wrapper& wrapper); | 96 static const sync_pb::SyncEntity& Unwrap(const Wrapper& wrapper); |
| 97 | 97 |
| 98 static sync_pb::SyncEntity* UnwrapMutable(Wrapper* wrapper); | 98 static sync_pb::SyncEntity* UnwrapMutable(Wrapper* wrapper); |
| 99 | 99 |
| 100 static void Swap(sync_pb::SyncEntity* t1, sync_pb::SyncEntity* t2); | 100 static void Swap(sync_pb::SyncEntity* t1, sync_pb::SyncEntity* t2); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 typedef csync::Immutable< | 103 typedef syncer::Immutable< |
| 104 sync_pb::SyncEntity, ImmutableSyncEntityTraits> | 104 sync_pb::SyncEntity, ImmutableSyncEntityTraits> |
| 105 ImmutableSyncEntity; | 105 ImmutableSyncEntity; |
| 106 | 106 |
| 107 // Clears |entity|. | 107 // Clears |entity|. |
| 108 SyncData(int64 id, sync_pb::SyncEntity* entity); | 108 SyncData(int64 id, sync_pb::SyncEntity* entity); |
| 109 | 109 |
| 110 // Whether this SyncData holds valid data. | 110 // Whether this SyncData holds valid data. |
| 111 bool is_valid_; | 111 bool is_valid_; |
| 112 | 112 |
| 113 // Equal to csync::kInvalidId iff this is local. | 113 // Equal to syncer::kInvalidId iff this is local. |
| 114 int64 id_; | 114 int64 id_; |
| 115 | 115 |
| 116 // The actual shared sync entity being held. | 116 // The actual shared sync entity being held. |
| 117 ImmutableSyncEntity immutable_entity_; | 117 ImmutableSyncEntity immutable_entity_; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 // gmock printer helper. | 120 // gmock printer helper. |
| 121 void PrintTo(const SyncData& sync_data, std::ostream* os); | 121 void PrintTo(const SyncData& sync_data, std::ostream* os); |
| 122 | 122 |
| 123 } // namespace csync | 123 } // namespace syncer |
| 124 | 124 |
| 125 #endif // SYNC_API_SYNC_DATA_H_ | 125 #endif // SYNC_API_SYNC_DATA_H_ |
| OLD | NEW |