Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: components/sync/base/node_ordinal.h

Issue 2689773002: [Sync] Replace typedef with using. (Closed)
Patch Set: [Sync] Replace typedef with using. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/sync/base/model_type.h ('k') | components/sync/base/ordinal_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 COMPONENTS_SYNC_BASE_NODE_ORDINAL_H_ 5 #ifndef COMPONENTS_SYNC_BASE_NODE_ORDINAL_H_
6 #define COMPONENTS_SYNC_BASE_NODE_ORDINAL_H_ 6 #define COMPONENTS_SYNC_BASE_NODE_ORDINAL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "components/sync/base/ordinal.h" 11 #include "components/sync/base/ordinal.h"
12 12
13 namespace syncer { 13 namespace syncer {
14 14
15 // A NodeOrdinal is an Ordinal whose internal value comes from the 15 // A NodeOrdinal is an Ordinal whose internal value comes from the
16 // ordinal_in_parent field of SyncEntity (see sync.proto). It uses 16 // ordinal_in_parent field of SyncEntity (see sync.proto). It uses
17 // the entire uint8_t range for backwards compatibility with the old 17 // the entire uint8_t range for backwards compatibility with the old
18 // int64_t-based positioning. 18 // int64_t-based positioning.
19 19
20 struct NodeOrdinalTraits { 20 struct NodeOrdinalTraits {
21 static const uint8_t kZeroDigit = 0; 21 static const uint8_t kZeroDigit = 0;
22 static const uint8_t kMaxDigit = UINT8_MAX; 22 static const uint8_t kMaxDigit = UINT8_MAX;
23 static const size_t kMinLength = 8; 23 static const size_t kMinLength = 8;
24 }; 24 };
25 25
26 typedef Ordinal<NodeOrdinalTraits> NodeOrdinal; 26 using NodeOrdinal = Ordinal<NodeOrdinalTraits>;
27 27
28 static_assert(static_cast<char>(NodeOrdinal::kZeroDigit) == '\x00', 28 static_assert(static_cast<char>(NodeOrdinal::kZeroDigit) == '\x00',
29 "NodeOrdinal has incorrect zero digit"); 29 "NodeOrdinal has incorrect zero digit");
30 static_assert(static_cast<char>(NodeOrdinal::kOneDigit) == '\x01', 30 static_assert(static_cast<char>(NodeOrdinal::kOneDigit) == '\x01',
31 "NodeOrdinal has incorrect one digit"); 31 "NodeOrdinal has incorrect one digit");
32 static_assert(static_cast<char>(NodeOrdinal::kMidDigit) == '\x80', 32 static_assert(static_cast<char>(NodeOrdinal::kMidDigit) == '\x80',
33 "NodeOrdinal has incorrect mid digit"); 33 "NodeOrdinal has incorrect mid digit");
34 static_assert(static_cast<char>(NodeOrdinal::kMaxDigit) == '\xff', 34 static_assert(static_cast<char>(NodeOrdinal::kMaxDigit) == '\xff',
35 "NodeOrdinal has incorrect max digit"); 35 "NodeOrdinal has incorrect max digit");
36 static_assert(NodeOrdinal::kMidDigitValue == 128, 36 static_assert(NodeOrdinal::kMidDigitValue == 128,
(...skipping 10 matching lines...) Expand all
47 47
48 // The inverse of Int64ToNodeOrdinal. This conversion is, in general, 48 // The inverse of Int64ToNodeOrdinal. This conversion is, in general,
49 // lossy: NodeOrdinals can have arbitrary fidelity, while numeric 49 // lossy: NodeOrdinals can have arbitrary fidelity, while numeric
50 // positions contain only 64 bits of information (in fact, this is the 50 // positions contain only 64 bits of information (in fact, this is the
51 // reason we've moved away from them). 51 // reason we've moved away from them).
52 int64_t NodeOrdinalToInt64(const NodeOrdinal& ordinal); 52 int64_t NodeOrdinalToInt64(const NodeOrdinal& ordinal);
53 53
54 } // namespace syncer 54 } // namespace syncer
55 55
56 #endif // COMPONENTS_SYNC_BASE_NODE_ORDINAL_H_ 56 #endif // COMPONENTS_SYNC_BASE_NODE_ORDINAL_H_
OLDNEW
« no previous file with comments | « components/sync/base/model_type.h ('k') | components/sync/base/ordinal_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698