Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/sync_file_system/drive_file_sync_service.cc

Issue 15410005: Deprecate DriveMetadataStore.batch_sync_origins (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small test fixes. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_metadata_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 void DriveFileSyncService::DidInitializeMetadataStore( 375 void DriveFileSyncService::DidInitializeMetadataStore(
376 const SyncStatusCallback& callback, 376 const SyncStatusCallback& callback,
377 SyncStatusCode status, 377 SyncStatusCode status,
378 bool created) { 378 bool created) {
379 if (status != SYNC_STATUS_OK) { 379 if (status != SYNC_STATUS_OK) {
380 callback.Run(status); 380 callback.Run(status);
381 return; 381 return;
382 } 382 }
383 383
384 // TODO(calvinlo): Move the code to delete legacy batch_sync_origin keys from
385 // DB into DriveMetadataStore.InitializeDBOnFileThread.
386 std::vector<GURL> batch_origins_to_delete;
387 typedef std::map<GURL, std::string>::const_iterator origin_itr;
388 for (origin_itr itr = metadata_store_->batch_sync_origins().begin();
389 itr != metadata_store_->batch_sync_origins().end(); ++itr) {
390 batch_origins_to_delete.push_back(itr->first);
391 }
392 for (std::vector<GURL>::const_iterator itr = batch_origins_to_delete.begin();
393 itr != batch_origins_to_delete.end(); ++itr) {
394 metadata_store_->RemoveOrigin(*itr, base::Bind(&EmptyStatusCallback));
395 }
396
397 DCHECK(pending_batch_sync_origins_.empty()); 384 DCHECK(pending_batch_sync_origins_.empty());
398 385
399 UpdateRegisteredOrigins(); 386 UpdateRegisteredOrigins();
400 387
401 largest_fetched_changestamp_ = metadata_store_->GetLargestChangeStamp(); 388 largest_fetched_changestamp_ = metadata_store_->GetLargestChangeStamp();
402 389
403 DriveMetadataStore::URLAndDriveMetadataList to_be_fetched_files; 390 DriveMetadataStore::URLAndDriveMetadataList to_be_fetched_files;
404 status = metadata_store_->GetToBeFetchedFiles(&to_be_fetched_files); 391 status = metadata_store_->GetToBeFetchedFiles(&to_be_fetched_files);
405 DCHECK_EQ(SYNC_STATUS_OK, status); 392 DCHECK_EQ(SYNC_STATUS_OK, status);
406 typedef DriveMetadataStore::URLAndDriveMetadataList::const_iterator iterator; 393 typedef DriveMetadataStore::URLAndDriveMetadataList::const_iterator iterator;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 const FileChange& local_file_change, 595 const FileChange& local_file_change,
609 const base::FilePath& local_file_path, 596 const base::FilePath& local_file_path,
610 const SyncFileMetadata& local_file_metadata, 597 const SyncFileMetadata& local_file_metadata,
611 const FileSystemURL& url, 598 const FileSystemURL& url,
612 const SyncStatusCallback& callback) { 599 const SyncStatusCallback& callback) {
613 if (GetCurrentState() == REMOTE_SERVICE_DISABLED) { 600 if (GetCurrentState() == REMOTE_SERVICE_DISABLED) {
614 callback.Run(SYNC_STATUS_SYNC_DISABLED); 601 callback.Run(SYNC_STATUS_SYNC_DISABLED);
615 return; 602 return;
616 } 603 }
617 604
618 if (!metadata_store_->IsIncrementalSyncOrigin(url.origin()) && 605 if (!metadata_store_->IsIncrementalSyncOrigin(url.origin())) {
619 !metadata_store_->IsBatchSyncOrigin(url.origin())) {
620 // We may get called by LocalFileSyncService to sync local changes 606 // We may get called by LocalFileSyncService to sync local changes
621 // for the origins that are disabled. 607 // for the origins that are disabled.
622 DVLOG(1) << "Got request for stray origin: " << url.origin().spec(); 608 DVLOG(1) << "Got request for stray origin: " << url.origin().spec();
623 callback.Run(SYNC_STATUS_UNKNOWN_ORIGIN); 609 callback.Run(SYNC_STATUS_UNKNOWN_ORIGIN);
624 return; 610 return;
625 } 611 }
626 612
627 DCHECK(!running_local_sync_task_); 613 DCHECK(!running_local_sync_task_);
628 running_local_sync_task_.reset(new drive::LocalChangeProcessorDelegate( 614 running_local_sync_task_.reset(new drive::LocalChangeProcessorDelegate(
629 AsWeakPtr(), local_file_change, local_file_path, 615 AsWeakPtr(), local_file_change, local_file_path,
630 local_file_metadata, url)); 616 local_file_metadata, url));
631 running_local_sync_task_->Run(base::Bind( 617 running_local_sync_task_->Run(base::Bind(
632 &DriveFileSyncService::DidApplyLocalChange, AsWeakPtr(), callback)); 618 &DriveFileSyncService::DidApplyLocalChange, AsWeakPtr(), callback));
633 } 619 }
634 620
635 void DriveFileSyncService::UpdateRegisteredOrigins() { 621 void DriveFileSyncService::UpdateRegisteredOrigins() {
636 ExtensionService* extension_service = 622 ExtensionService* extension_service =
637 extensions::ExtensionSystem::Get(profile_)->extension_service(); 623 extensions::ExtensionSystem::Get(profile_)->extension_service();
638 DCHECK(pending_batch_sync_origins_.empty()); 624 DCHECK(pending_batch_sync_origins_.empty());
639 DCHECK(metadata_store_->batch_sync_origins().empty());
640 if (!extension_service) 625 if (!extension_service)
641 return; 626 return;
642 627
643 std::vector<GURL> origins; 628 std::vector<GURL> origins;
644 metadata_store_->GetAllOrigins(&origins); 629 metadata_store_->GetAllOrigins(&origins);
645 630
646 // Update the status of every origin using status from ExtensionService. 631 // Update the status of every origin using status from ExtensionService.
647 for (std::vector<GURL>::const_iterator itr = origins.begin(); 632 for (std::vector<GURL>::const_iterator itr = origins.begin();
648 itr != origins.end(); ++itr) { 633 itr != origins.end(); ++itr) {
649 std::string extension_id = itr->host(); 634 std::string extension_id = itr->host();
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 GURL origin; 1631 GURL origin;
1647 if (IsDriveAPIEnabled()) { 1632 if (IsDriveAPIEnabled()) {
1648 metadata_store_->GetOriginByOriginRootDirectoryId( 1633 metadata_store_->GetOriginByOriginRootDirectoryId(
1649 google_apis::drive::util::ExtractResourceIdFromUrl((*itr)->href()), 1634 google_apis::drive::util::ExtractResourceIdFromUrl((*itr)->href()),
1650 &origin); 1635 &origin);
1651 } else { 1636 } else {
1652 origin = drive::APIUtil::DirectoryTitleToOrigin((*itr)->title()); 1637 origin = drive::APIUtil::DirectoryTitleToOrigin((*itr)->title());
1653 } 1638 }
1654 DCHECK(origin.is_valid()); 1639 DCHECK(origin.is_valid());
1655 1640
1656 if (!metadata_store_->IsBatchSyncOrigin(origin) && 1641 if (!metadata_store_->IsIncrementalSyncOrigin(origin))
1657 !metadata_store_->IsIncrementalSyncOrigin(origin))
1658 continue; 1642 continue;
1659 std::string resource_id(metadata_store_->GetResourceIdForOrigin(origin)); 1643 std::string resource_id(metadata_store_->GetResourceIdForOrigin(origin));
1660 if (resource_id.empty()) 1644 if (resource_id.empty())
1661 continue; 1645 continue;
1662 GURL resource_link(api_util_->ResourceIdToResourceLink(resource_id)); 1646 GURL resource_link(api_util_->ResourceIdToResourceLink(resource_id));
1663 if ((*itr)->href().GetOrigin() != resource_link.GetOrigin() || 1647 if ((*itr)->href().GetOrigin() != resource_link.GetOrigin() ||
1664 (*itr)->href().path() != resource_link.path()) 1648 (*itr)->href().path() != resource_link.path())
1665 continue; 1649 continue;
1666 1650
1667 *origin_out = origin; 1651 *origin_out = origin;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 metadata_store_->SetOriginRootDirectory(origin, resource_id); 1734 metadata_store_->SetOriginRootDirectory(origin, resource_id);
1751 } 1735 }
1752 callback.Run(status, resource_id); 1736 callback.Run(status, resource_id);
1753 } 1737 }
1754 1738
1755 std::string DriveFileSyncService::sync_root_resource_id() { 1739 std::string DriveFileSyncService::sync_root_resource_id() {
1756 return metadata_store_->sync_root_directory(); 1740 return metadata_store_->sync_root_directory();
1757 } 1741 }
1758 1742
1759 } // namespace sync_file_system 1743 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_metadata_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698