Chromium Code Reviews| 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/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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 if (feed_data.get()) | 374 if (feed_data.get()) |
| 375 about_resource = google_apis::AboutResource::CreateFrom(*feed_data); | 375 about_resource = google_apis::AboutResource::CreateFrom(*feed_data); |
| 376 | 376 |
| 377 if (!about_resource.get()) { | 377 if (!about_resource.get()) { |
| 378 LoadFromServer(params.Pass()); | 378 LoadFromServer(params.Pass()); |
| 379 return; | 379 return; |
| 380 } | 380 } |
| 381 | 381 |
| 382 bool changes_detected = true; | 382 bool changes_detected = true; |
| 383 int64 largest_changestamp = about_resource->largest_change_id(); | 383 int64 largest_changestamp = about_resource->largest_change_id(); |
| 384 resource_metadata_->InitializeRootEntry(about_resource->root_folder_id()); | 384 |
| 385 // Copy the root resource ID for use in UpdateFromFeed(). | |
| 386 params->root_resource_id = about_resource->root_folder_id(); | |
| 387 DCHECK(!params->root_resource_id.empty()); | |
| 385 | 388 |
| 386 if (local_changestamp >= largest_changestamp) { | 389 if (local_changestamp >= largest_changestamp) { |
| 387 if (local_changestamp > largest_changestamp) { | 390 if (local_changestamp > largest_changestamp) { |
| 388 LOG(WARNING) << "Cached client feed is fresher than server, client = " | 391 LOG(WARNING) << "Cached client feed is fresher than server, client = " |
| 389 << local_changestamp | 392 << local_changestamp |
| 390 << ", server = " | 393 << ", server = " |
| 391 << largest_changestamp; | 394 << largest_changestamp; |
| 392 } | 395 } |
| 393 // If our cache holds the latest state from the server, change the | 396 // If our cache holds the latest state from the server, change the |
| 394 // state to FROM_SERVER. | 397 // state to FROM_SERVER. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 490 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 488 | 491 |
| 489 if (error != DRIVE_FILE_OK) { | 492 if (error != DRIVE_FILE_OK) { |
| 490 if (!params->load_finished_callback.is_null()) | 493 if (!params->load_finished_callback.is_null()) |
| 491 params->load_finished_callback.Run(error); | 494 params->load_finished_callback.Run(error); |
| 492 return; | 495 return; |
| 493 } | 496 } |
| 494 | 497 |
| 495 UpdateFromFeed(params->feed_list, | 498 UpdateFromFeed(params->feed_list, |
| 496 params->start_changestamp, | 499 params->start_changestamp, |
| 497 params->root_feed_changestamp); | 500 params->root_feed_changestamp, |
| 501 params->root_resource_id); | |
| 498 | 502 |
| 499 // Save file system metadata to disk. | 503 // Save file system metadata to disk. |
| 500 SaveFileSystem(); | 504 SaveFileSystem(); |
| 501 | 505 |
| 502 // Tell the client that the loading was successful. | 506 // Tell the client that the loading was successful. |
| 503 if (!params->load_finished_callback.is_null()) | 507 if (!params->load_finished_callback.is_null()) |
| 504 params->load_finished_callback.Run(DRIVE_FILE_OK); | 508 params->load_finished_callback.Run(DRIVE_FILE_OK); |
| 505 | 509 |
| 506 FOR_EACH_OBSERVER(DriveFeedLoaderObserver, | 510 FOR_EACH_OBSERVER(DriveFeedLoaderObserver, |
| 507 observers_, | 511 observers_, |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 880 FROM_HERE, | 884 FROM_HERE, |
| 881 blocking_task_runner_, | 885 blocking_task_runner_, |
| 882 base::Bind(&SaveProtoOnBlockingPool, path, | 886 base::Bind(&SaveProtoOnBlockingPool, path, |
| 883 base::Passed(serialized_proto.Pass()))); | 887 base::Passed(serialized_proto.Pass()))); |
| 884 } | 888 } |
| 885 } | 889 } |
| 886 | 890 |
| 887 void DriveFeedLoader::UpdateFromFeed( | 891 void DriveFeedLoader::UpdateFromFeed( |
| 888 const ScopedVector<google_apis::DocumentFeed>& feed_list, | 892 const ScopedVector<google_apis::DocumentFeed>& feed_list, |
| 889 int64 start_changestamp, | 893 int64 start_changestamp, |
| 890 int64 root_feed_changestamp) { | 894 int64 root_feed_changestamp, |
| 895 const std::string& root_resource_id) { | |
| 891 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 896 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 892 DVLOG(1) << "Updating directory with a feed"; | 897 DVLOG(1) << "Updating directory with a feed"; |
| 893 | 898 |
| 894 std::set<FilePath> changed_dirs; | 899 std::set<FilePath> changed_dirs; |
| 895 | 900 |
| 901 if (start_changestamp == 0) { | |
|
satorux1
2012/10/26 06:14:36
{ // full fetch
kochi
2012/10/26 07:35:42
Added a bit more descriptive comment.
Please take
| |
| 902 if (google_apis::util::IsDriveV2ApiEnabled()) { | |
| 903 DCHECK(!root_resource_id.empty()); | |
| 904 resource_metadata_->SetRootResourceId(root_resource_id); | |
| 905 } else { | |
| 906 // Use fixed root resource ID for WAPI. | |
| 907 resource_metadata_->SetRootResourceId(kWAPIRootDirectoryResourceId); | |
| 908 } | |
| 909 } | |
| 910 | |
| 896 DriveFeedProcessor feed_processor(resource_metadata_); | 911 DriveFeedProcessor feed_processor(resource_metadata_); |
| 897 feed_processor.ApplyFeeds( | 912 feed_processor.ApplyFeeds( |
| 898 feed_list, | 913 feed_list, |
| 899 start_changestamp, | 914 start_changestamp, |
| 900 root_feed_changestamp, | 915 root_feed_changestamp, |
| 901 &changed_dirs); | 916 &changed_dirs); |
| 902 | 917 |
| 903 // Don't send directory content change notification while performing | 918 // Don't send directory content change notification while performing |
| 904 // the initial content retrieval. | 919 // the initial content retrieval. |
| 905 const bool should_notify_directory_changed = (start_changestamp != 0); | 920 const bool should_notify_directory_changed = (start_changestamp != 0); |
| 906 if (should_notify_directory_changed) { | 921 if (should_notify_directory_changed) { |
| 907 for (std::set<FilePath>::iterator dir_iter = changed_dirs.begin(); | 922 for (std::set<FilePath>::iterator dir_iter = changed_dirs.begin(); |
| 908 dir_iter != changed_dirs.end(); ++dir_iter) { | 923 dir_iter != changed_dirs.end(); ++dir_iter) { |
| 909 FOR_EACH_OBSERVER(DriveFeedLoaderObserver, observers_, | 924 FOR_EACH_OBSERVER(DriveFeedLoaderObserver, observers_, |
| 910 OnDirectoryChanged(*dir_iter)); | 925 OnDirectoryChanged(*dir_iter)); |
| 911 } | 926 } |
| 912 } | 927 } |
| 913 } | 928 } |
| 914 | 929 |
| 915 } // namespace drive | 930 } // namespace drive |
| OLD | NEW |