OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/syncable/directory.h" | 5 #include "sync/syncable/directory.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 } | 1491 } |
1492 } | 1492 } |
1493 | 1493 |
1494 void Directory::UnmarkDirtyEntry(WriteTransaction* trans, Entry* entry) { | 1494 void Directory::UnmarkDirtyEntry(WriteTransaction* trans, Entry* entry) { |
1495 CHECK(trans); | 1495 CHECK(trans); |
1496 entry->kernel_->clear_dirty(&kernel_->dirty_metahandles); | 1496 entry->kernel_->clear_dirty(&kernel_->dirty_metahandles); |
1497 } | 1497 } |
1498 | 1498 |
1499 void Directory::GetAttachmentIdsToUpload(BaseTransaction* trans, | 1499 void Directory::GetAttachmentIdsToUpload(BaseTransaction* trans, |
1500 ModelType type, | 1500 ModelType type, |
1501 AttachmentIdSet* id_set) { | 1501 AttachmentIdList* ids) { |
1502 // TODO(maniscalco): Maintain an index by ModelType and rewrite this method to | 1502 // TODO(maniscalco): Maintain an index by ModelType and rewrite this method to |
1503 // use it. The approach below is likely very expensive because it iterates | 1503 // use it. The approach below is likely very expensive because it iterates |
1504 // all entries (bug 415199). | 1504 // all entries (bug 415199). |
1505 DCHECK(trans); | 1505 DCHECK(trans); |
1506 DCHECK(id_set); | 1506 DCHECK(ids); |
1507 id_set->clear(); | 1507 ids->clear(); |
1508 AttachmentIdSet on_server_id_set; | 1508 AttachmentIdSet on_server_id_set; |
1509 AttachmentIdSet not_on_server_id_set; | 1509 AttachmentIdSet not_on_server_id_set; |
1510 std::vector<int64> metahandles; | 1510 std::vector<int64> metahandles; |
1511 { | 1511 { |
1512 ScopedKernelLock lock(this); | 1512 ScopedKernelLock lock(this); |
1513 GetMetaHandlesOfType(lock, trans, type, &metahandles); | 1513 GetMetaHandlesOfType(lock, trans, type, &metahandles); |
1514 std::vector<int64>::const_iterator iter = metahandles.begin(); | 1514 std::vector<int64>::const_iterator iter = metahandles.begin(); |
1515 const std::vector<int64>::const_iterator end = metahandles.end(); | 1515 const std::vector<int64>::const_iterator end = metahandles.end(); |
1516 // For all of this type's entries... | 1516 // For all of this type's entries... |
1517 for (; iter != end; ++iter) { | 1517 for (; iter != end; ++iter) { |
(...skipping 18 matching lines...) Expand all Loading... |
1536 } | 1536 } |
1537 // Why did we bother keeping a set of ids known to be on the server? The | 1537 // Why did we bother keeping a set of ids known to be on the server? The |
1538 // is_on_server flag is stored denormalized so we can end up with two entries | 1538 // is_on_server flag is stored denormalized so we can end up with two entries |
1539 // with the same attachment id where one says it's on the server and the other | 1539 // with the same attachment id where one says it's on the server and the other |
1540 // says it's not. When this happens, we trust the one that says it's on the | 1540 // says it's not. When this happens, we trust the one that says it's on the |
1541 // server. To avoid re-uploading the same attachment mulitple times, we | 1541 // server. To avoid re-uploading the same attachment mulitple times, we |
1542 // remove any ids known to be on the server from the id_set we are about to | 1542 // remove any ids known to be on the server from the id_set we are about to |
1543 // return. | 1543 // return. |
1544 // | 1544 // |
1545 // TODO(maniscalco): Eliminate redundant metadata storage (bug 415203). | 1545 // TODO(maniscalco): Eliminate redundant metadata storage (bug 415203). |
1546 std::set_difference(not_on_server_id_set.begin(), | 1546 std::set_difference(not_on_server_id_set.begin(), not_on_server_id_set.end(), |
1547 not_on_server_id_set.end(), | 1547 on_server_id_set.begin(), on_server_id_set.end(), |
1548 on_server_id_set.begin(), | 1548 std::back_inserter(*ids)); |
1549 on_server_id_set.end(), | |
1550 std::inserter(*id_set, id_set->end())); | |
1551 } | 1549 } |
1552 | 1550 |
1553 } // namespace syncable | 1551 } // namespace syncable |
1554 } // namespace syncer | 1552 } // namespace syncer |
OLD | NEW |