Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_SYNC_API_ENTITY_DATA_H_ | 5 #ifndef COMPONENTS_SYNC_API_ENTITY_DATA_H_ |
| 6 #define COMPONENTS_SYNC_API_ENTITY_DATA_H_ | 6 #define COMPONENTS_SYNC_API_ENTITY_DATA_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "base/values.h" | |
| 14 #include "components/sync/base/proto_value_ptr.h" | 15 #include "components/sync/base/proto_value_ptr.h" |
| 15 #include "components/sync/protocol/sync.pb.h" | 16 #include "components/sync/protocol/sync.pb.h" |
| 16 | 17 |
| 17 namespace syncer_v2 { | 18 namespace syncer_v2 { |
| 18 | 19 |
| 19 struct EntityData; | 20 struct EntityData; |
| 20 | 21 |
| 21 struct EntityDataTraits { | 22 struct EntityDataTraits { |
| 22 static void SwapValue(EntityData* dest, EntityData* src); | 23 static void SwapValue(EntityData* dest, EntityData* src); |
| 23 static bool HasValue(const EntityData& value); | 24 static bool HasValue(const EntityData& value); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 68 |
| 68 // True if EntityData represents deleted entity; otherwise false. | 69 // True if EntityData represents deleted entity; otherwise false. |
| 69 // Note that EntityData would be considered to represent a deletion if its | 70 // Note that EntityData would be considered to represent a deletion if its |
| 70 // specifics hasn't been set. | 71 // specifics hasn't been set. |
| 71 bool is_deleted() const { return specifics.ByteSize() == 0; } | 72 bool is_deleted() const { return specifics.ByteSize() == 0; } |
| 72 | 73 |
| 73 // Transfers this struct's data to EntityDataPtr. | 74 // Transfers this struct's data to EntityDataPtr. |
| 74 // The return value must be assigned into another EntityDataPtr. | 75 // The return value must be assigned into another EntityDataPtr. |
| 75 EntityDataPtr PassToPtr() WARN_UNUSED_RESULT; | 76 EntityDataPtr PassToPtr() WARN_UNUSED_RESULT; |
| 76 | 77 |
| 78 // Dumps all info into a DictionaryValue and returns it. | |
| 79 static std::unique_ptr<base::DictionaryValue> ToValue( | |
|
skym
2016/09/12 16:40:38
Kinda odd that ToValue returns a DictionaryValue,
pavely
2016/09/12 20:43:04
ToValue shouldn't be static. It is always called w
Gang Wu
2016/09/12 22:38:03
got this name from proto_value_conversions.cc, mos
Gang Wu
2016/09/12 22:38:03
Done.
| |
| 80 const EntityData& entity_data); | |
| 81 | |
| 77 private: | 82 private: |
| 78 friend struct EntityDataTraits; | 83 friend struct EntityDataTraits; |
| 79 // Used to transfer the data without copying. | 84 // Used to transfer the data without copying. |
| 80 void Swap(EntityData* other); | 85 void Swap(EntityData* other); |
| 81 | 86 |
| 82 DISALLOW_COPY_AND_ASSIGN(EntityData); | 87 DISALLOW_COPY_AND_ASSIGN(EntityData); |
| 83 }; | 88 }; |
| 84 | 89 |
| 85 } // namespace syncer_v2 | 90 } // namespace syncer_v2 |
| 86 | 91 |
| 87 #endif // COMPONENTS_SYNC_API_ENTITY_DATA_H_ | 92 #endif // COMPONENTS_SYNC_API_ENTITY_DATA_H_ |
| OLD | NEW |