diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-01 01:08:05 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-01 01:08:05 +0000 |
commit | 8d3d7ea57ac19413cdbac93c60d9fdf9803f78e0 (patch) | |
tree | ffb792e20b6827ab5ab1023319fd1d8f730b8d47 /chrome | |
parent | fb792f3b4816835335941993f2a2362f7ca8787d (diff) | |
download | chromium_src-8d3d7ea57ac19413cdbac93c60d9fdf9803f78e0.zip chromium_src-8d3d7ea57ac19413cdbac93c60d9fdf9803f78e0.tar.gz chromium_src-8d3d7ea57ac19413cdbac93c60d9fdf9803f78e0.tar.bz2 |
gdata: Periodic refresh should be active for file lists loaded from cache.
BUG=139561
TEST=manually tested that a file addition outside the Chromebook is reflected.
Review URL: https://chromiumcodereview.appspot.com/10836005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
3 files changed, 35 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc index 1c01d33..88a1ec5 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system.cc +++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc @@ -1010,7 +1010,10 @@ void GDataFileSystem::OnGetAccountMetadata( << ", server = " << account_metadata->largest_changestamp(); } - directory_service_->set_origin(initial_origin); + // If our cache holds the latest state from the server, change the + // state to FROM_SERVER. + directory_service_->set_origin( + initial_origin == FROM_CACHE ? FROM_SERVER : initial_origin); changes_detected = false; } diff --git a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc index 23e8a95..b7bd2be 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc +++ b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc @@ -653,10 +653,13 @@ class GDataFileSystemTest : public testing::Test { // Creates a proto file representing a filesystem with directories: // drive, drive/Dir1, drive/Dir1/SubDir2 // and files - // drive/File1, drive/Dir1/File2, drive/Dir1/SubDir2/File3 + // drive/File1, drive/Dir1/File2, drive/Dir1/SubDir2/File3. + // Sets the changestamp to 654321, equal to that of "account_metadata.json" + // test data, indicating the cache is holding the latest file system info. void SaveTestFileSystem() { GDataRootDirectoryProto root; root.set_version(kProtoVersion); + root.set_largest_changestamp(654321); GDataDirectoryProto* root_dir = root.mutable_gdata_directory(); GDataEntryProto* dir_base = root_dir->mutable_gdata_entry(); PlatformFileInfoProto* platform_info = dir_base->mutable_file_info(); @@ -1211,6 +1214,32 @@ TEST_F(GDataFileSystemTest, CachedFeedLoading) { FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2/File3")))); } +TEST_F(GDataFileSystemTest, CachedFeadLoadingThenServerFeedLoading) { + SaveTestFileSystem(); + + // SaveTestFileSystem and "account_metadata.json" have the same changestamp, + // so no request for new feeds (i.e., call to GetDocuments) should happen. + mock_doc_service_->set_account_metadata( + LoadJSONFile("account_metadata.json")); + EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1); + EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1); + EXPECT_CALL(*mock_doc_service_, GetDocuments(_, _, _, _, _)).Times(0); + + // Kicks loading of cached file system and query for server update. + EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File1")))); + + // Since the file system has verified that it holds the latest snapshot, + // it should change its state to FROM_SERVER, which admits periodic refresh. + // To test it, call CheckForUpdates and verify it does try to check updates. + mock_doc_service_->set_account_metadata( + LoadJSONFile("account_metadata.json")); + EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1); + EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1); + + file_system_->CheckForUpdates(); + test_util::RunBlockingPoolTask(); +} + TEST_F(GDataFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { LoadRootFeedDocument("root_feed.json"); diff --git a/chrome/browser/chromeos/gdata/mock_gdata_documents_service.h b/chrome/browser/chromeos/gdata/mock_gdata_documents_service.h index 9cc4590..b89ff17 100644 --- a/chrome/browser/chromeos/gdata/mock_gdata_documents_service.h +++ b/chrome/browser/chromeos/gdata/mock_gdata_documents_service.h @@ -83,7 +83,7 @@ class MockDocumentsService : public DocumentsServiceInterface { MOCK_CONST_METHOD0(HasRefreshToken, bool()); void set_account_metadata(base::Value* account_metadata) { - feed_data_.reset(account_metadata); + account_metadata_.reset(account_metadata); } void set_feed_data(base::Value* feed_data) { |