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 #include "sync/internal_api/public/base/unique_position.h" | 5 #include "sync/internal_api/public/base/unique_position.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 : cache_guid_(cache_guid), | 385 : cache_guid_(cache_guid), |
386 next_id_(-65535) { | 386 next_id_(-65535) { |
387 } | 387 } |
388 | 388 |
389 std::string NextSuffix() { | 389 std::string NextSuffix() { |
390 // This is not entirely realistic, but that should be OK. The current | 390 // This is not entirely realistic, but that should be OK. The current |
391 // suffix format is a base64'ed SHA1 hash, which should be fairly close to | 391 // suffix format is a base64'ed SHA1 hash, which should be fairly close to |
392 // random anyway. | 392 // random anyway. |
393 std::string input = cache_guid_ + base::Int64ToString(next_id_--); | 393 std::string input = cache_guid_ + base::Int64ToString(next_id_--); |
394 std::string output; | 394 std::string output; |
395 CHECK(base::Base64Encode(base::SHA1HashString(input), &output)); | 395 base::Base64Encode(base::SHA1HashString(input), &output); |
396 return output; | 396 return output; |
397 } | 397 } |
398 | 398 |
399 private: | 399 private: |
400 const std::string cache_guid_; | 400 const std::string cache_guid_; |
401 int64 next_id_; | 401 int64 next_id_; |
402 }; | 402 }; |
403 | 403 |
404 // Cache guids generated in the same style as real clients. | 404 // Cache guids generated in the same style as real clients. |
405 static const char kCacheGuidStr1[] = "tuiWdG8hV+8y4RT9N5Aikg=="; | 405 static const char kCacheGuidStr1[] = "tuiWdG8hV+8y4RT9N5Aikg=="; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 // This requires values in the test harness to be hard-coded in ascending order. | 671 // This requires values in the test harness to be hard-coded in ascending order. |
672 TEST_F(CompressedPositionTest, OrderingTest) { | 672 TEST_F(CompressedPositionTest, OrderingTest) { |
673 for (size_t i = 0; i < positions_.size()-1; ++i) { | 673 for (size_t i = 0; i < positions_.size()-1; ++i) { |
674 EXPECT_PRED_FORMAT2(LessThan, positions_[i], positions_[i+1]); | 674 EXPECT_PRED_FORMAT2(LessThan, positions_[i], positions_[i+1]); |
675 } | 675 } |
676 } | 676 } |
677 | 677 |
678 } // namespace | 678 } // namespace |
679 | 679 |
680 } // namespace syncer | 680 } // namespace syncer |
OLD | NEW |