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/change_list_loader.h" | 5 #include "chrome/browser/chromeos/drive/change_list_loader.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 const std::string& directory_resource_id, | 349 const std::string& directory_resource_id, |
| 350 const FileOperationCallback& callback, | 350 const FileOperationCallback& callback, |
| 351 google_apis::GDataErrorCode status, | 351 google_apis::GDataErrorCode status, |
| 352 scoped_ptr<google_apis::AboutResource> about_resource) { | 352 scoped_ptr<google_apis::AboutResource> about_resource) { |
| 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 354 DCHECK(!callback.is_null()); | 354 DCHECK(!callback.is_null()); |
| 355 | 355 |
| 356 int64 remote_changestamp = 0; | 356 int64 remote_changestamp = 0; |
| 357 if (util::GDataToDriveFileError(status) == DRIVE_FILE_OK) { | 357 if (util::GDataToDriveFileError(status) == DRIVE_FILE_OK) { |
| 358 DCHECK(about_resource); | 358 DCHECK(about_resource); |
| 359 remote_changestamp = about_resource->largest_change_id(); | 359 remote_changestamp = about_resource->largest_change_id(); |
|
satorux1
2013/04/03 07:14:07
we should probably update last_known_remote_change
kinaba
2013/04/03 07:58:25
Done.
| |
| 360 } | 360 } |
| 361 | 361 |
| 362 const DirectoryFetchInfo directory_fetch_info(directory_resource_id, | 362 const DirectoryFetchInfo directory_fetch_info(directory_resource_id, |
| 363 remote_changestamp); | 363 remote_changestamp); |
| 364 DoLoadDirectoryFromServer(directory_fetch_info, callback); | 364 DoLoadDirectoryFromServer(directory_fetch_info, callback); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void ChangeListLoader::DoLoadDirectoryFromServer( | 367 void ChangeListLoader::DoLoadDirectoryFromServer( |
| 368 const DirectoryFetchInfo& directory_fetch_info, | 368 const DirectoryFetchInfo& directory_fetch_info, |
| 369 const FileOperationCallback& callback) { | 369 const FileOperationCallback& callback) { |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 // If the directory of interest is already scheduled to be fetched, add the | 733 // If the directory of interest is already scheduled to be fetched, add the |
| 734 // callback to the pending list and return. | 734 // callback to the pending list and return. |
| 735 LoadCallbackMap::iterator it = pending_load_callback_.find(resource_id); | 735 LoadCallbackMap::iterator it = pending_load_callback_.find(resource_id); |
| 736 if (it != pending_load_callback_.end()) { | 736 if (it != pending_load_callback_.end()) { |
| 737 it->second.push_back(callback); | 737 it->second.push_back(callback); |
| 738 return; | 738 return; |
| 739 } | 739 } |
| 740 | 740 |
| 741 // If the directory's changestamp is up-to-date, just schedule to run the | 741 // If the directory's changestamp is up-to-date, just schedule to run the |
| 742 // callback, as there is no need to fetch the directory. | 742 // callback, as there is no need to fetch the directory. |
| 743 if (directory_fetch_info.changestamp() >= last_known_remote_changestamp_) { | 743 if (directory_fetch_info.changestamp() >= last_known_remote_changestamp_) { |
|
satorux1
2013/04/04 08:30:47
Seems to me that last_known_remote_changestamp_ is
kinaba
2013/04/05 07:04:37
Correct.
| |
| 744 base::MessageLoopProxy::current()->PostTask( | 744 base::MessageLoopProxy::current()->PostTask( |
| 745 FROM_HERE, | 745 FROM_HERE, |
| 746 base::Bind(callback, DRIVE_FILE_OK)); | 746 base::Bind(callback, DRIVE_FILE_OK)); |
| 747 return; | 747 return; |
| 748 } | 748 } |
| 749 | 749 |
| 750 // The directory should be fetched. Add a dummy task to so ScheduleRun() | 750 // The directory should be fetched. Add a dummy task to so ScheduleRun() |
| 751 // can check that the directory is being fetched. | 751 // can check that the directory is being fetched. |
| 752 pending_load_callback_[resource_id].push_back( | 752 pending_load_callback_[resource_id].push_back( |
| 753 base::Bind(&util::EmptyFileOperationCallback)); | 753 base::Bind(&util::EmptyFileOperationCallback)); |
| 754 | |
| 755 DirectoryFetchInfo new_directory_fetch_info( | |
| 756 directory_fetch_info.resource_id(), | |
| 757 last_known_remote_changestamp_); | |
|
satorux1
2013/04/03 07:14:07
not sure using last_known_remote_changestamp_ is c
kinaba
2013/04/03 07:58:25
If it is 0 we are exiting the function in the if-s
satorux1
2013/04/04 08:30:47
See above.
| |
| 754 DoLoadDirectoryFromServer( | 758 DoLoadDirectoryFromServer( |
| 755 directory_fetch_info, | 759 new_directory_fetch_info, |
| 756 base::Bind(&ChangeListLoader::OnDirectoryLoadComplete, | 760 base::Bind(&ChangeListLoader::OnDirectoryLoadComplete, |
| 757 weak_ptr_factory_.GetWeakPtr(), | 761 weak_ptr_factory_.GetWeakPtr(), |
| 758 directory_fetch_info, | 762 directory_fetch_info, |
| 759 callback)); | 763 callback)); |
| 760 } | 764 } |
| 761 | 765 |
| 762 void ChangeListLoader::NotifyDirectoryChangedAfterApplyFeed( | 766 void ChangeListLoader::NotifyDirectoryChangedAfterApplyFeed( |
| 763 bool should_notify_changed_directories, | 767 bool should_notify_changed_directories, |
| 764 const base::Closure& update_finished_callback) { | 768 const base::Closure& update_finished_callback) { |
| 765 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 769 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 856 for (size_t i = 0; i < callbacks.size(); ++i) { | 860 for (size_t i = 0; i < callbacks.size(); ++i) { |
| 857 base::MessageLoopProxy::current()->PostTask( | 861 base::MessageLoopProxy::current()->PostTask( |
| 858 FROM_HERE, | 862 FROM_HERE, |
| 859 base::Bind(callbacks[i], error)); | 863 base::Bind(callbacks[i], error)); |
| 860 } | 864 } |
| 861 pending_load_callback_.erase(it); | 865 pending_load_callback_.erase(it); |
| 862 } | 866 } |
| 863 } | 867 } |
| 864 | 868 |
| 865 } // namespace drive | 869 } // namespace drive |
| OLD | NEW |