| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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/engine/syncapi.h" | 5 #include "chrome/browser/sync/engine/syncapi.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1570 &ordered_changes[0], ordered_changes.size()); | 1570 &ordered_changes[0], ordered_changes.size()); |
| 1571 } | 1571 } |
| 1572 change_buffers_[i].Clear(); | 1572 change_buffers_[i].Clear(); |
| 1573 } | 1573 } |
| 1574 } | 1574 } |
| 1575 | 1575 |
| 1576 void SyncManager::SyncInternal::HandleCalculateChangesChangeEventFromSyncApi( | 1576 void SyncManager::SyncInternal::HandleCalculateChangesChangeEventFromSyncApi( |
| 1577 const syncable::DirectoryChangeEvent& event) { | 1577 const syncable::DirectoryChangeEvent& event) { |
| 1578 // We have been notified about a user action changing the bookmark model. | 1578 // We have been notified about a user action changing the bookmark model. |
| 1579 DCHECK_EQ(event.todo, syncable::DirectoryChangeEvent::CALCULATE_CHANGES); | 1579 DCHECK_EQ(event.todo, syncable::DirectoryChangeEvent::CALCULATE_CHANGES); |
| 1580 DCHECK_EQ(event.writer, syncable::SYNCAPI); | 1580 DCHECK(event.writer == syncable::SYNCAPI || |
| 1581 event.writer == syncable::UNITTEST); |
| 1581 LOG_IF(WARNING, !ChangeBuffersAreEmpty()) << | 1582 LOG_IF(WARNING, !ChangeBuffersAreEmpty()) << |
| 1582 "CALCULATE_CHANGES called with unapplied old changes."; | 1583 "CALCULATE_CHANGES called with unapplied old changes."; |
| 1583 | 1584 |
| 1584 bool exists_unsynced_items = false; | 1585 bool exists_unsynced_items = false; |
| 1585 for (syncable::OriginalEntries::const_iterator i = event.originals->begin(); | 1586 for (syncable::OriginalEntries::const_iterator i = event.originals->begin(); |
| 1586 i != event.originals->end() && !exists_unsynced_items; | 1587 i != event.originals->end() && !exists_unsynced_items; |
| 1587 ++i) { | 1588 ++i) { |
| 1588 int64 id = i->ref(syncable::META_HANDLE); | 1589 int64 id = i->ref(syncable::META_HANDLE); |
| 1589 syncable::Entry e(event.trans, syncable::GET_BY_HANDLE, id); | 1590 syncable::Entry e(event.trans, syncable::GET_BY_HANDLE, id); |
| 1590 DCHECK(e.good()); | 1591 DCHECK(e.good()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1604 if (exists_unsynced_items && syncer_thread()) { | 1605 if (exists_unsynced_items && syncer_thread()) { |
| 1605 syncer_thread()->NudgeSyncer(200, SyncerThread::kLocal); // 1/5 a second. | 1606 syncer_thread()->NudgeSyncer(200, SyncerThread::kLocal); // 1/5 a second. |
| 1606 } | 1607 } |
| 1607 } | 1608 } |
| 1608 | 1609 |
| 1609 void SyncManager::SyncInternal::HandleCalculateChangesChangeEventFromSyncer( | 1610 void SyncManager::SyncInternal::HandleCalculateChangesChangeEventFromSyncer( |
| 1610 const syncable::DirectoryChangeEvent& event) { | 1611 const syncable::DirectoryChangeEvent& event) { |
| 1611 // We only expect one notification per sync step, so change_buffers_ should | 1612 // We only expect one notification per sync step, so change_buffers_ should |
| 1612 // contain no pending entries. | 1613 // contain no pending entries. |
| 1613 DCHECK_EQ(event.todo, syncable::DirectoryChangeEvent::CALCULATE_CHANGES); | 1614 DCHECK_EQ(event.todo, syncable::DirectoryChangeEvent::CALCULATE_CHANGES); |
| 1614 DCHECK_EQ(event.writer, syncable::SYNCER); | 1615 DCHECK(event.writer == syncable::SYNCER || |
| 1616 event.writer == syncable::UNITTEST); |
| 1615 LOG_IF(WARNING, !ChangeBuffersAreEmpty()) << | 1617 LOG_IF(WARNING, !ChangeBuffersAreEmpty()) << |
| 1616 "CALCULATE_CHANGES called with unapplied old changes."; | 1618 "CALCULATE_CHANGES called with unapplied old changes."; |
| 1617 | 1619 |
| 1618 for (syncable::OriginalEntries::const_iterator i = event.originals->begin(); | 1620 for (syncable::OriginalEntries::const_iterator i = event.originals->begin(); |
| 1619 i != event.originals->end(); ++i) { | 1621 i != event.originals->end(); ++i) { |
| 1620 int64 id = i->ref(syncable::META_HANDLE); | 1622 int64 id = i->ref(syncable::META_HANDLE); |
| 1621 syncable::Entry e(event.trans, syncable::GET_BY_HANDLE, id); | 1623 syncable::Entry e(event.trans, syncable::GET_BY_HANDLE, id); |
| 1622 bool existed_before = !i->ref(syncable::IS_DEL); | 1624 bool existed_before = !i->ref(syncable::IS_DEL); |
| 1623 bool exists_now = e.good() && !e.Get(syncable::IS_DEL); | 1625 bool exists_now = e.good() && !e.Get(syncable::IS_DEL); |
| 1624 DCHECK(e.good()); | 1626 DCHECK(e.good()); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 BaseTransaction::~BaseTransaction() { | 1890 BaseTransaction::~BaseTransaction() { |
| 1889 delete lookup_; | 1891 delete lookup_; |
| 1890 } | 1892 } |
| 1891 | 1893 |
| 1892 UserShare* SyncManager::GetUserShare() const { | 1894 UserShare* SyncManager::GetUserShare() const { |
| 1893 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; | 1895 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; |
| 1894 return data_->GetUserShare(); | 1896 return data_->GetUserShare(); |
| 1895 } | 1897 } |
| 1896 | 1898 |
| 1897 } // namespace sync_api | 1899 } // namespace sync_api |
| OLD | NEW |