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/chromeos/drive/drive_feed_loader.cc

Issue 11348030: Revert 164876 - Set root resource ID upon full feed update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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
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/chromeos/drive/drive_feed_loader.h" 5 #include "chrome/browser/chromeos/drive/drive_feed_loader.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 scoped_ptr<google_apis::AboutResource> about_resource; 370 scoped_ptr<google_apis::AboutResource> about_resource;
371 if (feed_data.get()) 371 if (feed_data.get())
372 about_resource = google_apis::AboutResource::CreateFrom(*feed_data); 372 about_resource = google_apis::AboutResource::CreateFrom(*feed_data);
373 373
374 if (!about_resource.get()) { 374 if (!about_resource.get()) {
375 LoadFromServer(params.Pass()); 375 LoadFromServer(params.Pass());
376 return; 376 return;
377 } 377 }
378 378
379 int64 largest_changestamp = about_resource->largest_change_id(); 379 int64 largest_changestamp = about_resource->largest_change_id();
380 380 resource_metadata_->InitializeRootEntry(about_resource->root_folder_id());
381 // Copy the root resource ID for use in UpdateFromFeed().
382 params->root_resource_id = about_resource->root_folder_id();
383 DCHECK(!params->root_resource_id.empty());
384 381
385 if (local_changestamp >= largest_changestamp) { 382 if (local_changestamp >= largest_changestamp) {
386 if (local_changestamp > largest_changestamp) { 383 if (local_changestamp > largest_changestamp) {
387 LOG(WARNING) << "Cached client feed is fresher than server, client = " 384 LOG(WARNING) << "Cached client feed is fresher than server, client = "
388 << local_changestamp 385 << local_changestamp
389 << ", server = " 386 << ", server = "
390 << largest_changestamp; 387 << largest_changestamp;
391 } 388 }
392 389
393 // No changes detected, tell the client that the loading was successful. 390 // No changes detected, tell the client that the loading was successful.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 469
473 void DriveFeedLoader::OnFeedFromServerLoaded(scoped_ptr<LoadFeedParams> params, 470 void DriveFeedLoader::OnFeedFromServerLoaded(scoped_ptr<LoadFeedParams> params,
474 DriveFileError error) { 471 DriveFileError error) {
475 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 472 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
476 DCHECK(!params->load_finished_callback.is_null()); 473 DCHECK(!params->load_finished_callback.is_null());
477 DCHECK(refreshing_); 474 DCHECK(refreshing_);
478 475
479 if (error == DRIVE_FILE_OK) { 476 if (error == DRIVE_FILE_OK) {
480 UpdateFromFeed(params->feed_list, 477 UpdateFromFeed(params->feed_list,
481 params->start_changestamp, 478 params->start_changestamp,
482 params->root_feed_changestamp, 479 params->root_feed_changestamp);
483 params->root_resource_id);
484 } 480 }
485 refreshing_ = false; 481 refreshing_ = false;
486 482
487 if (error != DRIVE_FILE_OK) { 483 if (error != DRIVE_FILE_OK) {
488 params->load_finished_callback.Run(error); 484 params->load_finished_callback.Run(error);
489 return; 485 return;
490 } 486 }
491 487
492 // Save file system metadata to disk. 488 // Save file system metadata to disk.
493 SaveFileSystem(); 489 SaveFileSystem();
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 FROM_HERE, 841 FROM_HERE,
846 blocking_task_runner_, 842 blocking_task_runner_,
847 base::Bind(&SaveProtoOnBlockingPool, path, 843 base::Bind(&SaveProtoOnBlockingPool, path,
848 base::Passed(serialized_proto.Pass()))); 844 base::Passed(serialized_proto.Pass())));
849 } 845 }
850 } 846 }
851 847
852 void DriveFeedLoader::UpdateFromFeed( 848 void DriveFeedLoader::UpdateFromFeed(
853 const ScopedVector<google_apis::DocumentFeed>& feed_list, 849 const ScopedVector<google_apis::DocumentFeed>& feed_list,
854 int64 start_changestamp, 850 int64 start_changestamp,
855 int64 root_feed_changestamp, 851 int64 root_feed_changestamp) {
856 const std::string& root_resource_id) {
857 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 852 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
858 DVLOG(1) << "Updating directory with a feed"; 853 DVLOG(1) << "Updating directory with a feed";
859 854
860 std::set<FilePath> changed_dirs; 855 std::set<FilePath> changed_dirs;
861 856
862 if (start_changestamp == 0) {
863 // This is a full fetch and on full fetch the root has to be initialized
864 // before children are added by DriveFeedProcessor.
865 if (google_apis::util::IsDriveV2ApiEnabled()) {
866 DCHECK(!root_resource_id.empty());
867 resource_metadata_->InitializeRootEntry(root_resource_id);
868 } else {
869 // Use fixed root resource ID for WAPI.
870 resource_metadata_->InitializeRootEntry(kWAPIRootDirectoryResourceId);
871 }
872 }
873
874 DriveFeedProcessor feed_processor(resource_metadata_); 857 DriveFeedProcessor feed_processor(resource_metadata_);
875 feed_processor.ApplyFeeds( 858 feed_processor.ApplyFeeds(
876 feed_list, 859 feed_list,
877 start_changestamp, 860 start_changestamp,
878 root_feed_changestamp, 861 root_feed_changestamp,
879 &changed_dirs); 862 &changed_dirs);
880 863
881 // Don't send directory content change notification while performing 864 // Don't send directory content change notification while performing
882 // the initial content retrieval. 865 // the initial content retrieval.
883 const bool should_notify_directory_changed = (start_changestamp != 0); 866 const bool should_notify_directory_changed = (start_changestamp != 0);
884 if (should_notify_directory_changed) { 867 if (should_notify_directory_changed) {
885 for (std::set<FilePath>::iterator dir_iter = changed_dirs.begin(); 868 for (std::set<FilePath>::iterator dir_iter = changed_dirs.begin();
886 dir_iter != changed_dirs.end(); ++dir_iter) { 869 dir_iter != changed_dirs.end(); ++dir_iter) {
887 FOR_EACH_OBSERVER(DriveFeedLoaderObserver, observers_, 870 FOR_EACH_OBSERVER(DriveFeedLoaderObserver, observers_,
888 OnDirectoryChanged(*dir_iter)); 871 OnDirectoryChanged(*dir_iter));
889 } 872 }
890 } 873 }
891 } 874 }
892 875
893 } // namespace drive 876 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_feed_loader.h ('k') | chrome/browser/chromeos/drive/drive_file_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698