| 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 // A tool making it easier to create IDs for unit testing. | 5 // A tool making it easier to create IDs for unit testing. |
| 6 | 6 |
| 7 #ifndef SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ | 7 #ifndef SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ |
| 8 #define SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ | 8 #define SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 static syncable::Id FromNumber(int64 value) { | 29 static syncable::Id FromNumber(int64 value) { |
| 30 if (value == 0) | 30 if (value == 0) |
| 31 return root(); | 31 return root(); |
| 32 else if (value < 0) | 32 else if (value < 0) |
| 33 return syncable::Id::CreateFromClientString(base::Int64ToString(value)); | 33 return syncable::Id::CreateFromClientString(base::Int64ToString(value)); |
| 34 else | 34 else |
| 35 return syncable::Id::CreateFromServerId(base::Int64ToString(value)); | 35 return syncable::Id::CreateFromServerId(base::Int64ToString(value)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Create a local ID from a name. | 38 // Create a local ID from a name. |
| 39 static syncable::Id MakeLocal(std::string name) { | 39 static syncable::Id MakeLocal(const std::string& name) { |
| 40 return syncable::Id::CreateFromClientString(std::string("lient ") + name); | 40 return syncable::Id::CreateFromClientString(std::string("lient ") + name); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Create a server ID from a string name. | 43 // Create a server ID from a string name. |
| 44 static syncable::Id MakeServer(std::string name) { | 44 static syncable::Id MakeServer(const std::string& name) { |
| 45 return syncable::Id::CreateFromServerId(std::string("erver ") + name); | 45 return syncable::Id::CreateFromServerId(std::string("erver ") + name); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Autogenerate a fresh local ID. | 48 // Autogenerate a fresh local ID. |
| 49 syncable::Id NewLocalId() { | 49 syncable::Id NewLocalId() { |
| 50 return syncable::Id::CreateFromClientString( | 50 return syncable::Id::CreateFromClientString( |
| 51 std::string("_auto ") + base::IntToString(-next_value())); | 51 std::string("_auto ") + base::IntToString(-next_value())); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Autogenerate a fresh server ID. | 54 // Autogenerate a fresh server ID. |
| 55 syncable::Id NewServerId() { | 55 syncable::Id NewServerId() { |
| 56 return syncable::Id::CreateFromServerId( | 56 return syncable::Id::CreateFromServerId( |
| 57 std::string("_auto ") + base::IntToString(next_value())); | 57 std::string("_auto ") + base::IntToString(next_value())); |
| 58 } | 58 } |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 int next_value() { | 61 int next_value() { |
| 62 return next_value_++; | 62 return next_value_++; |
| 63 } | 63 } |
| 64 int next_value_; | 64 int next_value_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace syncer | 67 } // namespace syncer |
| 68 | 68 |
| 69 #endif // SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ | 69 #endif // SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ |
| 70 | 70 |
| OLD | NEW |