Skip to content

Commit

Permalink
drive: Remove unused DriveServiceInterface::CopyHostedDocument
Browse files Browse the repository at this point in the history
BUG=324382
TEST=unit_tests

Review URL: https://codereview.chromium.org/114973002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240594 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
hashimoto@chromium.org committed Dec 13, 2013
1 parent 39c6187 commit c76e04d
Show file tree
Hide file tree
Showing 18 changed files with 8 additions and 305 deletions.
3 changes: 0 additions & 3 deletions chrome/browser/chromeos/drive/job_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ std::string JobTypeToString(JobType type) {
return "TYPE_TRASH_RESOURCE";
case TYPE_COPY_RESOURCE:
return "TYPE_COPY_RESOURCE";
case TYPE_COPY_HOSTED_DOCUMENT:
return "TYPE_COPY_HOSTED_DOCUMENT";
case TYPE_UPDATE_RESOURCE:
return "TYPE_UPDATE_RESOURCE";
case TYPE_RENAME_RESOURCE:
Expand Down Expand Up @@ -127,7 +125,6 @@ bool IsActiveFileTransferJobInfo(const JobInfo& job_info) {
case TYPE_GET_SHARE_URL:
case TYPE_TRASH_RESOURCE:
case TYPE_COPY_RESOURCE:
case TYPE_COPY_HOSTED_DOCUMENT:
case TYPE_UPDATE_RESOURCE:
case TYPE_RENAME_RESOURCE:
case TYPE_ADD_RESOURCE_TO_DIRECTORY:
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/chromeos/drive/job_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ enum JobType {
TYPE_GET_SHARE_URL,
TYPE_TRASH_RESOURCE,
TYPE_COPY_RESOURCE,
TYPE_COPY_HOSTED_DOCUMENT,
TYPE_UPDATE_RESOURCE,
TYPE_RENAME_RESOURCE,
TYPE_ADD_RESOURCE_TO_DIRECTORY,
Expand Down
22 changes: 0 additions & 22 deletions chrome/browser/chromeos/drive/job_scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,27 +466,6 @@ void JobScheduler::CopyResource(
StartJob(new_job);
}

void JobScheduler::CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const google_apis::GetResourceEntryCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());

JobEntry* new_job = CreateNewJob(TYPE_COPY_HOSTED_DOCUMENT);
new_job->task = base::Bind(
&DriveServiceInterface::CopyHostedDocument,
base::Unretained(drive_service_),
resource_id,
new_title,
base::Bind(&JobScheduler::OnGetResourceEntryJobDone,
weak_ptr_factory_.GetWeakPtr(),
new_job->job_info.job_id,
callback));
new_job->abort_callback = CreateErrorRunCallback(callback);
StartJob(new_job);
}

void JobScheduler::UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
Expand Down Expand Up @@ -1139,7 +1118,6 @@ JobScheduler::QueueType JobScheduler::GetJobQueueType(JobType type) {
case TYPE_GET_SHARE_URL:
case TYPE_TRASH_RESOURCE:
case TYPE_COPY_RESOURCE:
case TYPE_COPY_HOSTED_DOCUMENT:
case TYPE_UPDATE_RESOURCE:
case TYPE_RENAME_RESOURCE:
case TYPE_ADD_RESOURCE_TO_DIRECTORY:
Expand Down
6 changes: 0 additions & 6 deletions chrome/browser/chromeos/drive/job_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ class JobScheduler
const base::Time& last_modified,
const google_apis::GetResourceEntryCallback& callback);

// Adds a CopyHostedDocument operation to the queue.
void CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const google_apis::GetResourceEntryCallback& callback);

// Adds a UpdateResource operation to the queue.
void UpdateResource(
const std::string& resource_id,
Expand Down
30 changes: 8 additions & 22 deletions chrome/browser/chromeos/drive/job_scheduler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,22 +425,6 @@ TEST_F(JobSchedulerTest, CopyResource) {
ASSERT_TRUE(entry);
}

TEST_F(JobSchedulerTest, CopyHostedDocument) {
ConnectToWifi();

google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
scoped_ptr<google_apis::ResourceEntry> entry;

scheduler_->CopyHostedDocument(
"document:5_document_resource_id", // resource ID
"New Document", // new title
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();

ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
ASSERT_TRUE(entry);
}

TEST_F(JobSchedulerTest, UpdateResource) {
ConnectToWifi();

Expand Down Expand Up @@ -883,10 +867,12 @@ TEST_F(JobSchedulerTest, JobInfo) {
"folder:1_folder_resource_id",
"file:2_file_resource_id",
google_apis::test_util::CreateCopyResultCallback(&error));
expected_types.insert(TYPE_COPY_HOSTED_DOCUMENT);
scheduler_->CopyHostedDocument(
expected_types.insert(TYPE_COPY_RESOURCE);
scheduler_->CopyResource(
"document:5_document_resource_id",
fake_drive_service_->GetRootResourceId(),
"New Document",
base::Time(), // last_modified
google_apis::test_util::CreateCopyResultCallback(&error, &entry));

// 6 jobs in total were queued.
Expand All @@ -901,9 +887,9 @@ TEST_F(JobSchedulerTest, JobInfo) {
EXPECT_EQ(expected_types, actual_types);
EXPECT_EQ(6U, job_ids.size()) << "All job IDs must be unique";
EXPECT_TRUE(logger.Has(JobListLogger::ADDED, TYPE_ADD_RESOURCE_TO_DIRECTORY));
EXPECT_TRUE(logger.Has(JobListLogger::ADDED, TYPE_COPY_HOSTED_DOCUMENT));
EXPECT_TRUE(logger.Has(JobListLogger::ADDED, TYPE_COPY_RESOURCE));
EXPECT_FALSE(logger.Has(JobListLogger::DONE, TYPE_ADD_RESOURCE_TO_DIRECTORY));
EXPECT_FALSE(logger.Has(JobListLogger::DONE, TYPE_COPY_HOSTED_DOCUMENT));
EXPECT_FALSE(logger.Has(JobListLogger::DONE, TYPE_COPY_RESOURCE));

// Run the jobs.
base::RunLoop().RunUntilIdle();
Expand All @@ -919,14 +905,14 @@ TEST_F(JobSchedulerTest, JobInfo) {
EXPECT_TRUE(logger.Has(JobListLogger::UPDATED, TYPE_RENAME_RESOURCE));
EXPECT_TRUE(logger.Has(JobListLogger::UPDATED,
TYPE_ADD_RESOURCE_TO_DIRECTORY));
EXPECT_TRUE(logger.Has(JobListLogger::UPDATED, TYPE_COPY_HOSTED_DOCUMENT));
EXPECT_TRUE(logger.Has(JobListLogger::UPDATED, TYPE_COPY_RESOURCE));
EXPECT_FALSE(logger.Has(JobListLogger::UPDATED, TYPE_DOWNLOAD_FILE));

EXPECT_TRUE(logger.Has(JobListLogger::DONE, TYPE_ADD_NEW_DIRECTORY));
EXPECT_TRUE(logger.Has(JobListLogger::DONE, TYPE_GET_ABOUT_RESOURCE));
EXPECT_TRUE(logger.Has(JobListLogger::DONE, TYPE_RENAME_RESOURCE));
EXPECT_TRUE(logger.Has(JobListLogger::DONE, TYPE_ADD_RESOURCE_TO_DIRECTORY));
EXPECT_TRUE(logger.Has(JobListLogger::DONE, TYPE_COPY_HOSTED_DOCUMENT));
EXPECT_TRUE(logger.Has(JobListLogger::DONE, TYPE_COPY_RESOURCE));
EXPECT_FALSE(logger.Has(JobListLogger::DONE, TYPE_DOWNLOAD_FILE));

// Run the background downloading job as well.
Expand Down
16 changes: 0 additions & 16 deletions chrome/browser/drive/drive_api_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -621,22 +621,6 @@ CancelCallback DriveAPIService::CopyResource(
return sender_->StartRequestWithRetry(request);
}

CancelCallback DriveAPIService::CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const GetResourceEntryCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());

FilesCopyRequest* request = new FilesCopyRequest(
sender_.get(), url_generator_,
base::Bind(&ConvertFileEntryToResourceEntryAndRun, callback));
request->set_file_id(resource_id);
request->set_title(new_title);
request->set_fields(kFileResourceFields);
return sender_->StartRequestWithRetry(request);
}

CancelCallback DriveAPIService::UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
Expand Down
4 changes: 0 additions & 4 deletions chrome/browser/drive/drive_api_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ class DriveAPIService : public DriveServiceInterface,
const std::string& new_title,
const base::Time& last_modified,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
Expand Down
13 changes: 0 additions & 13 deletions chrome/browser/drive/drive_service_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,6 @@ class DriveServiceInterface {
const base::Time& last_modified,
const google_apis::GetResourceEntryCallback& callback) = 0;

// Makes a copy of a hosted document identified by its |resource_id|.
// The copy is named as the UTF-8 encoded |new_title| and is not added to any
// collection. Use AddResourceToDirectory() to add the copy to a collection
// when needed. Upon completion, invokes |callback| with results on the
// calling thread.
// |callback| must not be null.
// TODO(hidehiko): After the migration to Drive API v2, remove this method,
// because we can use CopyResource instead.
virtual google_apis::CancelCallback CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const google_apis::GetResourceEntryCallback& callback) = 0;

// Updates a resource with |resource_id| to the directory of
// |parent_resource_id| with renaming to |new_title|.
// If |last_modified| or |last_accessed| is not null, the modified/accessed
Expand Down
5 changes: 0 additions & 5 deletions chrome/browser/drive/dummy_drive_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ CancelCallback DummyDriveService::CopyResource(
const base::Time& last_modified,
const GetResourceEntryCallback& callback) { return CancelCallback(); }

CancelCallback DummyDriveService::CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const GetResourceEntryCallback& callback) { return CancelCallback(); }

CancelCallback DummyDriveService::UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
Expand Down
4 changes: 0 additions & 4 deletions chrome/browser/drive/dummy_drive_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ class DummyDriveService : public DriveServiceInterface {
const std::string& new_title,
const base::Time& last_modified,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
Expand Down
11 changes: 0 additions & 11 deletions chrome/browser/drive/fake_drive_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -827,17 +827,6 @@ CancelCallback FakeDriveService::CopyResource(
return CancelCallback();
}

CancelCallback FakeDriveService::CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const GetResourceEntryCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());

return CopyResource(
resource_id, std::string(), new_title, base::Time(), callback);
}

CancelCallback FakeDriveService::UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
Expand Down
6 changes: 0 additions & 6 deletions chrome/browser/drive/fake_drive_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,6 @@ class FakeDriveService : public DriveServiceInterface {
const std::string& new_title,
const base::Time& last_modified,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
// The new resource ID for the copied document will look like
// |resource_id| + "_copied".
virtual google_apis::CancelCallback CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
Expand Down
61 changes: 0 additions & 61 deletions chrome/browser/drive/fake_drive_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1202,67 +1202,6 @@ TEST_F(FakeDriveServiceTest, CopyResource_Offline) {
EXPECT_FALSE(resource_entry);
}

TEST_F(FakeDriveServiceTest, CopyHostedDocument_Existing) {
ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
"gdata/root_feed.json"));
ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi(
"gdata/account_metadata.json"));

int64 old_largest_change_id = GetLargestChangeByAboutResource();

const std::string kResourceId = "document:5_document_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
scoped_ptr<ResourceEntry> resource_entry;
fake_service_.CopyHostedDocument(
kResourceId,
"new title",
test_util::CreateCopyResultCallback(&error, &resource_entry));
base::RunLoop().RunUntilIdle();

EXPECT_EQ(HTTP_SUCCESS, error);
ASSERT_TRUE(resource_entry);
// The copied entry should have the new resource ID and the title.
EXPECT_EQ(kResourceId + "_copied", resource_entry->resource_id());
EXPECT_EQ("new title", resource_entry->title());
// Should be incremented as a new hosted document was created.
EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
}

TEST_F(FakeDriveServiceTest, CopyHostedDocument_NonExisting) {
ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
"gdata/root_feed.json"));

const std::string kResourceId = "document:nonexisting_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
scoped_ptr<ResourceEntry> resource_entry;
fake_service_.CopyHostedDocument(
kResourceId,
"new title",
test_util::CreateCopyResultCallback(&error, &resource_entry));
base::RunLoop().RunUntilIdle();

EXPECT_EQ(HTTP_NOT_FOUND, error);
}

TEST_F(FakeDriveServiceTest, CopyHostedDocument_Offline) {
ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
"gdata/root_feed.json"));
fake_service_.set_offline(true);

const std::string kResourceId = "document:5_document_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
scoped_ptr<ResourceEntry> resource_entry;
fake_service_.CopyHostedDocument(
kResourceId,
"new title",
test_util::CreateCopyResultCallback(&error, &resource_entry));
base::RunLoop().RunUntilIdle();

EXPECT_EQ(GDATA_NO_CONNECTION, error);
EXPECT_FALSE(resource_entry);
}

TEST_F(FakeDriveServiceTest, UpdateResource) {
const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123};
const base::Time::Exploded kViewedDate = {2013, 8, 1, 20, 16, 00, 14, 234};
Expand Down
17 changes: 0 additions & 17 deletions chrome/browser/drive/gdata_wapi_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ using google_apis::AuthStatusCallback;
using google_apis::AuthorizeAppCallback;
using google_apis::AuthorizeAppRequest;
using google_apis::CancelCallback;
using google_apis::CopyHostedDocumentRequest;
using google_apis::CreateDirectoryRequest;
using google_apis::DeleteResourceRequest;
using google_apis::DownloadActionCallback;
Expand Down Expand Up @@ -429,22 +428,6 @@ CancelCallback GDataWapiService::CopyResource(
return CancelCallback();
}

CancelCallback GDataWapiService::CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const GetResourceEntryCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());

return sender_->StartRequestWithRetry(
new CopyHostedDocumentRequest(sender_.get(),
url_generator_,
base::Bind(&ParseResourceEntryAndRun,
callback),
resource_id,
new_title));
}

CancelCallback GDataWapiService::UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
Expand Down
4 changes: 0 additions & 4 deletions chrome/browser/drive/gdata_wapi_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ class GDataWapiService : public DriveServiceInterface,
const std::string& new_title,
const base::Time& last_modified,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback CopyHostedDocument(
const std::string& resource_id,
const std::string& new_title,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
Expand Down
Loading

0 comments on commit c76e04d

Please sign in to comment.