| 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 "chrome/browser/sync/syncable/syncable.h" | 5 #include "chrome/browser/sync/syncable/syncable.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 // PlatformThread::Delegate methods: | 1541 // PlatformThread::Delegate methods: |
| 1542 virtual void ThreadMain() { | 1542 virtual void ThreadMain() { |
| 1543 int entry_count = 0; | 1543 int entry_count = 0; |
| 1544 std::string path_name; | 1544 std::string path_name; |
| 1545 | 1545 |
| 1546 for (int i = 0; i < 20; ++i) { | 1546 for (int i = 0; i < 20; ++i) { |
| 1547 const int rand_action = rand() % 10; | 1547 const int rand_action = rand() % 10; |
| 1548 if (rand_action < 4 && !path_name.empty()) { | 1548 if (rand_action < 4 && !path_name.empty()) { |
| 1549 ReadTransaction trans(FROM_HERE, dir_); | 1549 ReadTransaction trans(FROM_HERE, dir_); |
| 1550 CHECK(1 == CountEntriesWithName(&trans, trans.root_id(), path_name)); | 1550 CHECK(1 == CountEntriesWithName(&trans, trans.root_id(), path_name)); |
| 1551 base::PlatformThread::Sleep(rand() % 10); | 1551 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( |
| 1552 rand() % 10)); |
| 1552 } else { | 1553 } else { |
| 1553 std::string unique_name = | 1554 std::string unique_name = |
| 1554 base::StringPrintf("%d.%d", thread_number_, entry_count++); | 1555 base::StringPrintf("%d.%d", thread_number_, entry_count++); |
| 1555 path_name.assign(unique_name.begin(), unique_name.end()); | 1556 path_name.assign(unique_name.begin(), unique_name.end()); |
| 1556 WriteTransaction trans(FROM_HERE, UNITTEST, dir_); | 1557 WriteTransaction trans(FROM_HERE, UNITTEST, dir_); |
| 1557 MutableEntry e(&trans, CREATE, trans.root_id(), path_name); | 1558 MutableEntry e(&trans, CREATE, trans.root_id(), path_name); |
| 1558 CHECK(e.good()); | 1559 CHECK(e.good()); |
| 1559 base::PlatformThread::Sleep(rand() % 20); | 1560 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( |
| 1561 rand() % 20)); |
| 1560 e.Put(IS_UNSYNCED, true); | 1562 e.Put(IS_UNSYNCED, true); |
| 1561 if (e.Put(ID, TestIdFactory::FromNumber(rand())) && | 1563 if (e.Put(ID, TestIdFactory::FromNumber(rand())) && |
| 1562 e.Get(ID).ServerKnows() && !e.Get(ID).IsRoot()) { | 1564 e.Get(ID).ServerKnows() && !e.Get(ID).IsRoot()) { |
| 1563 e.Put(BASE_VERSION, 1); | 1565 e.Put(BASE_VERSION, 1); |
| 1564 } | 1566 } |
| 1565 } | 1567 } |
| 1566 } | 1568 } |
| 1567 } | 1569 } |
| 1568 | 1570 |
| 1569 DISALLOW_COPY_AND_ASSIGN(StressTransactionsDelegate); | 1571 DISALLOW_COPY_AND_ASSIGN(StressTransactionsDelegate); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { | 1692 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { |
| 1691 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 1693 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
| 1692 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 1694 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
| 1693 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); | 1695 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); |
| 1694 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); | 1696 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); |
| 1695 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); | 1697 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); |
| 1696 } | 1698 } |
| 1697 | 1699 |
| 1698 } // namespace | 1700 } // namespace |
| 1699 } // namespace syncable | 1701 } // namespace syncable |
| OLD | NEW |