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_file_system/drive_file_sync_service.h" | 5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 else | 1355 else |
1356 file_type = fileapi::SYNC_FILE_TYPE_FILE; | 1356 file_type = fileapi::SYNC_FILE_TYPE_FILE; |
1357 } | 1357 } |
1358 | 1358 |
1359 fileapi::FileChange file_change(change_type, file_type); | 1359 fileapi::FileChange file_change(change_type, file_type); |
1360 | 1360 |
1361 std::pair<PendingChangeQueue::iterator, bool> inserted_to_queue = | 1361 std::pair<PendingChangeQueue::iterator, bool> inserted_to_queue = |
1362 pending_changes_.insert(ChangeQueueItem(changestamp, sync_type, url)); | 1362 pending_changes_.insert(ChangeQueueItem(changestamp, sync_type, url)); |
1363 DCHECK(inserted_to_queue.second); | 1363 DCHECK(inserted_to_queue.second); |
1364 | 1364 |
| 1365 DVLOG(3) << "Append remote change: " << path.value() |
| 1366 << "@" << changestamp << " " |
| 1367 << file_change.DebugString(); |
| 1368 |
1365 (*path_to_change)[path] = RemoteChange( | 1369 (*path_to_change)[path] = RemoteChange( |
1366 changestamp, entry.resource_id(), url, file_change, | 1370 changestamp, entry.resource_id(), url, file_change, |
1367 inserted_to_queue.first); | 1371 inserted_to_queue.first); |
1368 return true; | 1372 return true; |
1369 } | 1373 } |
1370 | 1374 |
1371 void DriveFileSyncService::RemoveRemoteChange( | 1375 void DriveFileSyncService::RemoveRemoteChange( |
1372 const fileapi::FileSystemURL& url) { | 1376 const fileapi::FileSystemURL& url) { |
1373 URLToChange::iterator found_origin = url_to_change_.find(url.origin()); | 1377 URLToChange::iterator found_origin = url_to_change_.find(url.origin()); |
1374 if (found_origin == url_to_change_.end()) | 1378 if (found_origin == url_to_change_.end()) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 scoped_ptr<google_apis::DocumentFeed> changes) { | 1442 scoped_ptr<google_apis::DocumentFeed> changes) { |
1439 if (error != google_apis::HTTP_SUCCESS) { | 1443 if (error != google_apis::HTTP_SUCCESS) { |
1440 NotifyTaskDone(GDataErrorCodeToSyncStatusCodeWrapper(error), token.Pass()); | 1444 NotifyTaskDone(GDataErrorCodeToSyncStatusCodeWrapper(error), token.Pass()); |
1441 return; | 1445 return; |
1442 } | 1446 } |
1443 | 1447 |
1444 typedef ScopedVector<google_apis::DocumentEntry>::const_iterator iterator; | 1448 typedef ScopedVector<google_apis::DocumentEntry>::const_iterator iterator; |
1445 for (iterator itr = changes->entries().begin(); | 1449 for (iterator itr = changes->entries().begin(); |
1446 itr != changes->entries().end(); ++itr) { | 1450 itr != changes->entries().end(); ++itr) { |
1447 const google_apis::DocumentEntry& entry = **itr; | 1451 const google_apis::DocumentEntry& entry = **itr; |
1448 DVLOG(3) << " change:" << entry.title(); | |
1449 GURL origin; | 1452 GURL origin; |
1450 if (!GetOriginForEntry(entry, &origin)) | 1453 if (!GetOriginForEntry(entry, &origin)) |
1451 continue; | 1454 continue; |
1452 | 1455 |
1453 has_new_changes = has_new_changes || | 1456 DVLOG(3) << " * change:" << entry.title() |
| 1457 << (entry.deleted() ? " (deleted)" : " ") |
| 1458 << "[" << origin.spec() << "]"; |
| 1459 has_new_changes = |
1454 AppendNewRemoteChange(origin, entry, entry.changestamp(), | 1460 AppendNewRemoteChange(origin, entry, entry.changestamp(), |
1455 REMOTE_SYNC_TYPE_INCREMENTAL); | 1461 REMOTE_SYNC_TYPE_INCREMENTAL) || has_new_changes; |
1456 } | 1462 } |
1457 | 1463 |
1458 GURL next_feed; | 1464 GURL next_feed; |
1459 if (changes->GetNextFeedURL(&next_feed)) { | 1465 if (changes->GetNextFeedURL(&next_feed)) { |
1460 sync_client_->ContinueListing( | 1466 sync_client_->ContinueListing( |
1461 next_feed, | 1467 next_feed, |
1462 base::Bind(&DriveFileSyncService::DidFetchChangesForIncrementalSync, | 1468 base::Bind(&DriveFileSyncService::DidFetchChangesForIncrementalSync, |
1463 AsWeakPtr(), base::Passed(&token), has_new_changes)); | 1469 AsWeakPtr(), base::Passed(&token), has_new_changes)); |
1464 return; | 1470 return; |
1465 } | 1471 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 fileapi::SyncStatusCode | 1539 fileapi::SyncStatusCode |
1534 DriveFileSyncService::GDataErrorCodeToSyncStatusCodeWrapper( | 1540 DriveFileSyncService::GDataErrorCodeToSyncStatusCodeWrapper( |
1535 google_apis::GDataErrorCode error) const { | 1541 google_apis::GDataErrorCode error) const { |
1536 fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); | 1542 fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); |
1537 if (status != fileapi::SYNC_STATUS_OK && !sync_client_->IsAuthenticated()) | 1543 if (status != fileapi::SYNC_STATUS_OK && !sync_client_->IsAuthenticated()) |
1538 return fileapi::SYNC_STATUS_AUTHENTICATION_FAILED; | 1544 return fileapi::SYNC_STATUS_AUTHENTICATION_FAILED; |
1539 return status; | 1545 return status; |
1540 } | 1546 } |
1541 | 1547 |
1542 } // namespace sync_file_system | 1548 } // namespace sync_file_system |
OLD | NEW |