summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 06:34:59 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 06:34:59 +0000
commitbfcaaf333c2d02920cd58e013b9782328d65c718 (patch)
tree9fc54f174bf1241b761895b9bbf1361231edcd5e
parent5122733559e5eb97b841602387722c1710cdf86a (diff)
downloadchromium_src-bfcaaf333c2d02920cd58e013b9782328d65c718.zip
chromium_src-bfcaaf333c2d02920cd58e013b9782328d65c718.tar.gz
chromium_src-bfcaaf333c2d02920cd58e013b9782328d65c718.tar.bz2
drive: Merge OnCacheFileUploadNeededByOperation event to OnEntryUpdatedByOperation
BUG=337083 TEST=unit_tests R=kinaba@chromium.org Review URL: https://codereview.chromium.org/132453006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247197 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/drive/file_system.cc5
-rw-r--r--chrome/browser/chromeos/drive/file_system.h2
-rw-r--r--chrome/browser/chromeos/drive/file_system/copy_operation.cc2
-rw-r--r--chrome/browser/chromeos/drive/file_system/copy_operation_unittest.cc2
-rw-r--r--chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.cc2
-rw-r--r--chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation_unittest.cc3
-rw-r--r--chrome/browser/chromeos/drive/file_system/open_file_operation.cc2
-rw-r--r--chrome/browser/chromeos/drive/file_system/open_file_operation_unittest.cc24
-rw-r--r--chrome/browser/chromeos/drive/file_system/operation_observer.h6
-rw-r--r--chrome/browser/chromeos/drive/file_system/operation_test_base.cc5
-rw-r--r--chrome/browser/chromeos/drive/file_system/operation_test_base.h8
-rw-r--r--chrome/browser/chromeos/drive/file_system/truncate_operation.cc2
-rw-r--r--chrome/browser/chromeos/drive/sync_client.cc7
-rw-r--r--chrome/browser/chromeos/drive/sync_client.h3
-rw-r--r--chrome/browser/chromeos/drive/sync_client_unittest.cc4
15 files changed, 16 insertions, 61 deletions
diff --git a/chrome/browser/chromeos/drive/file_system.cc b/chrome/browser/chromeos/drive/file_system.cc
index 2da7624..a617b56 100644
--- a/chrome/browser/chromeos/drive/file_system.cc
+++ b/chrome/browser/chromeos/drive/file_system.cc
@@ -771,11 +771,6 @@ void FileSystem::OnDirectoryChangedByOperation(
OnDirectoryChanged(directory_path);
}
-void FileSystem::OnCacheFileUploadNeededByOperation(
- const std::string& local_id) {
- sync_client_->AddUploadTask(ClientContext(USER_INITIATED), local_id);
-}
-
void FileSystem::OnEntryUpdatedByOperation(const std::string& local_id) {
sync_client_->AddUpdateTask(ClientContext(USER_INITIATED), local_id);
}
diff --git a/chrome/browser/chromeos/drive/file_system.h b/chrome/browser/chromeos/drive/file_system.h
index 0b5f530..28f608a 100644
--- a/chrome/browser/chromeos/drive/file_system.h
+++ b/chrome/browser/chromeos/drive/file_system.h
@@ -156,8 +156,6 @@ class FileSystem : public FileSystemInterface,
// file_system::OperationObserver overrides.
virtual void OnDirectoryChangedByOperation(
const base::FilePath& directory_path) OVERRIDE;
- virtual void OnCacheFileUploadNeededByOperation(
- const std::string& local_id) OVERRIDE;
virtual void OnEntryUpdatedByOperation(const std::string& local_id) OVERRIDE;
virtual void OnDriveSyncError(file_system::DriveSyncErrorType type,
const std::string& local_id) OVERRIDE;
diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.cc b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
index 82e9885..d438095 100644
--- a/chrome/browser/chromeos/drive/file_system/copy_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
@@ -457,7 +457,7 @@ void CopyOperation::ScheduleTransferRegularFileAfterUpdateLocalState(
DCHECK(!callback.is_null());
if (error == FILE_ERROR_OK)
- observer_->OnCacheFileUploadNeededByOperation(*local_id);
+ observer_->OnEntryUpdatedByOperation(*local_id);
callback.Run(error);
}
diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation_unittest.cc b/chrome/browser/chromeos/drive/file_system/copy_operation_unittest.cc
index d30c333..28494b5 100644
--- a/chrome/browser/chromeos/drive/file_system/copy_operation_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system/copy_operation_unittest.cc
@@ -57,7 +57,7 @@ TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_RegularFile) {
// TransferFileFromLocalToRemote stores a copy of the local file in the cache,
// marks it dirty and requests the observer to upload the file.
EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry));
- EXPECT_EQ(1U, observer()->upload_needed_local_ids().count(
+ EXPECT_EQ(1U, observer()->updated_local_ids().count(
GetLocalId(remote_dest_path)));
FileCacheEntry cache_entry;
bool found = false;
diff --git a/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.cc b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.cc
index c88bf59..6569e16 100644
--- a/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.cc
@@ -165,7 +165,7 @@ void GetFileForSavingOperation::GetFileForSavingAfterWatch(
void GetFileForSavingOperation::OnWriteEvent(
const std::string& local_id,
scoped_ptr<base::ScopedClosureRunner> file_closer) {
- observer_->OnCacheFileUploadNeededByOperation(local_id);
+ observer_->OnEntryUpdatedByOperation(local_id);
// Clients may have enlarged the file. By FreeDiskpSpaceIfNeededFor(0),
// we try to ensure (0 + the-minimum-safe-margin = 512MB as of now) space.
diff --git a/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation_unittest.cc b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation_unittest.cc
index 6621990..51650c0 100644
--- a/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation_unittest.cc
@@ -38,8 +38,7 @@ class TestObserver : public OperationObserver {
virtual void OnDirectoryChangedByOperation(
const base::FilePath& path) OVERRIDE {}
- virtual void OnCacheFileUploadNeededByOperation(
- const std::string& local_id) OVERRIDE {
+ virtual void OnEntryUpdatedByOperation(const std::string& local_id) OVERRIDE {
observed_local_id_ = local_id;
quit_closure_.Run();
}
diff --git a/chrome/browser/chromeos/drive/file_system/open_file_operation.cc b/chrome/browser/chromeos/drive/file_system/open_file_operation.cc
index f79a313..a5b9414 100644
--- a/chrome/browser/chromeos/drive/file_system/open_file_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/open_file_operation.cc
@@ -170,7 +170,7 @@ void OpenFileOperation::CloseFile(
if (--open_files_[local_id] == 0) {
// All clients closes this file, so notify to upload the file.
open_files_.erase(local_id);
- observer_->OnCacheFileUploadNeededByOperation(local_id);
+ observer_->OnEntryUpdatedByOperation(local_id);
// Clients may have enlarged the file. By FreeDiskpSpaceIfNeededFor(0),
// we try to ensure (0 + the-minimum-safe-margin = 512MB as of now) space.
diff --git a/chrome/browser/chromeos/drive/file_system/open_file_operation_unittest.cc b/chrome/browser/chromeos/drive/file_system/open_file_operation_unittest.cc
index 4b4cd76..734d2a8 100644
--- a/chrome/browser/chromeos/drive/file_system/open_file_operation_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system/open_file_operation_unittest.cc
@@ -59,9 +59,7 @@ TEST_F(OpenFileOperationTest, OpenExistingFile) {
ASSERT_FALSE(close_callback.is_null());
close_callback.Run();
- EXPECT_EQ(
- 1U,
- observer()->upload_needed_local_ids().count(src_entry.local_id()));
+ EXPECT_EQ(1U, observer()->updated_local_ids().count(src_entry.local_id()));
}
TEST_F(OpenFileOperationTest, OpenNonExistingFile) {
@@ -129,9 +127,8 @@ TEST_F(OpenFileOperationTest, CreateNonExistingFile) {
ASSERT_FALSE(close_callback.is_null());
close_callback.Run();
- EXPECT_EQ(
- 1U,
- observer()->upload_needed_local_ids().count(GetLocalId(file_in_root)));
+ EXPECT_EQ(1U,
+ observer()->updated_local_ids().count(GetLocalId(file_in_root)));
}
TEST_F(OpenFileOperationTest, OpenOrCreateExistingFile) {
@@ -164,9 +161,7 @@ TEST_F(OpenFileOperationTest, OpenOrCreateExistingFile) {
ASSERT_FALSE(close_callback.is_null());
close_callback.Run();
- EXPECT_EQ(
- 1U,
- observer()->upload_needed_local_ids().count(src_entry.local_id()));
+ EXPECT_EQ(1U, observer()->updated_local_ids().count(src_entry.local_id()));
bool success = false;
FileCacheEntry cache_entry;
@@ -207,9 +202,8 @@ TEST_F(OpenFileOperationTest, OpenOrCreateNonExistingFile) {
ASSERT_FALSE(close_callback.is_null());
close_callback.Run();
- EXPECT_EQ(
- 1U,
- observer()->upload_needed_local_ids().count(GetLocalId(file_in_root)));
+ EXPECT_EQ(1U,
+ observer()->updated_local_ids().count(GetLocalId(file_in_root)));
}
TEST_F(OpenFileOperationTest, OpenFileTwice) {
@@ -259,14 +253,12 @@ TEST_F(OpenFileOperationTest, OpenFileTwice) {
// There still remains a client opening the file, so it shouldn't be
// uploaded yet.
- EXPECT_TRUE(observer()->upload_needed_local_ids().empty());
+ EXPECT_TRUE(observer()->updated_local_ids().empty());
close_callback2.Run();
// Here, all the clients close the file, so it should be uploaded then.
- EXPECT_EQ(
- 1U,
- observer()->upload_needed_local_ids().count(src_entry.local_id()));
+ EXPECT_EQ(1U, observer()->updated_local_ids().count(src_entry.local_id()));
}
} // namespace file_system
diff --git a/chrome/browser/chromeos/drive/file_system/operation_observer.h b/chrome/browser/chromeos/drive/file_system/operation_observer.h
index 82fd5d0..436c53f 100644
--- a/chrome/browser/chromeos/drive/file_system/operation_observer.h
+++ b/chrome/browser/chromeos/drive/file_system/operation_observer.h
@@ -32,11 +32,7 @@ class OperationObserver {
virtual void OnDirectoryChangedByOperation(
const base::FilePath& directory_path) = 0;
- // Sent when a cache file is modified and upload is needed.
- virtual void OnCacheFileUploadNeededByOperation(
- const std::string& local_id) = 0;
-
- // Sent when metadata entry is updated and sync is needed.
+ // Sent when an entry is updated and sync is needed.
virtual void OnEntryUpdatedByOperation(const std::string& local_id) {}
// Sent when a specific drive sync error occurred.
diff --git a/chrome/browser/chromeos/drive/file_system/operation_test_base.cc b/chrome/browser/chromeos/drive/file_system/operation_test_base.cc
index 691a40a..e4a691f 100644
--- a/chrome/browser/chromeos/drive/file_system/operation_test_base.cc
+++ b/chrome/browser/chromeos/drive/file_system/operation_test_base.cc
@@ -31,11 +31,6 @@ void OperationTestBase::LoggingObserver::OnDirectoryChangedByOperation(
changed_paths_.insert(path);
}
-void OperationTestBase::LoggingObserver::OnCacheFileUploadNeededByOperation(
- const std::string& local_id) {
- upload_needed_local_ids_.insert(local_id);
-}
-
void OperationTestBase::LoggingObserver::OnEntryUpdatedByOperation(
const std::string& local_id) {
updated_local_ids_.insert(local_id);
diff --git a/chrome/browser/chromeos/drive/file_system/operation_test_base.h b/chrome/browser/chromeos/drive/file_system/operation_test_base.h
index f899d33..4707f2b 100644
--- a/chrome/browser/chromeos/drive/file_system/operation_test_base.h
+++ b/chrome/browser/chromeos/drive/file_system/operation_test_base.h
@@ -50,8 +50,6 @@ class OperationTestBase : public testing::Test {
// OperationObserver overrides.
virtual void OnDirectoryChangedByOperation(
const base::FilePath& path) OVERRIDE;
- virtual void OnCacheFileUploadNeededByOperation(
- const std::string& local_id) OVERRIDE;
virtual void OnEntryUpdatedByOperation(
const std::string& local_id) OVERRIDE;
virtual void OnDriveSyncError(DriveSyncErrorType type,
@@ -62,11 +60,6 @@ class OperationTestBase : public testing::Test {
return changed_paths_;
}
- // Gets the set of upload needed local IDs.
- const std::set<std::string>& upload_needed_local_ids() const {
- return upload_needed_local_ids_;
- }
-
// Gets the set of updated local IDs.
const std::set<std::string>& updated_local_ids() const {
return updated_local_ids_;
@@ -79,7 +72,6 @@ class OperationTestBase : public testing::Test {
private:
std::set<base::FilePath> changed_paths_;
- std::set<std::string> upload_needed_local_ids_;
std::set<std::string> updated_local_ids_;
std::vector<DriveSyncErrorType> drive_sync_errors_;
};
diff --git a/chrome/browser/chromeos/drive/file_system/truncate_operation.cc b/chrome/browser/chromeos/drive/file_system/truncate_operation.cc
index a5273f2..d9fae3e 100644
--- a/chrome/browser/chromeos/drive/file_system/truncate_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/truncate_operation.cc
@@ -146,7 +146,7 @@ void TruncateOperation::TruncateAfterTruncateOnBlockingPool(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- observer_->OnCacheFileUploadNeededByOperation(local_id);
+ observer_->OnEntryUpdatedByOperation(local_id);
callback.Run(error);
}
diff --git a/chrome/browser/chromeos/drive/sync_client.cc b/chrome/browser/chromeos/drive/sync_client.cc
index d566214..a679f3f 100644
--- a/chrome/browser/chromeos/drive/sync_client.cc
+++ b/chrome/browser/chromeos/drive/sync_client.cc
@@ -215,13 +215,6 @@ void SyncClient::RemoveFetchTask(const std::string& local_id) {
}
}
-void SyncClient::AddUploadTask(const ClientContext& context,
- const std::string& local_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // TODO(hashimoto): Remove this method.
- AddUpdateTask(context, local_id);
-}
-
void SyncClient::AddUpdateTask(const ClientContext& context,
const std::string& local_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
diff --git a/chrome/browser/chromeos/drive/sync_client.h b/chrome/browser/chromeos/drive/sync_client.h
index 3eaad06..677ff1a 100644
--- a/chrome/browser/chromeos/drive/sync_client.h
+++ b/chrome/browser/chromeos/drive/sync_client.h
@@ -59,9 +59,6 @@ class SyncClient {
// Removes a fetch task.
void RemoveFetchTask(const std::string& local_id);
- // Adds an upload task.
- void AddUploadTask(const ClientContext& context, const std::string& local_id);
-
// Adds a update task.
void AddUpdateTask(const ClientContext& context, const std::string& local_id);
diff --git a/chrome/browser/chromeos/drive/sync_client_unittest.cc b/chrome/browser/chromeos/drive/sync_client_unittest.cc
index e5a0c28..784e247 100644
--- a/chrome/browser/chromeos/drive/sync_client_unittest.cc
+++ b/chrome/browser/chromeos/drive/sync_client_unittest.cc
@@ -98,8 +98,6 @@ class DummyOperationObserver : public file_system::OperationObserver {
// OperationObserver override:
virtual void OnDirectoryChangedByOperation(
const base::FilePath& path) OVERRIDE {}
- virtual void OnCacheFileUploadNeededByOperation(
- const std::string& local_id) OVERRIDE {}
};
} // namespace
@@ -389,7 +387,7 @@ TEST_F(SyncClientTest, RetryOnDisconnection) {
// Try fetch and upload.
sync_client_->AddFetchTask(GetLocalId("foo"));
- sync_client_->AddUploadTask(ClientContext(USER_INITIATED),
+ sync_client_->AddUpdateTask(ClientContext(USER_INITIATED),
GetLocalId("dirty"));
base::RunLoop().RunUntilIdle();