| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/sync/syncable/syncable_id.h" | 5 #include "chrome/browser/sync/syncable/syncable_id.h" |
| 6 | 6 |
| 7 #include <iosfwd> | 7 #include <iosfwd> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 using browser_sync::FastDump; | 23 using browser_sync::FastDump; |
| 24 FastDump& operator << (FastDump& dump, const syncable::Id& id) { | 24 FastDump& operator << (FastDump& dump, const syncable::Id& id) { |
| 25 dump.out_->sputn(id.s_.data(), id.s_.size()); | 25 dump.out_->sputn(id.s_.data(), id.s_.size()); |
| 26 return dump; | 26 return dump; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace syncable { | 29 namespace syncable { |
| 30 | 30 |
| 31 string Id::AsQueryParam() const { | |
| 32 if ('s' == s_[0]) | |
| 33 return s_.c_str() + 1; | |
| 34 return ""; | |
| 35 } | |
| 36 | |
| 37 string Id::GetServerId() const { | 31 string Id::GetServerId() const { |
| 38 // Currently root is the string "0". We need to decide on a true value. | 32 // Currently root is the string "0". We need to decide on a true value. |
| 39 // "" would be convenient here, as the IsRoot call would not be needed. | 33 // "" would be convenient here, as the IsRoot call would not be needed. |
| 40 if (IsRoot()) | 34 if (IsRoot()) |
| 41 return "0"; | 35 return "0"; |
| 42 return s_.substr(1); | 36 return s_.substr(1); |
| 43 } | 37 } |
| 44 | 38 |
| 45 Id Id::CreateFromServerId(const string& server_id) { | 39 Id Id::CreateFromServerId(const string& server_id) { |
| 46 Id id; | 40 Id id; |
| 47 if (server_id == "0") | 41 if (server_id == "0") |
| 48 id.s_ = "r"; | 42 id.s_ = "r"; |
| 49 else | 43 else |
| 50 id.s_ = string("s") + server_id; | 44 id.s_ = string("s") + server_id; |
| 51 return id; | 45 return id; |
| 52 } | 46 } |
| 53 | 47 |
| 54 Id Id::CreateFromClientString(const string& local_id) { | 48 Id Id::CreateFromClientString(const string& local_id) { |
| 55 Id id; | 49 Id id; |
| 56 if (local_id == "0") | 50 if (local_id == "0") |
| 57 id.s_ = "r"; | 51 id.s_ = "r"; |
| 58 else | 52 else |
| 59 id.s_ = string("c") + local_id; | 53 id.s_ = string("c") + local_id; |
| 60 return id; | 54 return id; |
| 61 } | 55 } |
| 62 | 56 |
| 63 } // namespace syncable | 57 } // namespace syncable |
| OLD | NEW |