summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 03:37:41 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 03:37:41 +0000
commit3125844a928e887e297ae046fb263e3d4646b679 (patch)
tree8364d00d74c8b4e8a53404c10c6962d708bbbe66
parent975da41aab312ba7cc270462d02931452f51d953 (diff)
downloadchromium_src-3125844a928e887e297ae046fb263e3d4646b679.zip
chromium_src-3125844a928e887e297ae046fb263e3d4646b679.tar.gz
chromium_src-3125844a928e887e297ae046fb263e3d4646b679.tar.bz2
drive: Replace GetResourceEntryCallback in DriveServiceInterface with FileResourceCallback
Rename DriveServiceInterface::GetResourceEntry() to GetFileResource(). Change the callback type of CopyResource(), UpdateResource() and AddNewDirectory() to FileResourceCallback. BUG=231125 TEST=git cl try Review URL: https://codereview.chromium.org/307343002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275006 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/drive/change_list_loader_unittest.cc10
-rw-r--r--chrome/browser/chromeos/drive/directory_loader_unittest.cc4
-rw-r--r--chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc4
-rw-r--r--chrome/browser/chromeos/drive/fake_file_system.cc17
-rw-r--r--chrome/browser/chromeos/drive/fake_file_system.h6
-rw-r--r--chrome/browser/chromeos/drive/file_system/copy_operation_unittest.cc10
-rw-r--r--chrome/browser/chromeos/drive/file_system/search_operation_unittest.cc11
-rw-r--r--chrome/browser/chromeos/drive/file_system_unittest.cc94
-rw-r--r--chrome/browser/chromeos/drive/fileapi/webkit_file_stream_reader_impl_unittest.cc6
-rw-r--r--chrome/browser/chromeos/drive/job_scheduler.cc21
-rw-r--r--chrome/browser/chromeos/drive/job_scheduler.h6
-rw-r--r--chrome/browser/chromeos/drive/job_scheduler_unittest.cc4
-rw-r--r--chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc52
-rw-r--r--chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc18
-rw-r--r--chrome/browser/chromeos/drive/sync_client_unittest.cc25
-rw-r--r--chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc45
-rw-r--r--chrome/browser/chromeos/file_manager/file_manager_browsertest.cc30
-rw-r--r--chrome/browser/drive/drive_api_service.cc49
-rw-r--r--chrome/browser/drive/drive_api_service.h10
-rw-r--r--chrome/browser/drive/drive_service_interface.h12
-rw-r--r--chrome/browser/drive/dummy_drive_service.cc12
-rw-r--r--chrome/browser/drive/dummy_drive_service.h10
-rw-r--r--chrome/browser/drive/fake_drive_service.cc93
-rw-r--r--chrome/browser/drive/fake_drive_service.h18
-rw-r--r--chrome/browser/drive/fake_drive_service_unittest.cc372
-rw-r--r--chrome/browser/drive/test_util.cc6
-rw-r--r--chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc16
-rw-r--r--chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc8
-rw-r--r--chrome/browser/sync_file_system/drive_backend/conflict_resolver.h4
-rw-r--r--chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc14
-rw-r--r--chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.cc12
-rw-r--r--chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.h10
-rw-r--r--chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.cc8
-rw-r--r--chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.h6
-rw-r--r--chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc22
-rw-r--r--chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.h4
-rw-r--r--chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.cc27
-rw-r--r--chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h2
-rw-r--r--chrome/browser/sync_file_system/drive_backend/folder_creator.cc2
-rw-r--r--chrome/browser/sync_file_system/drive_backend/folder_creator.h2
-rw-r--r--chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc7
-rw-r--r--chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h3
-rw-r--r--chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc9
-rw-r--r--chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.cc6
-rw-r--r--chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h2
-rw-r--r--chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.cc2
-rw-r--r--chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h2
-rw-r--r--chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc12
-rw-r--r--chrome/browser/sync_file_system/drive_backend_v1/api_util.cc31
-rw-r--r--chrome/browser/sync_file_system/drive_backend_v1/api_util.h8
-rw-r--r--chrome/browser/sync_file_system/drive_backend_v1/api_util_unittest.cc57
-rw-r--r--chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc17
52 files changed, 579 insertions, 659 deletions
diff --git a/chrome/browser/chromeos/drive/change_list_loader_unittest.cc b/chrome/browser/chromeos/drive/change_list_loader_unittest.cc
index 51ea898..ee4152a 100644
--- a/chrome/browser/chromeos/drive/change_list_loader_unittest.cc
+++ b/chrome/browser/chromeos/drive/change_list_loader_unittest.cc
@@ -115,9 +115,9 @@ class ChangeListLoaderTest : public testing::Test {
}
// Adds a new file to the root directory of the service.
- scoped_ptr<google_apis::ResourceEntry> AddNewFile(const std::string& title) {
+ scoped_ptr<google_apis::FileResource> AddNewFile(const std::string& title) {
google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR;
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
drive_service_->AddNewFile(
"text/plain",
"content text",
@@ -195,7 +195,7 @@ TEST_F(ChangeListLoaderTest, Load_LocalMetadataAvailable) {
loader_controller_.get()));
// Add a file to the service.
- scoped_ptr<google_apis::ResourceEntry> gdata_entry = AddNewFile("New File");
+ scoped_ptr<google_apis::FileResource> gdata_entry = AddNewFile("New File");
ASSERT_TRUE(gdata_entry);
// Start loading. Because local metadata is available, the load results in
@@ -278,7 +278,7 @@ TEST_F(ChangeListLoaderTest, CheckForUpdates) {
EXPECT_EQ(previous_changestamp, changestamp);
// Add a file to the service.
- scoped_ptr<google_apis::ResourceEntry> gdata_entry = AddNewFile("New File");
+ scoped_ptr<google_apis::FileResource> gdata_entry = AddNewFile("New File");
ASSERT_TRUE(gdata_entry);
// CheckForUpdates() results in update.
@@ -311,7 +311,7 @@ TEST_F(ChangeListLoaderTest, Lock) {
EXPECT_EQ(FILE_ERROR_OK, error);
// Add a new file.
- scoped_ptr<google_apis::ResourceEntry> file = AddNewFile("New File");
+ scoped_ptr<google_apis::FileResource> file = AddNewFile("New File");
ASSERT_TRUE(file);
// Lock the loader.
diff --git a/chrome/browser/chromeos/drive/directory_loader_unittest.cc b/chrome/browser/chromeos/drive/directory_loader_unittest.cc
index d4e5802..1de5266 100644
--- a/chrome/browser/chromeos/drive/directory_loader_unittest.cc
+++ b/chrome/browser/chromeos/drive/directory_loader_unittest.cc
@@ -109,9 +109,9 @@ class DirectoryLoaderTest : public testing::Test {
}
// Adds a new file to the root directory of the service.
- scoped_ptr<google_apis::ResourceEntry> AddNewFile(const std::string& title) {
+ scoped_ptr<google_apis::FileResource> AddNewFile(const std::string& title) {
google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR;
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
drive_service_->AddNewFile(
"text/plain",
"content text",
diff --git a/chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc b/chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc
index eaac7d8..4a702f1 100644
--- a/chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc
+++ b/chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc
@@ -18,7 +18,7 @@
#include "chrome/browser/drive/fake_drive_service.h"
#include "chrome/browser/drive/test_util.h"
#include "content/public/test/test_browser_thread_bundle.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
@@ -493,7 +493,7 @@ TEST_F(DriveFileStreamReaderTest, ZeroByteFileRead) {
// Prepare an empty file
{
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
fake_drive_service_->AddNewFile(
"text/plain",
"", // empty
diff --git a/chrome/browser/chromeos/drive/fake_file_system.cc b/chrome/browser/chromeos/drive/fake_file_system.cc
index 07dfafa..87a3a35 100644
--- a/chrome/browser/chromeos/drive/fake_file_system.cc
+++ b/chrome/browser/chromeos/drive/fake_file_system.cc
@@ -255,23 +255,23 @@ void FakeFileSystem::GetFileContentAfterGetResourceEntry(
return;
}
- // Fetch google_apis::ResourceEntry for its |download_url|.
- drive_service_->GetResourceEntry(
+ // Fetch google_apis::FileResource for its |download_url|.
+ drive_service_->GetFileResource(
entry->resource_id(),
base::Bind(
- &FakeFileSystem::GetFileContentAfterGetWapiResourceEntry,
+ &FakeFileSystem::GetFileContentAfterGetFileResource,
weak_ptr_factory_.GetWeakPtr(),
initialized_callback,
get_content_callback,
completion_callback));
}
-void FakeFileSystem::GetFileContentAfterGetWapiResourceEntry(
+void FakeFileSystem::GetFileContentAfterGetFileResource(
const GetFileContentInitializedCallback& initialized_callback,
const google_apis::GetContentCallback& get_content_callback,
const FileOperationCallback& completion_callback,
google_apis::GDataErrorCode gdata_error,
- scoped_ptr<google_apis::ResourceEntry> gdata_entry) {
+ scoped_ptr<google_apis::FileResource> gdata_entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
FileError error = GDataToFileError(gdata_error);
@@ -283,8 +283,9 @@ void FakeFileSystem::GetFileContentAfterGetWapiResourceEntry(
scoped_ptr<ResourceEntry> entry(new ResourceEntry);
std::string parent_resource_id;
- bool converted =
- ConvertToResourceEntry(*gdata_entry, entry.get(), &parent_resource_id);
+ bool converted = ConvertToResourceEntry(
+ *util::ConvertFileResourceToResourceEntry(*gdata_entry),
+ entry.get(), &parent_resource_id);
DCHECK(converted);
entry->set_parent_local_id(parent_resource_id);
@@ -300,7 +301,7 @@ void FakeFileSystem::GetFileContentAfterGetWapiResourceEntry(
initialized_callback.Run(FILE_ERROR_OK, base::FilePath(), entry.Pass());
drive_service_->DownloadFile(
cache_path,
- gdata_entry->resource_id(),
+ gdata_entry->file_id(),
base::Bind(&FakeFileSystem::GetFileContentAfterDownloadFile,
weak_ptr_factory_.GetWeakPtr(),
completion_callback),
diff --git a/chrome/browser/chromeos/drive/fake_file_system.h b/chrome/browser/chromeos/drive/fake_file_system.h
index 8abb723..5625cca 100644
--- a/chrome/browser/chromeos/drive/fake_file_system.h
+++ b/chrome/browser/chromeos/drive/fake_file_system.h
@@ -18,7 +18,7 @@
namespace google_apis {
class AboutResource;
-class ResourceEntry;
+class FileResource;
} // namespace google_apis
@@ -141,12 +141,12 @@ class FakeFileSystem : public FileSystemInterface {
const FileOperationCallback& completion_callback,
FileError error,
scoped_ptr<ResourceEntry> entry);
- void GetFileContentAfterGetWapiResourceEntry(
+ void GetFileContentAfterGetFileResource(
const GetFileContentInitializedCallback& initialized_callback,
const google_apis::GetContentCallback& get_content_callback,
const FileOperationCallback& completion_callback,
google_apis::GDataErrorCode gdata_error,
- scoped_ptr<google_apis::ResourceEntry> gdata_entry);
+ scoped_ptr<google_apis::FileResource> gdata_entry);
void GetFileContentAfterDownloadFile(
const FileOperationCallback& completion_callback,
google_apis::GDataErrorCode gdata_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 7722301..47dd9b3 100644
--- a/chrome/browser/chromeos/drive/file_system/copy_operation_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system/copy_operation_unittest.cc
@@ -11,7 +11,7 @@
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/drive/drive_api_util.h"
#include "chrome/browser/drive/fake_drive_service.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -179,7 +179,7 @@ TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_NewHostedDocument) {
// Create a hosted document on the server that is not synced to local yet.
google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> new_gdoc_entry;
+ scoped_ptr<google_apis::FileResource> new_gdoc_entry;
fake_service()->AddNewFile(
"application/vnd.google-apps.document", "", "", "title", true,
google_apis::test_util::CreateCopyResultCallback(&gdata_error,
@@ -190,8 +190,8 @@ TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_NewHostedDocument) {
// Prepare a local file, which is a json file of the added hosted document.
ASSERT_TRUE(util::CreateGDocFile(
local_src_path,
- GURL("https://3_document_self_link/" + new_gdoc_entry->resource_id()),
- new_gdoc_entry->resource_id()));
+ GURL("https://3_document_self_link/" + new_gdoc_entry->file_id()),
+ new_gdoc_entry->file_id()));
ResourceEntry entry;
ASSERT_EQ(FILE_ERROR_NOT_FOUND,
@@ -212,7 +212,7 @@ TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_NewHostedDocument) {
EXPECT_TRUE(
observer()->get_changed_paths().count(remote_dest_path.DirName()));
// The original document got new parent.
- EXPECT_EQ(new_gdoc_entry->resource_id(), entry.resource_id());
+ EXPECT_EQ(new_gdoc_entry->file_id(), entry.resource_id());
}
TEST_F(CopyOperationTest, CopyNotExistingFile) {
diff --git a/chrome/browser/chromeos/drive/file_system/search_operation_unittest.cc b/chrome/browser/chromeos/drive/file_system/search_operation_unittest.cc
index 9e4f944..72918dd 100644
--- a/chrome/browser/chromeos/drive/file_system/search_operation_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system/search_operation_unittest.cc
@@ -8,7 +8,7 @@
#include "chrome/browser/chromeos/drive/change_list_loader.h"
#include "chrome/browser/chromeos/drive/file_system/operation_test_base.h"
#include "chrome/browser/drive/fake_drive_service.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -52,16 +52,15 @@ TEST_F(SearchOperationTest, ContentSearchWithNewEntry) {
loader_controller());
// Create a new directory in the drive service.
- google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
+ google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
+ scoped_ptr<google_apis::FileResource> server_entry;
fake_service()->AddNewDirectory(
fake_service()->GetRootResourceId(),
"New Directory 1!",
DriveServiceInterface::AddNewDirectoryOptions(),
- google_apis::test_util::CreateCopyResultCallback(
- &gdata_error, &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
test_util::RunBlockingPoolTask();
- ASSERT_EQ(google_apis::HTTP_CREATED, gdata_error);
+ ASSERT_EQ(google_apis::HTTP_CREATED, status);
// As the result of the first Search(), only entries in the current file
// system snapshot are expected to be returned in the "right" path. New
diff --git a/chrome/browser/chromeos/drive/file_system_unittest.cc b/chrome/browser/chromeos/drive/file_system_unittest.cc
index b0f8aa8..74e26b5 100644
--- a/chrome/browser/chromeos/drive/file_system_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system_unittest.cc
@@ -329,16 +329,15 @@ TEST_F(FileSystemTest, Copy) {
ASSERT_TRUE(entry);
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
- fake_drive_service_->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_drive_service_->GetFileResource(
entry->resource_id(),
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
test_util::RunBlockingPoolTask();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_EQ(entry->title(), resource_entry->title());
- EXPECT_TRUE(resource_entry->is_file());
+ ASSERT_TRUE(server_entry);
+ EXPECT_EQ(entry->title(), server_entry->title());
+ EXPECT_FALSE(server_entry->IsDirectory());
}
TEST_F(FileSystemTest, Move) {
@@ -363,21 +362,17 @@ TEST_F(FileSystemTest, Move) {
ASSERT_TRUE(entry);
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
- fake_drive_service_->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_drive_service_->GetFileResource(
entry->resource_id(),
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
test_util::RunBlockingPoolTask();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_EQ(entry->title(), resource_entry->title());
-
- const google_apis::Link* parent_link =
- resource_entry->GetLinkByType(google_apis::Link::LINK_PARENT);
- ASSERT_TRUE(parent_link);
- EXPECT_EQ(parent->resource_id(),
- util::ExtractResourceIdFromUrl(parent_link->href()));
+ ASSERT_TRUE(server_entry);
+ EXPECT_EQ(entry->title(), server_entry->title());
+
+ ASSERT_FALSE(server_entry->parents().empty());
+ EXPECT_EQ(parent->resource_id(), server_entry->parents()[0].file_id());
}
TEST_F(FileSystemTest, Remove) {
@@ -395,15 +390,14 @@ TEST_F(FileSystemTest, Remove) {
// Entry is removed on the server.
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
- fake_drive_service_->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_drive_service_->GetFileResource(
entry->resource_id(),
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
test_util::RunBlockingPoolTask();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->deleted());
+ ASSERT_TRUE(server_entry);
+ EXPECT_TRUE(server_entry->labels().is_trashed());
}
TEST_F(FileSystemTest, CreateDirectory) {
@@ -424,16 +418,15 @@ TEST_F(FileSystemTest, CreateDirectory) {
ASSERT_TRUE(entry);
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
- fake_drive_service_->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_drive_service_->GetFileResource(
entry->resource_id(),
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
test_util::RunBlockingPoolTask();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_EQ(entry->title(), resource_entry->title());
- EXPECT_TRUE(resource_entry->is_folder());
+ ASSERT_TRUE(server_entry);
+ EXPECT_EQ(entry->title(), server_entry->title());
+ EXPECT_TRUE(server_entry->IsDirectory());
}
TEST_F(FileSystemTest, CreateFile) {
@@ -454,16 +447,15 @@ TEST_F(FileSystemTest, CreateFile) {
ASSERT_TRUE(entry);
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
- fake_drive_service_->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_drive_service_->GetFileResource(
entry->resource_id(),
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
test_util::RunBlockingPoolTask();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_EQ(entry->title(), resource_entry->title());
- EXPECT_TRUE(resource_entry->is_file());
+ ASSERT_TRUE(server_entry);
+ EXPECT_EQ(entry->title(), server_entry->title());
+ EXPECT_FALSE(server_entry->IsDirectory());
}
TEST_F(FileSystemTest, TouchFile) {
@@ -489,16 +481,15 @@ TEST_F(FileSystemTest, TouchFile) {
// File is touched on the server.
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
- fake_drive_service_->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_drive_service_->GetFileResource(
entry->resource_id(),
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
test_util::RunBlockingPoolTask();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_EQ(last_accessed, resource_entry->last_viewed_time());
- EXPECT_EQ(last_modified, resource_entry->updated_time());
+ ASSERT_TRUE(server_entry);
+ EXPECT_EQ(last_accessed, server_entry->last_viewed_by_me_date());
+ EXPECT_EQ(last_modified, server_entry->modified_date());
}
TEST_F(FileSystemTest, TruncateFile) {
@@ -518,15 +509,14 @@ TEST_F(FileSystemTest, TruncateFile) {
// File is touched on the server.
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
- fake_drive_service_->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_drive_service_->GetFileResource(
entry->resource_id(),
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
test_util::RunBlockingPoolTask();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_EQ(kLength, resource_entry->file_size());
+ ASSERT_TRUE(server_entry);
+ EXPECT_EQ(kLength, server_entry->file_size());
}
TEST_F(FileSystemTest, DuplicatedAsyncInitialization) {
diff --git a/chrome/browser/chromeos/drive/fileapi/webkit_file_stream_reader_impl_unittest.cc b/chrome/browser/chromeos/drive/fileapi/webkit_file_stream_reader_impl_unittest.cc
index 403ad62..8fb9881 100644
--- a/chrome/browser/chromeos/drive/fileapi/webkit_file_stream_reader_impl_unittest.cc
+++ b/chrome/browser/chromeos/drive/fileapi/webkit_file_stream_reader_impl_unittest.cc
@@ -19,7 +19,7 @@
#include "chrome/browser/drive/fake_drive_service.h"
#include "chrome/browser/drive/test_util.h"
#include "content/public/test/test_browser_thread_bundle.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/time_util.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
@@ -182,7 +182,7 @@ TEST_F(WebkitFileStreamReaderImplTest, LastModification) {
ASSERT_TRUE(entry);
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
+ scoped_ptr<google_apis::FileResource> server_entry;
fake_drive_service_->UpdateResource(
entry->resource_id(),
std::string(), // parent_resource_id
@@ -190,7 +190,7 @@ TEST_F(WebkitFileStreamReaderImplTest, LastModification) {
expected_modification_time,
base::Time(),
google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ &server_entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
diff --git a/chrome/browser/chromeos/drive/job_scheduler.cc b/chrome/browser/chromeos/drive/job_scheduler.cc
index 6bbfda8..f7e8927 100644
--- a/chrome/browser/chromeos/drive/job_scheduler.cc
+++ b/chrome/browser/chromeos/drive/job_scheduler.cc
@@ -391,10 +391,10 @@ void JobScheduler::GetResourceEntry(
JobEntry* new_job = CreateNewJob(TYPE_GET_RESOURCE_ENTRY);
new_job->context = context;
new_job->task = base::Bind(
- &DriveServiceInterface::GetResourceEntry,
+ &DriveServiceInterface::GetFileResource,
base::Unretained(drive_service_),
resource_id,
- base::Bind(&JobScheduler::OnGetResourceEntryJobDone,
+ base::Bind(&JobScheduler::OnGetFileResourceJobDone,
weak_ptr_factory_.GetWeakPtr(),
new_job->job_info.job_id,
callback));
@@ -463,7 +463,7 @@ void JobScheduler::CopyResource(
parent_resource_id,
new_title,
last_modified,
- base::Bind(&JobScheduler::OnGetResourceEntryJobDone,
+ base::Bind(&JobScheduler::OnGetFileResourceJobDone,
weak_ptr_factory_.GetWeakPtr(),
new_job->job_info.job_id,
callback));
@@ -492,7 +492,7 @@ void JobScheduler::UpdateResource(
new_title,
last_modified,
last_viewed_by_me,
- base::Bind(&JobScheduler::OnGetResourceEntryJobDone,
+ base::Bind(&JobScheduler::OnGetFileResourceJobDone,
weak_ptr_factory_.GetWeakPtr(),
new_job->job_info.job_id,
callback));
@@ -580,7 +580,7 @@ void JobScheduler::AddNewDirectory(
parent_resource_id,
directory_title,
options,
- base::Bind(&JobScheduler::OnGetResourceEntryJobDone,
+ base::Bind(&JobScheduler::OnGetFileResourceJobDone,
weak_ptr_factory_.GetWeakPtr(),
new_job->job_info.job_id,
callback));
@@ -930,16 +930,19 @@ void JobScheduler::OnGetChangeListJobDone(
}
}
-void JobScheduler::OnGetResourceEntryJobDone(
+void JobScheduler::OnGetFileResourceJobDone(
JobID job_id,
const google_apis::GetResourceEntryCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry) {
+ scoped_ptr<google_apis::FileResource> entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- if (OnJobDone(job_id, error))
- callback.Run(error, entry.Pass());
+ if (OnJobDone(job_id, error)) {
+ callback.Run(error, entry ?
+ util::ConvertFileResourceToResourceEntry(*entry) :
+ scoped_ptr<google_apis::ResourceEntry>());
+ }
}
void JobScheduler::OnGetAboutResourceJobDone(
diff --git a/chrome/browser/chromeos/drive/job_scheduler.h b/chrome/browser/chromeos/drive/job_scheduler.h
index 27bedf5..f28741c 100644
--- a/chrome/browser/chromeos/drive/job_scheduler.h
+++ b/chrome/browser/chromeos/drive/job_scheduler.h
@@ -289,12 +289,12 @@ class JobScheduler
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ChangeList> change_list);
- // Callback for job finishing with a GetResourceEntryCallback.
- void OnGetResourceEntryJobDone(
+ // Callback for job finishing with a FileResourceCallback.
+ void OnGetFileResourceJobDone(
JobID job_id,
const google_apis::GetResourceEntryCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry);
+ scoped_ptr<google_apis::FileResource> entry);
// Callback for job finishing with a AboutResourceCallback.
void OnGetAboutResourceJobDone(
diff --git a/chrome/browser/chromeos/drive/job_scheduler_unittest.cc b/chrome/browser/chromeos/drive/job_scheduler_unittest.cc
index 40ed5a2..3cfd4fa 100644
--- a/chrome/browser/chromeos/drive/job_scheduler_unittest.cc
+++ b/chrome/browser/chromeos/drive/job_scheduler_unittest.cc
@@ -274,13 +274,13 @@ TEST_F(JobSchedulerTest, GetChangeList) {
// Create a new directory.
{
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
+ scoped_ptr<google_apis::FileResource> entry;
fake_drive_service_->AddNewDirectory(
fake_drive_service_->GetRootResourceId(),
"new directory",
DriveServiceInterface::AddNewDirectoryOptions(),
google_apis::test_util::CreateCopyResultCallback(
- &error, &resource_entry));
+ &error, &entry));
base::RunLoop().RunUntilIdle();
ASSERT_EQ(google_apis::HTTP_CREATED, error);
}
diff --git a/chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc b/chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc
index 6481cb3..678e7ce 100644
--- a/chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc
+++ b/chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/drive/drive_api_util.h"
#include "chrome/browser/drive/fake_drive_service.h"
#include "google_apis/drive/drive_api_parser.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
#include "google_apis/drive/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -106,8 +105,8 @@ TEST_F(EntryUpdatePerformerTest, UpdateEntry) {
// Verify the file is updated on the server.
google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> gdata_entry;
- fake_service()->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> gdata_entry;
+ fake_service()->GetFileResource(
src_entry.resource_id(),
google_apis::test_util::CreateCopyResultCallback(&gdata_error,
&gdata_entry));
@@ -116,14 +115,11 @@ TEST_F(EntryUpdatePerformerTest, UpdateEntry) {
ASSERT_TRUE(gdata_entry);
EXPECT_EQ(src_entry.title(), gdata_entry->title());
- EXPECT_EQ(new_last_modified, gdata_entry->updated_time());
- EXPECT_EQ(new_last_accessed, gdata_entry->last_viewed_time());
-
- const google_apis::Link* parent_link =
- gdata_entry->GetLinkByType(google_apis::Link::LINK_PARENT);
- ASSERT_TRUE(parent_link);
- EXPECT_EQ(dest_entry.resource_id(),
- util::ExtractResourceIdFromUrl(parent_link->href()));
+ EXPECT_EQ(new_last_modified, gdata_entry->modified_date());
+ EXPECT_EQ(new_last_accessed, gdata_entry->last_viewed_by_me_date());
+
+ ASSERT_FALSE(gdata_entry->parents().empty());
+ EXPECT_EQ(dest_entry.resource_id(), gdata_entry->parents()[0].file_id());
}
// Tests updating metadata of a file with a non-dirty cache file.
@@ -175,8 +171,8 @@ TEST_F(EntryUpdatePerformerTest, UpdateEntry_WithNonDirtyCache) {
// Verify the file is updated on the server.
google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> gdata_entry;
- fake_service()->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> gdata_entry;
+ fake_service()->GetFileResource(
src_entry->resource_id(),
google_apis::test_util::CreateCopyResultCallback(&gdata_error,
&gdata_entry));
@@ -224,8 +220,8 @@ TEST_F(EntryUpdatePerformerTest, UpdateEntry_ContentUpdate) {
// Check that the file size is updated to that of the updated content.
google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> server_entry;
- fake_service()->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_service()->GetFileResource(
kResourceId,
google_apis::test_util::CreateCopyResultCallback(&gdata_error,
&server_entry));
@@ -268,8 +264,8 @@ TEST_F(EntryUpdatePerformerTest, UpdateEntry_ContentUpdateMd5Check) {
// Check that the file size is updated to that of the updated content.
google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> server_entry;
- fake_service()->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_service()->GetFileResource(
kResourceId,
google_apis::test_util::CreateCopyResultCallback(&gdata_error,
&server_entry));
@@ -418,15 +414,14 @@ TEST_F(EntryUpdatePerformerTest, UpdateEntry_UploadNewFile) {
// Make sure that we really created a file.
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
- fake_service()->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_service()->GetFileResource(
entry.resource_id(),
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
test_util::RunBlockingPoolTask();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_FALSE(resource_entry->is_folder());
+ ASSERT_TRUE(server_entry);
+ EXPECT_FALSE(server_entry->IsDirectory());
}
TEST_F(EntryUpdatePerformerTest, UpdateEntry_NewFileOpendForWrite) {
@@ -545,15 +540,14 @@ TEST_F(EntryUpdatePerformerTest, UpdateEntry_CreateDirectory) {
// Make sure that we really created a directory.
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
- fake_service()->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ fake_service()->GetFileResource(
entry.resource_id(),
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
test_util::RunBlockingPoolTask();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->is_folder());
+ ASSERT_TRUE(server_entry);
+ EXPECT_TRUE(server_entry->IsDirectory());
}
} // namespace internal
diff --git a/chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc b/chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc
index 043bfda..daec210 100644
--- a/chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc
+++ b/chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc
@@ -10,7 +10,7 @@
#include "chrome/browser/chromeos/drive/job_scheduler.h"
#include "chrome/browser/chromeos/drive/resource_metadata.h"
#include "chrome/browser/drive/fake_drive_service.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
namespace drive {
@@ -49,14 +49,14 @@ TEST_F(RemovePerformerTest, RemoveFile) {
// Verify the file is indeed removed in the server.
google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> gdata_entry;
- fake_service()->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> gdata_entry;
+ fake_service()->GetFileResource(
resource_id,
google_apis::test_util::CreateCopyResultCallback(&gdata_error,
&gdata_entry));
test_util::RunBlockingPoolTask();
ASSERT_EQ(google_apis::HTTP_SUCCESS, gdata_error);
- EXPECT_TRUE(gdata_entry->deleted());
+ EXPECT_TRUE(gdata_entry->labels().is_trashed());
// Try removing non-existing file.
error = FILE_ERROR_FAILED;
@@ -78,7 +78,7 @@ TEST_F(RemovePerformerTest, RemoveShared) {
// Prepare a shared file to the root folder.
google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> gdata_entry;
+ scoped_ptr<google_apis::FileResource> gdata_entry;
fake_service()->AddNewFile(
"text/plain",
"dummy content",
@@ -106,15 +106,15 @@ TEST_F(RemovePerformerTest, RemoveShared) {
// Remotely, the entry should have lost its parent.
gdata_error = google_apis::GDATA_OTHER_ERROR;
- const std::string resource_id = gdata_entry->resource_id();
- fake_service()->GetResourceEntry(
+ const std::string resource_id = gdata_entry->file_id();
+ fake_service()->GetFileResource(
resource_id,
google_apis::test_util::CreateCopyResultCallback(&gdata_error,
&gdata_entry));
test_util::RunBlockingPoolTask();
ASSERT_EQ(google_apis::HTTP_SUCCESS, gdata_error);
- EXPECT_FALSE(gdata_entry->deleted()); // It's not deleted.
- EXPECT_FALSE(gdata_entry->GetLinkByType(google_apis::Link::LINK_PARENT));
+ EXPECT_FALSE(gdata_entry->labels().is_trashed()); // It's not deleted.
+ EXPECT_TRUE(gdata_entry->parents().empty());
}
TEST_F(RemovePerformerTest, RemoveLocallyCreatedFile) {
diff --git a/chrome/browser/chromeos/drive/sync_client_unittest.cc b/chrome/browser/chromeos/drive/sync_client_unittest.cc
index a99b368..8f247bf 100644
--- a/chrome/browser/chromeos/drive/sync_client_unittest.cc
+++ b/chrome/browser/chromeos/drive/sync_client_unittest.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/drive/event_logger.h"
#include "chrome/browser/drive/fake_drive_service.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -163,7 +164,7 @@ class SyncClientTest : public testing::Test {
// Adds a file to the service root and |resource_ids_|.
void AddFileEntry(const std::string& title) {
google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR;
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
drive_service_->AddNewFile(
"text/plain",
kRemoteContent,
@@ -174,7 +175,7 @@ class SyncClientTest : public testing::Test {
base::RunLoop().RunUntilIdle();
ASSERT_EQ(google_apis::HTTP_CREATED, error);
ASSERT_TRUE(entry);
- resource_ids_[title] = entry->resource_id();
+ resource_ids_[title] = entry->file_id();
}
// Sets up data for tests.
@@ -296,26 +297,24 @@ TEST_F(SyncClientTest, StartProcessingBacklog) {
// Removed entry is not found.
google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
- drive_service_->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> server_entry;
+ drive_service_->GetFileResource(
resource_ids_["removed"],
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->deleted());
+ ASSERT_TRUE(server_entry);
+ EXPECT_TRUE(server_entry->labels().is_trashed());
// Moved entry was moved.
status = google_apis::GDATA_OTHER_ERROR;
- drive_service_->GetResourceEntry(
+ drive_service_->GetFileResource(
resource_ids_["moved"],
- google_apis::test_util::CreateCopyResultCallback(&status,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
- ASSERT_TRUE(resource_entry);
- EXPECT_EQ("moved_new_title", resource_entry->title());
+ ASSERT_TRUE(server_entry);
+ EXPECT_EQ("moved_new_title", server_entry->title());
}
TEST_F(SyncClientTest, AddFetchTask) {
diff --git a/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc b/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc
index 70e67f2a..77eccc2 100644
--- a/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc
+++ b/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc
@@ -25,6 +25,7 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
#include "google_apis/drive/time_util.h"
#include "webkit/browser/fileapi/external_mount_points.h"
@@ -123,7 +124,7 @@ bool InitializeLocalFileSystem(std::string mount_point_name,
return true;
}
-scoped_ptr<google_apis::ResourceEntry> UpdateDriveEntryTime(
+scoped_ptr<google_apis::FileResource> UpdateDriveEntryTime(
drive::FakeDriveService* fake_drive_service,
const std::string& resource_id,
const std::string& last_modified,
@@ -133,10 +134,10 @@ scoped_ptr<google_apis::ResourceEntry> UpdateDriveEntryTime(
&last_modified_time) ||
!google_apis::util::GetTimeFromString(last_viewed_by_me,
&last_viewed_by_me_time))
- return scoped_ptr<google_apis::ResourceEntry>();
+ return scoped_ptr<google_apis::FileResource>();
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
fake_drive_service->UpdateResource(
resource_id,
std::string(), // parent_resource_id
@@ -146,12 +147,12 @@ scoped_ptr<google_apis::ResourceEntry> UpdateDriveEntryTime(
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
if (error != google_apis::HTTP_SUCCESS)
- return scoped_ptr<google_apis::ResourceEntry>();
+ return scoped_ptr<google_apis::FileResource>();
return entry.Pass();
}
-scoped_ptr<google_apis::ResourceEntry> AddFileToDriveService(
+scoped_ptr<google_apis::FileResource> AddFileToDriveService(
drive::FakeDriveService* fake_drive_service,
const std::string& mime_type,
const std::string& content,
@@ -160,7 +161,7 @@ scoped_ptr<google_apis::ResourceEntry> AddFileToDriveService(
const std::string& last_modified,
const std::string& last_viewed_by_me) {
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
fake_drive_service->AddNewFile(
mime_type,
content,
@@ -170,20 +171,20 @@ scoped_ptr<google_apis::ResourceEntry> AddFileToDriveService(
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
if (error != google_apis::HTTP_CREATED)
- return scoped_ptr<google_apis::ResourceEntry>();
+ return scoped_ptr<google_apis::FileResource>();
- return UpdateDriveEntryTime(fake_drive_service, entry->resource_id(),
+ return UpdateDriveEntryTime(fake_drive_service, entry->file_id(),
last_modified, last_viewed_by_me);
}
-scoped_ptr<google_apis::ResourceEntry> AddDirectoryToDriveService(
+scoped_ptr<google_apis::FileResource> AddDirectoryToDriveService(
drive::FakeDriveService* fake_drive_service,
const std::string& parent_resource_id,
const std::string& title,
const std::string& last_modified,
const std::string& last_viewed_by_me) {
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
fake_drive_service->AddNewDirectory(
parent_resource_id,
title,
@@ -191,9 +192,9 @@ scoped_ptr<google_apis::ResourceEntry> AddDirectoryToDriveService(
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
if (error != google_apis::HTTP_CREATED)
- return scoped_ptr<google_apis::ResourceEntry>();
+ return scoped_ptr<google_apis::FileResource>();
- return UpdateDriveEntryTime(fake_drive_service, entry->resource_id(),
+ return UpdateDriveEntryTime(fake_drive_service, entry->file_id(),
last_modified, last_viewed_by_me);
}
@@ -202,7 +203,7 @@ scoped_ptr<google_apis::ResourceEntry> AddDirectoryToDriveService(
bool InitializeDriveService(
drive::FakeDriveService* fake_drive_service,
std::map<std::string, std::string>* out_resource_ids) {
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
entry = AddDirectoryToDriveService(fake_drive_service,
fake_drive_service->GetRootResourceId(),
@@ -211,7 +212,7 @@ bool InitializeDriveService(
"2012-01-02T00:00:01.000Z");
if (!entry)
return false;
- (*out_resource_ids)[entry->title()] = entry->resource_id();
+ (*out_resource_ids)[entry->title()] = entry->file_id();
entry = AddDirectoryToDriveService(fake_drive_service,
(*out_resource_ids)["test_dir"],
@@ -220,7 +221,7 @@ bool InitializeDriveService(
"2011-11-02T04:00:00.000Z");
if (!entry)
return false;
- (*out_resource_ids)[entry->title()] = entry->resource_id();
+ (*out_resource_ids)[entry->title()] = entry->file_id();
entry = AddDirectoryToDriveService(fake_drive_service,
(*out_resource_ids)["test_dir"],
@@ -229,7 +230,7 @@ bool InitializeDriveService(
"2012-01-02T00:00:01.000Z");
if (!entry)
return false;
- (*out_resource_ids)[entry->title()] = entry->resource_id();
+ (*out_resource_ids)[entry->title()] = entry->file_id();
entry = AddFileToDriveService(fake_drive_service,
"application/vnd.mozilla.xul+xml",
@@ -240,7 +241,7 @@ bool InitializeDriveService(
"2012-01-02T00:00:00.000Z");
if (!entry)
return false;
- (*out_resource_ids)[entry->title()] = entry->resource_id();
+ (*out_resource_ids)[entry->title()] = entry->file_id();
entry = AddFileToDriveService(fake_drive_service,
"test/ro",
@@ -251,7 +252,7 @@ bool InitializeDriveService(
"2012-01-01T00:00:00.000Z");
if (!entry)
return false;
- (*out_resource_ids)[entry->title()] = entry->resource_id();
+ (*out_resource_ids)[entry->title()] = entry->file_id();
entry = AddFileToDriveService(fake_drive_service,
"image/tiff",
@@ -262,7 +263,7 @@ bool InitializeDriveService(
"2012-01-02T00:00:00.000Z");
if (!entry)
return false;
- (*out_resource_ids)[entry->title()] = entry->resource_id();
+ (*out_resource_ids)[entry->title()] = entry->file_id();
entry = AddFileToDriveService(fake_drive_service,
"test/rw",
@@ -273,7 +274,7 @@ bool InitializeDriveService(
"2010-01-02T00:00:00.000Z");
if (!entry)
return false;
- (*out_resource_ids)[entry->title()] = entry->resource_id();
+ (*out_resource_ids)[entry->title()] = entry->file_id();
entry = AddFileToDriveService(fake_drive_service,
"test/rw",
@@ -284,7 +285,7 @@ bool InitializeDriveService(
"2011-12-14T00:40:47.330Z");
if (!entry)
return false;
- (*out_resource_ids)[entry->title()] = entry->resource_id();
+ (*out_resource_ids)[entry->title()] = entry->file_id();
return true;
}
@@ -568,7 +569,7 @@ class MultiProfileDriveFileSystemExtensionApiTest :
drive::util::GetDriveServiceByProfile(second_profile));
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
// Place a hosted document under root/test_dir of the sub profile.
sub_service->AddNewFileWithResourceId(
diff --git a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc
index 5fbb381..3db922d 100644
--- a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc
+++ b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc
@@ -54,7 +54,7 @@
#include "content/public/test/test_utils.h"
#include "extensions/browser/api/test/test_api.h"
#include "extensions/common/extension.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "webkit/browser/fileapi/external_mount_points.h"
@@ -388,25 +388,23 @@ class DriveTestVolume : public TestVolume {
const std::string& target_name,
const base::Time& modification_time) {
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
+ scoped_ptr<google_apis::FileResource> entry;
fake_drive_service_->AddNewDirectory(
parent_id,
target_name,
drive::DriveServiceInterface::AddNewDirectoryOptions(),
- google_apis::test_util::CreateCopyResultCallback(&error,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::MessageLoop::current()->RunUntilIdle();
ASSERT_EQ(google_apis::HTTP_CREATED, error);
- ASSERT_TRUE(resource_entry);
+ ASSERT_TRUE(entry);
fake_drive_service_->SetLastModifiedTime(
- resource_entry->resource_id(),
+ entry->file_id(),
modification_time,
- google_apis::test_util::CreateCopyResultCallback(&error,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::MessageLoop::current()->RunUntilIdle();
ASSERT_TRUE(error == google_apis::HTTP_SUCCESS);
- ASSERT_TRUE(resource_entry);
+ ASSERT_TRUE(entry);
CheckForUpdates();
}
@@ -428,27 +426,25 @@ class DriveTestVolume : public TestVolume {
ASSERT_TRUE(base::ReadFileToString(source_file_path, &content_data));
}
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
+ scoped_ptr<google_apis::FileResource> entry;
fake_drive_service_->AddNewFile(
mime_type,
content_data,
parent_id,
target_name,
shared_with_me,
- google_apis::test_util::CreateCopyResultCallback(&error,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::MessageLoop::current()->RunUntilIdle();
ASSERT_EQ(google_apis::HTTP_CREATED, error);
- ASSERT_TRUE(resource_entry);
+ ASSERT_TRUE(entry);
fake_drive_service_->SetLastModifiedTime(
- resource_entry->resource_id(),
+ entry->file_id(),
modification_time,
- google_apis::test_util::CreateCopyResultCallback(&error,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::MessageLoop::current()->RunUntilIdle();
ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
- ASSERT_TRUE(resource_entry);
+ ASSERT_TRUE(entry);
CheckForUpdates();
}
diff --git a/chrome/browser/drive/drive_api_service.cc b/chrome/browser/drive/drive_api_service.cc
index bb3a4a1..8a0fd9c 100644
--- a/chrome/browser/drive/drive_api_service.cc
+++ b/chrome/browser/drive/drive_api_service.cc
@@ -38,11 +38,11 @@ using google_apis::EntryActionCallback;
using google_apis::FileList;
using google_apis::FileListCallback;
using google_apis::FileResource;
+using google_apis::FileResourceCallback;
using google_apis::GDATA_OTHER_ERROR;
using google_apis::GDATA_PARSE_ERROR;
using google_apis::GDataErrorCode;
using google_apis::GetContentCallback;
-using google_apis::GetResourceEntryCallback;
using google_apis::GetResourceEntryRequest;
using google_apis::GetShareUrlCallback;
using google_apis::HTTP_NOT_IMPLEMENTED;
@@ -123,31 +123,6 @@ const char kChangeListFields[] =
"lastViewedByMeDate,shared),deleted,id,fileId,modificationDate),nextLink,"
"largestChangeId";
-// Converts the FileResource value to ResourceEntry and runs |callback| on the
-// UI thread.
-void ConvertFileEntryToResourceEntryAndRun(
- const GetResourceEntryCallback& callback,
- GDataErrorCode error,
- scoped_ptr<FileResource> value) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!callback.is_null());
-
- if (!value) {
- callback.Run(error, scoped_ptr<ResourceEntry>());
- return;
- }
-
- // Converting to ResourceEntry is cheap enough to do on UI thread.
- scoped_ptr<ResourceEntry> entry =
- util::ConvertFileResourceToResourceEntry(*value);
- if (!entry) {
- callback.Run(GDATA_PARSE_ERROR, scoped_ptr<ResourceEntry>());
- return;
- }
-
- callback.Run(error, entry.Pass());
-}
-
// Converts the FileResource value to ResourceEntry for upload range request,
// and runs |callback| on the UI thread.
void ConvertFileResourceToResourceEntryForUploadRangeAndRun(
@@ -401,15 +376,14 @@ CancelCallback DriveAPIService::GetRemainingFileList(
return sender_->StartRequestWithRetry(request);
}
-CancelCallback DriveAPIService::GetResourceEntry(
+CancelCallback DriveAPIService::GetFileResource(
const std::string& resource_id,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
FilesGetRequest* request = new FilesGetRequest(
- sender_.get(), url_generator_,
- base::Bind(&ConvertFileEntryToResourceEntryAndRun, callback));
+ sender_.get(), url_generator_, callback);
request->set_file_id(resource_id);
request->set_fields(kFileResourceFields);
return sender_->StartRequestWithRetry(request);
@@ -508,13 +482,12 @@ CancelCallback DriveAPIService::AddNewDirectory(
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
FilesInsertRequest* request = new FilesInsertRequest(
- sender_.get(), url_generator_,
- base::Bind(&ConvertFileEntryToResourceEntryAndRun, callback));
+ sender_.get(), url_generator_, callback);
request->set_last_viewed_by_me_date(options.last_viewed_by_me_date);
request->set_mime_type(kFolderMimeType);
request->set_modified_date(options.modified_date);
@@ -529,13 +502,12 @@ CancelCallback DriveAPIService::CopyResource(
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
FilesCopyRequest* request = new FilesCopyRequest(
- sender_.get(), url_generator_,
- base::Bind(&ConvertFileEntryToResourceEntryAndRun, callback));
+ sender_.get(), url_generator_, callback);
request->set_file_id(resource_id);
request->add_parent(parent_resource_id);
request->set_title(new_title);
@@ -550,13 +522,12 @@ CancelCallback DriveAPIService::UpdateResource(
const std::string& new_title,
const base::Time& last_modified,
const base::Time& last_viewed_by_me,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
FilesPatchRequest* request = new FilesPatchRequest(
- sender_.get(), url_generator_,
- base::Bind(&ConvertFileEntryToResourceEntryAndRun, callback));
+ sender_.get(), url_generator_, callback);
request->set_file_id(resource_id);
request->set_title(new_title);
if (!parent_resource_id.empty())
diff --git a/chrome/browser/drive/drive_api_service.h b/chrome/browser/drive/drive_api_service.h
index 7f448608..4d3dc0c 100644
--- a/chrome/browser/drive/drive_api_service.h
+++ b/chrome/browser/drive/drive_api_service.h
@@ -95,9 +95,9 @@ class DriveAPIService : public DriveServiceInterface,
virtual google_apis::CancelCallback GetRemainingFileList(
const GURL& next_link,
const google_apis::FileListCallback& callback) OVERRIDE;
- virtual google_apis::CancelCallback GetResourceEntry(
+ virtual google_apis::CancelCallback GetFileResource(
const std::string& resource_id,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetShareUrl(
const std::string& resource_id,
const GURL& embed_origin,
@@ -124,14 +124,14 @@ class DriveAPIService : public DriveServiceInterface,
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
const base::Time& last_viewed_by_me,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback RenameResource(
const std::string& resource_id,
const std::string& new_title,
@@ -148,7 +148,7 @@ class DriveAPIService : public DriveServiceInterface,
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback InitiateUploadNewFile(
const std::string& content_type,
int64 content_length,
diff --git a/chrome/browser/drive/drive_service_interface.h b/chrome/browser/drive/drive_service_interface.h
index 619c8b2..7f78bb9 100644
--- a/chrome/browser/drive/drive_service_interface.h
+++ b/chrome/browser/drive/drive_service_interface.h
@@ -220,13 +220,13 @@ class DriveServiceInterface {
const GURL& next_link,
const google_apis::FileListCallback& callback) = 0;
- // Fetches single entry metadata from server. The entry's resource id equals
+ // Fetches single entry metadata from server. The entry's file id equals
// |resource_id|.
// Upon completion, invokes |callback| with results on the calling thread.
// |callback| must not be null.
- virtual google_apis::CancelCallback GetResourceEntry(
+ virtual google_apis::CancelCallback GetFileResource(
const std::string& resource_id,
- const google_apis::GetResourceEntryCallback& callback) = 0;
+ const google_apis::FileResourceCallback& callback) = 0;
// Fetches an url for the sharing dialog for a single entry with id
// |resource_id|, to be embedded in a webview or an iframe with origin
@@ -280,7 +280,7 @@ class DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
- const google_apis::GetResourceEntryCallback& callback) = 0;
+ const google_apis::FileResourceCallback& callback) = 0;
// Updates a resource with |resource_id| to the directory of
// |parent_resource_id| with renaming to |new_title|.
@@ -296,7 +296,7 @@ class DriveServiceInterface {
const std::string& new_title,
const base::Time& last_modified,
const base::Time& last_viewed_by_me,
- const google_apis::GetResourceEntryCallback& callback) = 0;
+ const google_apis::FileResourceCallback& callback) = 0;
// Renames a document or collection identified by its |resource_id|
// to the UTF-8 encoded |new_title|. Upon completion,
@@ -337,7 +337,7 @@ class DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const google_apis::GetResourceEntryCallback& callback) = 0;
+ const google_apis::FileResourceCallback& callback) = 0;
// Downloads a file with |resourced_id|. The downloaded file will
// be stored at |local_cache_path| location. Upon completion, invokes
diff --git a/chrome/browser/drive/dummy_drive_service.cc b/chrome/browser/drive/dummy_drive_service.cc
index 9a841f49..d3d89d0 100644
--- a/chrome/browser/drive/dummy_drive_service.cc
+++ b/chrome/browser/drive/dummy_drive_service.cc
@@ -16,8 +16,8 @@ using google_apis::ChangeListCallback;
using google_apis::DownloadActionCallback;
using google_apis::EntryActionCallback;
using google_apis::FileListCallback;
+using google_apis::FileResourceCallback;
using google_apis::GetContentCallback;
-using google_apis::GetResourceEntryCallback;
using google_apis::GetShareUrlCallback;
using google_apis::InitiateUploadCallback;
using google_apis::ProgressCallback;
@@ -85,9 +85,9 @@ CancelCallback DummyDriveService::GetRemainingFileList(
const GURL& next_link,
const FileListCallback& callback) { return CancelCallback(); }
-CancelCallback DummyDriveService::GetResourceEntry(
+CancelCallback DummyDriveService::GetFileResource(
const std::string& resource_id,
- const GetResourceEntryCallback& callback) { return CancelCallback(); }
+ const FileResourceCallback& callback) { return CancelCallback(); }
CancelCallback DummyDriveService::GetShareUrl(
const std::string& resource_id,
@@ -121,7 +121,7 @@ CancelCallback DummyDriveService::CopyResource(
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
- const GetResourceEntryCallback& callback) { return CancelCallback(); }
+ const FileResourceCallback& callback) { return CancelCallback(); }
CancelCallback DummyDriveService::UpdateResource(
const std::string& resource_id,
@@ -129,7 +129,7 @@ CancelCallback DummyDriveService::UpdateResource(
const std::string& new_title,
const base::Time& last_modified,
const base::Time& last_viewed_by_me,
- const google_apis::GetResourceEntryCallback& callback) {
+ const google_apis::FileResourceCallback& callback) {
return CancelCallback();
}
@@ -152,7 +152,7 @@ CancelCallback DummyDriveService::AddNewDirectory(
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const GetResourceEntryCallback& callback) { return CancelCallback(); }
+ const FileResourceCallback& callback) { return CancelCallback(); }
CancelCallback DummyDriveService::InitiateUploadNewFile(
const std::string& content_type,
diff --git a/chrome/browser/drive/dummy_drive_service.h b/chrome/browser/drive/dummy_drive_service.h
index 5792456..520a761 100644
--- a/chrome/browser/drive/dummy_drive_service.h
+++ b/chrome/browser/drive/dummy_drive_service.h
@@ -51,9 +51,9 @@ class DummyDriveService : public DriveServiceInterface {
virtual google_apis::CancelCallback GetRemainingFileList(
const GURL& next_link,
const google_apis::FileListCallback& callback) OVERRIDE;
- virtual google_apis::CancelCallback GetResourceEntry(
+ virtual google_apis::CancelCallback GetFileResource(
const std::string& resource_id,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetShareUrl(
const std::string& resource_id,
const GURL& embed_origin,
@@ -80,14 +80,14 @@ class DummyDriveService : public DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
const base::Time& last_viewed_by_me,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback RenameResource(
const std::string& resource_id,
const std::string& new_title,
@@ -104,7 +104,7 @@ class DummyDriveService : public DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback InitiateUploadNewFile(
const std::string& content_type,
int64 content_length,
diff --git a/chrome/browser/drive/fake_drive_service.cc b/chrome/browser/drive/fake_drive_service.cc
index fcba154..f36f149 100644
--- a/chrome/browser/drive/fake_drive_service.cc
+++ b/chrome/browser/drive/fake_drive_service.cc
@@ -41,6 +41,7 @@ using google_apis::EntryActionCallback;
using google_apis::FileList;
using google_apis::FileListCallback;
using google_apis::FileResource;
+using google_apis::FileResourceCallback;
using google_apis::GDATA_FILE_ERROR;
using google_apis::GDATA_NO_CONNECTION;
using google_apis::GDATA_OTHER_ERROR;
@@ -119,7 +120,7 @@ void ScheduleUploadRangeCallback(const UploadRangeCallback& callback,
void EntryActionCallbackAdapter(
const EntryActionCallback& callback,
- GDataErrorCode error, scoped_ptr<ResourceEntry> resource_entry) {
+ GDataErrorCode error, scoped_ptr<FileResource> file) {
callback.Run(error);
}
@@ -426,36 +427,34 @@ CancelCallback FakeDriveService::GetRemainingFileList(
next_link, base::Bind(&FileListCallbackAdapter, callback));
}
-CancelCallback FakeDriveService::GetResourceEntry(
+CancelCallback FakeDriveService::GetFileResource(
const std::string& resource_id,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
if (offline_) {
- scoped_ptr<ResourceEntry> null;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(callback,
GDATA_NO_CONNECTION,
- base::Passed(&null)));
+ base::Passed(scoped_ptr<FileResource>())));
return CancelCallback();
}
EntryInfo* entry = FindEntryByResourceId(resource_id);
- if (entry) {
- scoped_ptr<ResourceEntry> resource_entry =
- util::ConvertChangeResourceToResourceEntry(entry->change_resource);
+ if (entry && entry->change_resource.file()) {
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_entry)));
+ base::Bind(callback, HTTP_SUCCESS, base::Passed(make_scoped_ptr(
+ new FileResource(*entry->change_resource.file())))));
return CancelCallback();
}
- scoped_ptr<ResourceEntry> null;
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, HTTP_NOT_FOUND, base::Passed(&null)));
+ base::Bind(callback, HTTP_NOT_FOUND,
+ base::Passed(scoped_ptr<FileResource>())));
return CancelCallback();
}
@@ -688,17 +687,16 @@ CancelCallback FakeDriveService::CopyResource(
const std::string& in_parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
if (offline_) {
- scoped_ptr<ResourceEntry> null;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(callback,
GDATA_NO_CONNECTION,
- base::Passed(&null)));
+ base::Passed(scoped_ptr<FileResource>())));
return CancelCallback();
}
@@ -734,8 +732,6 @@ CancelCallback FakeDriveService::CopyResource(
AddNewChangestamp(new_change);
UpdateETag(new_file);
- scoped_ptr<ResourceEntry> resource_entry =
- util::ConvertChangeResourceToResourceEntry(*new_change);
// Add the new entry to the map.
entries_[new_resource_id] = copied_entry.release();
@@ -743,14 +739,14 @@ CancelCallback FakeDriveService::CopyResource(
FROM_HERE,
base::Bind(callback,
HTTP_SUCCESS,
- base::Passed(&resource_entry)));
+ base::Passed(make_scoped_ptr(new FileResource(*new_file)))));
return CancelCallback();
}
- scoped_ptr<ResourceEntry> null;
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, HTTP_NOT_FOUND, base::Passed(&null)));
+ base::Bind(callback, HTTP_NOT_FOUND,
+ base::Passed(scoped_ptr<FileResource>())));
return CancelCallback();
}
@@ -760,14 +756,14 @@ CancelCallback FakeDriveService::UpdateResource(
const std::string& new_title,
const base::Time& last_modified,
const base::Time& last_viewed_by_me,
- const google_apis::GetResourceEntryCallback& callback) {
+ const google_apis::FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
if (offline_) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(callback, GDATA_NO_CONNECTION,
- base::Passed(scoped_ptr<ResourceEntry>())));
+ base::Passed(scoped_ptr<FileResource>())));
return CancelCallback();
}
@@ -799,18 +795,17 @@ CancelCallback FakeDriveService::UpdateResource(
AddNewChangestamp(change);
UpdateETag(file);
- scoped_ptr<ResourceEntry> resource_entry =
- util::ConvertChangeResourceToResourceEntry(*change);
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_entry)));
+ base::Bind(callback, HTTP_SUCCESS,
+ base::Passed(make_scoped_ptr(new FileResource(*file)))));
return CancelCallback();
}
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(callback, HTTP_NOT_FOUND,
- base::Passed(scoped_ptr<ResourceEntry>())));
+ base::Passed(scoped_ptr<FileResource>())));
return CancelCallback();
}
@@ -900,7 +895,7 @@ CancelCallback FakeDriveService::AddNewDirectory(
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
return AddNewDirectoryWithResourceId(
"",
parent_resource_id.empty() ? GetRootResourceId() : parent_resource_id,
@@ -1159,7 +1154,7 @@ void FakeDriveService::AddNewFile(const std::string& content_type,
const std::string& parent_resource_id,
const std::string& title,
bool shared_with_me,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
AddNewFileWithResourceId("", content_type, content_data, parent_resource_id,
title, shared_with_me, callback);
}
@@ -1171,17 +1166,16 @@ void FakeDriveService::AddNewFileWithResourceId(
const std::string& parent_resource_id,
const std::string& title,
bool shared_with_me,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
if (offline_) {
- scoped_ptr<ResourceEntry> null;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(callback,
GDATA_NO_CONNECTION,
- base::Passed(&null)));
+ base::Passed(scoped_ptr<FileResource>())));
return;
}
@@ -1192,18 +1186,18 @@ void FakeDriveService::AddNewFileWithResourceId(
title,
shared_with_me);
if (!new_entry) {
- scoped_ptr<ResourceEntry> null;
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, HTTP_NOT_FOUND, base::Passed(&null)));
+ base::Bind(callback, HTTP_NOT_FOUND,
+ base::Passed(scoped_ptr<FileResource>())));
return;
}
- scoped_ptr<ResourceEntry> parsed_entry(
- util::ConvertChangeResourceToResourceEntry(new_entry->change_resource));
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, HTTP_CREATED, base::Passed(&parsed_entry)));
+ base::Bind(callback, HTTP_CREATED,
+ base::Passed(make_scoped_ptr(
+ new FileResource(*new_entry->change_resource.file())))));
}
CancelCallback FakeDriveService::AddNewDirectoryWithResourceId(
@@ -1211,17 +1205,16 @@ CancelCallback FakeDriveService::AddNewDirectoryWithResourceId(
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
if (offline_) {
- scoped_ptr<ResourceEntry> null;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(callback,
GDATA_NO_CONNECTION,
- base::Passed(&null)));
+ base::Passed(scoped_ptr<FileResource>())));
return CancelCallback();
}
@@ -1232,44 +1225,43 @@ CancelCallback FakeDriveService::AddNewDirectoryWithResourceId(
directory_title,
false); // shared_with_me
if (!new_entry) {
- scoped_ptr<ResourceEntry> null;
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, HTTP_NOT_FOUND, base::Passed(&null)));
+ base::Bind(callback, HTTP_NOT_FOUND,
+ base::Passed(scoped_ptr<FileResource>())));
return CancelCallback();
}
- scoped_ptr<ResourceEntry> parsed_entry(
- util::ConvertChangeResourceToResourceEntry(new_entry->change_resource));
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, HTTP_CREATED, base::Passed(&parsed_entry)));
+ base::Bind(callback, HTTP_CREATED,
+ base::Passed(make_scoped_ptr(
+ new FileResource(*new_entry->change_resource.file())))));
return CancelCallback();
}
void FakeDriveService::SetLastModifiedTime(
const std::string& resource_id,
const base::Time& last_modified_time,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
if (offline_) {
- scoped_ptr<ResourceEntry> null;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(callback,
GDATA_NO_CONNECTION,
- base::Passed(&null)));
+ base::Passed(scoped_ptr<FileResource>())));
return;
}
EntryInfo* entry = FindEntryByResourceId(resource_id);
if (!entry) {
- scoped_ptr<ResourceEntry> null;
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, HTTP_NOT_FOUND, base::Passed(&null)));
+ base::Bind(callback, HTTP_NOT_FOUND,
+ base::Passed(scoped_ptr<FileResource>())));
return;
}
@@ -1277,11 +1269,10 @@ void FakeDriveService::SetLastModifiedTime(
FileResource* file = change->mutable_file();
file->set_modified_date(last_modified_time);
- scoped_ptr<ResourceEntry> parsed_entry(
- util::ConvertChangeResourceToResourceEntry(*change));
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, HTTP_SUCCESS, base::Passed(&parsed_entry)));
+ base::Bind(callback, HTTP_SUCCESS,
+ base::Passed(make_scoped_ptr(new FileResource(*file)))));
}
FakeDriveService::EntryInfo* FakeDriveService::FindEntryByResourceId(
diff --git a/chrome/browser/drive/fake_drive_service.h b/chrome/browser/drive/fake_drive_service.h
index 8abcac8..165ff1c 100644
--- a/chrome/browser/drive/fake_drive_service.h
+++ b/chrome/browser/drive/fake_drive_service.h
@@ -137,9 +137,9 @@ class FakeDriveService : public DriveServiceInterface {
virtual google_apis::CancelCallback GetRemainingFileList(
const GURL& next_link,
const google_apis::FileListCallback& callback) OVERRIDE;
- virtual google_apis::CancelCallback GetResourceEntry(
+ virtual google_apis::CancelCallback GetFileResource(
const std::string& resource_id,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetShareUrl(
const std::string& resource_id,
const GURL& embed_origin,
@@ -166,14 +166,14 @@ class FakeDriveService : public DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
const base::Time& last_viewed_by_me,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback RenameResource(
const std::string& resource_id,
const std::string& new_title,
@@ -190,7 +190,7 @@ class FakeDriveService : public DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback InitiateUploadNewFile(
const std::string& content_type,
int64 content_length,
@@ -238,7 +238,7 @@ class FakeDriveService : public DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& title,
bool shared_with_me,
- const google_apis::GetResourceEntryCallback& callback);
+ const google_apis::FileResourceCallback& callback);
// Adds a new file with the given |resource_id|. If the id already exists,
// it's an error. This is used for testing cross profile file sharing that
@@ -251,7 +251,7 @@ class FakeDriveService : public DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& title,
bool shared_with_me,
- const google_apis::GetResourceEntryCallback& callback);
+ const google_apis::FileResourceCallback& callback);
// Adds a new directory with the given |resource_id|.
// |callback| must not be null.
@@ -260,7 +260,7 @@ class FakeDriveService : public DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const google_apis::GetResourceEntryCallback& callback);
+ const google_apis::FileResourceCallback& callback);
// Sets the last modified time for an entry specified by |resource_id|.
// On success, returns HTTP_SUCCESS with the parsed entry.
@@ -268,7 +268,7 @@ class FakeDriveService : public DriveServiceInterface {
void SetLastModifiedTime(
const std::string& resource_id,
const base::Time& last_modified_time,
- const google_apis::GetResourceEntryCallback& callback);
+ const google_apis::FileResourceCallback& callback);
private:
struct EntryInfo;
diff --git a/chrome/browser/drive/fake_drive_service_unittest.cc b/chrome/browser/drive/fake_drive_service_unittest.cc
index 0c23e4c..931d44d 100644
--- a/chrome/browser/drive/fake_drive_service_unittest.cc
+++ b/chrome/browser/drive/fake_drive_service_unittest.cc
@@ -27,6 +27,7 @@ using google_apis::AppList;
using google_apis::ChangeList;
using google_apis::ChangeResource;
using google_apis::FileList;
+using google_apis::FileResource;
using google_apis::GDATA_NO_CONNECTION;
using google_apis::GDATA_OTHER_ERROR;
using google_apis::GDataErrorCode;
@@ -59,20 +60,19 @@ namespace {
class FakeDriveServiceTest : public testing::Test {
protected:
// Returns the resource entry that matches |resource_id|.
- scoped_ptr<ResourceEntry> FindEntry(const std::string& resource_id) {
+ scoped_ptr<FileResource> FindEntry(const std::string& resource_id) {
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
- fake_service_.GetResourceEntry(
- resource_id,
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ scoped_ptr<FileResource> entry;
+ fake_service_.GetFileResource(
+ resource_id, test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
- return resource_entry.Pass();
+ return entry.Pass();
}
// Returns true if the resource identified by |resource_id| exists.
bool Exists(const std::string& resource_id) {
- scoped_ptr<ResourceEntry> resource_entry = FindEntry(resource_id);
- return resource_entry && !resource_entry->deleted();
+ scoped_ptr<FileResource> entry = FindEntry(resource_id);
+ return entry && !entry->labels().is_trashed();
}
// Adds a new directory at |parent_resource_id| with the given name.
@@ -80,12 +80,12 @@ class FakeDriveServiceTest : public testing::Test {
bool AddNewDirectory(const std::string& parent_resource_id,
const std::string& directory_title) {
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewDirectory(
parent_resource_id,
directory_title,
DriveServiceInterface::AddNewDirectoryOptions(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
return error == HTTP_CREATED;
}
@@ -93,12 +93,10 @@ class FakeDriveServiceTest : public testing::Test {
// Returns true if the resource identified by |resource_id| has a parent
// identified by |parent_id|.
bool HasParent(const std::string& resource_id, const std::string& parent_id) {
- const GURL parent_url = FakeDriveService::GetFakeLinkUrl(parent_id);
- scoped_ptr<ResourceEntry> resource_entry = FindEntry(resource_id);
- if (resource_entry.get()) {
- for (size_t i = 0; i < resource_entry->links().size(); ++i) {
- if (resource_entry->links()[i]->type() == Link::LINK_PARENT &&
- resource_entry->links()[i]->href() == parent_url)
+ scoped_ptr<FileResource> entry = FindEntry(resource_id);
+ if (entry) {
+ for (size_t i = 0; i < entry->parents().size(); ++i) {
+ if (entry->parents()[i].file_id() == parent_id)
return true;
}
}
@@ -767,52 +765,49 @@ TEST_F(FakeDriveServiceTest, GetAppList_Offline) {
EXPECT_FALSE(app_list);
}
-TEST_F(FakeDriveServiceTest, GetResourceEntry_ExistingFile) {
+TEST_F(FakeDriveServiceTest, GetFileResource_ExistingFile) {
ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
const std::string kResourceId = "file:2_file_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
- fake_service_.GetResourceEntry(
- kResourceId,
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ scoped_ptr<FileResource> entry;
+ fake_service_.GetFileResource(
+ kResourceId, test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_SUCCESS, error);
- ASSERT_TRUE(resource_entry);
+ ASSERT_TRUE(entry);
// Do some sanity check.
- EXPECT_EQ(kResourceId, resource_entry->resource_id());
+ EXPECT_EQ(kResourceId, entry->file_id());
}
-TEST_F(FakeDriveServiceTest, GetResourceEntry_NonexistingFile) {
+TEST_F(FakeDriveServiceTest, GetFileResource_NonexistingFile) {
ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
const std::string kResourceId = "file:nonexisting_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
- fake_service_.GetResourceEntry(
- kResourceId,
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ scoped_ptr<FileResource> entry;
+ fake_service_.GetFileResource(
+ kResourceId, test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_NOT_FOUND, error);
- ASSERT_FALSE(resource_entry);
+ ASSERT_FALSE(entry);
}
-TEST_F(FakeDriveServiceTest, GetResourceEntry_Offline) {
+TEST_F(FakeDriveServiceTest, GetFileResource_Offline) {
ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
fake_service_.set_offline(true);
const std::string kResourceId = "file:2_file_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
- fake_service_.GetResourceEntry(
- kResourceId,
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ scoped_ptr<FileResource> entry;
+ fake_service_.GetFileResource(
+ kResourceId, test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(GDATA_NO_CONNECTION, error);
- EXPECT_FALSE(resource_entry);
+ EXPECT_FALSE(entry);
}
TEST_F(FakeDriveServiceTest, GetShareUrl) {
@@ -872,9 +867,9 @@ TEST_F(FakeDriveServiceTest, DeleteResource_ETagMatch) {
ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
// Resource "file:2_file_resource_id" should now exist.
- scoped_ptr<ResourceEntry> entry = FindEntry("file:2_file_resource_id");
+ scoped_ptr<FileResource> entry = FindEntry("file:2_file_resource_id");
ASSERT_TRUE(entry);
- ASSERT_FALSE(entry->deleted());
+ ASSERT_FALSE(entry->labels().is_trashed());
ASSERT_FALSE(entry->etag().empty());
GDataErrorCode error = GDATA_OTHER_ERROR;
@@ -1043,23 +1038,22 @@ TEST_F(FakeDriveServiceTest, CopyResource) {
const std::string kResourceId = "file:2_file_resource_id";
const std::string kParentResourceId = "folder:2_folder_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.CopyResource(
kResourceId,
kParentResourceId,
"new title",
base::Time::FromUTCExploded(kModifiedDate),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_SUCCESS, error);
- ASSERT_TRUE(resource_entry);
+ ASSERT_TRUE(entry);
// The copied entry should have the new resource ID and the title.
- EXPECT_NE(kResourceId, resource_entry->resource_id());
- EXPECT_EQ("new title", resource_entry->title());
- EXPECT_EQ(base::Time::FromUTCExploded(kModifiedDate),
- resource_entry->updated_time());
- EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId));
+ EXPECT_NE(kResourceId, entry->file_id());
+ EXPECT_EQ("new title", entry->title());
+ EXPECT_EQ(base::Time::FromUTCExploded(kModifiedDate), entry->modified_date());
+ EXPECT_TRUE(HasParent(entry->file_id(), kParentResourceId));
// Should be incremented as a new hosted document was created.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
@@ -1071,13 +1065,13 @@ TEST_F(FakeDriveServiceTest, CopyResource_NonExisting) {
const std::string kResourceId = "document:nonexisting_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.CopyResource(
kResourceId,
"folder:1_folder_resource_id",
"new title",
base::Time(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_NOT_FOUND, error);
@@ -1090,20 +1084,20 @@ TEST_F(FakeDriveServiceTest, CopyResource_EmptyParentResourceId) {
const std::string kResourceId = "file:2_file_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.CopyResource(
kResourceId,
std::string(),
"new title",
base::Time(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_SUCCESS, error);
- ASSERT_TRUE(resource_entry);
+ ASSERT_TRUE(entry);
// The copied entry should have the new resource ID and the title.
- EXPECT_NE(kResourceId, resource_entry->resource_id());
- EXPECT_EQ("new title", resource_entry->title());
+ EXPECT_NE(kResourceId, entry->file_id());
+ EXPECT_EQ("new title", entry->title());
EXPECT_TRUE(HasParent(kResourceId, fake_service_.GetRootResourceId()));
// Should be incremented as a new hosted document was created.
EXPECT_EQ(old_largest_change_id + 1,
@@ -1117,17 +1111,17 @@ TEST_F(FakeDriveServiceTest, CopyResource_Offline) {
const std::string kResourceId = "file:2_file_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.CopyResource(
kResourceId,
"folder:1_folder_resource_id",
"new title",
base::Time(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(GDATA_NO_CONNECTION, error);
- EXPECT_FALSE(resource_entry);
+ EXPECT_FALSE(entry);
}
TEST_F(FakeDriveServiceTest, UpdateResource) {
@@ -1141,25 +1135,25 @@ TEST_F(FakeDriveServiceTest, UpdateResource) {
const std::string kResourceId = "file:2_file_resource_id";
const std::string kParentResourceId = "folder:2_folder_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.UpdateResource(
kResourceId,
kParentResourceId,
"new title",
base::Time::FromUTCExploded(kModifiedDate),
base::Time::FromUTCExploded(kViewedDate),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_SUCCESS, error);
- ASSERT_TRUE(resource_entry);
+ ASSERT_TRUE(entry);
// The updated entry should have the new title.
- EXPECT_EQ(kResourceId, resource_entry->resource_id());
- EXPECT_EQ("new title", resource_entry->title());
+ EXPECT_EQ(kResourceId, entry->file_id());
+ EXPECT_EQ("new title", entry->title());
EXPECT_EQ(base::Time::FromUTCExploded(kModifiedDate),
- resource_entry->updated_time());
+ entry->modified_date());
EXPECT_EQ(base::Time::FromUTCExploded(kViewedDate),
- resource_entry->last_viewed_time());
+ entry->last_viewed_by_me_date());
EXPECT_TRUE(HasParent(kResourceId, kParentResourceId));
// Should be incremented as a new hosted document was created.
EXPECT_EQ(old_largest_change_id + 1,
@@ -1172,14 +1166,14 @@ TEST_F(FakeDriveServiceTest, UpdateResource_NonExisting) {
const std::string kResourceId = "document:nonexisting_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.UpdateResource(
kResourceId,
"folder:1_folder_resource_id",
"new title",
base::Time(),
base::Time(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_NOT_FOUND, error);
@@ -1196,21 +1190,21 @@ TEST_F(FakeDriveServiceTest, UpdateResource_EmptyParentResourceId) {
ASSERT_TRUE(HasParent(kResourceId, "fake_root"));
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.UpdateResource(
kResourceId,
std::string(),
"new title",
base::Time(),
base::Time(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_SUCCESS, error);
- ASSERT_TRUE(resource_entry);
+ ASSERT_TRUE(entry);
// The updated entry should have the new title.
- EXPECT_EQ(kResourceId, resource_entry->resource_id());
- EXPECT_EQ("new title", resource_entry->title());
+ EXPECT_EQ(kResourceId, entry->file_id());
+ EXPECT_EQ("new title", entry->title());
EXPECT_TRUE(HasParent(kResourceId, "fake_root"));
// Should be incremented as a new hosted document was created.
EXPECT_EQ(old_largest_change_id + 1,
@@ -1224,18 +1218,18 @@ TEST_F(FakeDriveServiceTest, UpdateResource_Offline) {
const std::string kResourceId = "file:2_file_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.UpdateResource(
kResourceId,
std::string(),
"new title",
base::Time(),
base::Time(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(GDATA_NO_CONNECTION, error);
- EXPECT_FALSE(resource_entry);
+ EXPECT_FALSE(entry);
}
TEST_F(FakeDriveServiceTest, RenameResource_ExistingFile) {
@@ -1253,9 +1247,9 @@ TEST_F(FakeDriveServiceTest, RenameResource_ExistingFile) {
EXPECT_EQ(HTTP_SUCCESS, error);
- scoped_ptr<ResourceEntry> resource_entry = FindEntry(kResourceId);
- ASSERT_TRUE(resource_entry);
- EXPECT_EQ("new title", resource_entry->title());
+ scoped_ptr<FileResource> entry = FindEntry(kResourceId);
+ ASSERT_TRUE(entry);
+ EXPECT_EQ("new title", entry->title());
// Should be incremented as a file was renamed.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
@@ -1424,12 +1418,10 @@ TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_ExistingFile) {
const std::string kResourceId = "file:subdirectory_file_1_id";
const std::string kParentResourceId = "folder:1_folder_resource_id";
- scoped_ptr<ResourceEntry> resource_entry = FindEntry(kResourceId);
- ASSERT_TRUE(resource_entry);
- // The parent link should exist now.
- const google_apis::Link* parent_link =
- resource_entry->GetLinkByType(Link::LINK_PARENT);
- ASSERT_TRUE(parent_link);
+ scoped_ptr<FileResource> entry = FindEntry(kResourceId);
+ ASSERT_TRUE(entry);
+ // The entry should have a parent now.
+ ASSERT_FALSE(entry->parents().empty());
GDataErrorCode error = GDATA_OTHER_ERROR;
fake_service_.RemoveResourceFromDirectory(
@@ -1440,11 +1432,10 @@ TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_ExistingFile) {
EXPECT_EQ(HTTP_NO_CONTENT, error);
- resource_entry = FindEntry(kResourceId);
- ASSERT_TRUE(resource_entry);
- // The parent link should be gone now.
- parent_link = resource_entry->GetLinkByType(Link::LINK_PARENT);
- ASSERT_FALSE(parent_link);
+ entry = FindEntry(kResourceId);
+ ASSERT_TRUE(entry);
+ // The entry should have no parent now.
+ ASSERT_TRUE(entry->parents().empty());
// Should be incremented as a file was moved to the root directory.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
@@ -1506,21 +1497,20 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_EmptyParent) {
int64 old_largest_change_id = GetLargestChangeByAboutResource();
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewDirectory(
std::string(),
"new directory",
DriveServiceInterface::AddNewDirectoryOptions(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_CREATED, error);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->is_folder());
- EXPECT_EQ("resource_id_1", resource_entry->resource_id());
- EXPECT_EQ("new directory", resource_entry->title());
- EXPECT_TRUE(HasParent(resource_entry->resource_id(),
- fake_service_.GetRootResourceId()));
+ ASSERT_TRUE(entry);
+ EXPECT_TRUE(entry->IsDirectory());
+ EXPECT_EQ("resource_id_1", entry->file_id());
+ EXPECT_EQ("new directory", entry->title());
+ EXPECT_TRUE(HasParent(entry->file_id(), fake_service_.GetRootResourceId()));
// Should be incremented as a new directory was created.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
@@ -1533,21 +1523,20 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_ToRootDirectory) {
int64 old_largest_change_id = GetLargestChangeByAboutResource();
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewDirectory(
fake_service_.GetRootResourceId(),
"new directory",
DriveServiceInterface::AddNewDirectoryOptions(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_CREATED, error);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->is_folder());
- EXPECT_EQ("resource_id_1", resource_entry->resource_id());
- EXPECT_EQ("new directory", resource_entry->title());
- EXPECT_TRUE(HasParent(resource_entry->resource_id(),
- fake_service_.GetRootResourceId()));
+ ASSERT_TRUE(entry);
+ EXPECT_TRUE(entry->IsDirectory());
+ EXPECT_EQ("resource_id_1", entry->file_id());
+ EXPECT_EQ("new directory", entry->title());
+ EXPECT_TRUE(HasParent(entry->file_id(), fake_service_.GetRootResourceId()));
// Should be incremented as a new directory was created.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
@@ -1558,21 +1547,20 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_ToRootDirectoryOnEmptyFileSystem) {
int64 old_largest_change_id = GetLargestChangeByAboutResource();
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewDirectory(
fake_service_.GetRootResourceId(),
"new directory",
DriveServiceInterface::AddNewDirectoryOptions(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_CREATED, error);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->is_folder());
- EXPECT_EQ("resource_id_1", resource_entry->resource_id());
- EXPECT_EQ("new directory", resource_entry->title());
- EXPECT_TRUE(HasParent(resource_entry->resource_id(),
- fake_service_.GetRootResourceId()));
+ ASSERT_TRUE(entry);
+ EXPECT_TRUE(entry->IsDirectory());
+ EXPECT_EQ("resource_id_1", entry->file_id());
+ EXPECT_EQ("new directory", entry->title());
+ EXPECT_TRUE(HasParent(entry->file_id(), fake_service_.GetRootResourceId()));
// Should be incremented as a new directory was created.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
@@ -1587,20 +1575,20 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_ToNonRootDirectory) {
const std::string kParentResourceId = "folder:1_folder_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewDirectory(
kParentResourceId,
"new directory",
DriveServiceInterface::AddNewDirectoryOptions(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_CREATED, error);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->is_folder());
- EXPECT_EQ("resource_id_1", resource_entry->resource_id());
- EXPECT_EQ("new directory", resource_entry->title());
- EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId));
+ ASSERT_TRUE(entry);
+ EXPECT_TRUE(entry->IsDirectory());
+ EXPECT_EQ("resource_id_1", entry->file_id());
+ EXPECT_EQ("new directory", entry->title());
+ EXPECT_TRUE(HasParent(entry->file_id(), kParentResourceId));
// Should be incremented as a new directory was created.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
@@ -1613,16 +1601,16 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_ToNonexistingDirectory) {
const std::string kParentResourceId = "folder:nonexisting_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewDirectory(
kParentResourceId,
"new directory",
DriveServiceInterface::AddNewDirectoryOptions(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_NOT_FOUND, error);
- EXPECT_FALSE(resource_entry);
+ EXPECT_FALSE(entry);
}
TEST_F(FakeDriveServiceTest, AddNewDirectory_Offline) {
@@ -1630,16 +1618,16 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_Offline) {
fake_service_.set_offline(true);
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewDirectory(
fake_service_.GetRootResourceId(),
"new directory",
DriveServiceInterface::AddNewDirectoryOptions(),
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(GDATA_NO_CONNECTION, error);
- EXPECT_FALSE(resource_entry);
+ EXPECT_FALSE(entry);
}
TEST_F(FakeDriveServiceTest, InitiateUploadNewFile_Offline) {
@@ -1757,7 +1745,7 @@ TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_WrongETag) {
TEST_F(FakeDriveServiceTest, InitiateUpload_ExistingFile) {
ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
- scoped_ptr<ResourceEntry> entry = FindEntry("file:2_file_resource_id");
+ scoped_ptr<FileResource> entry = FindEntry("file:2_file_resource_id");
ASSERT_TRUE(entry);
FakeDriveService::InitiateUploadExistingFileOptions options;
@@ -1852,7 +1840,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) {
ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
- scoped_ptr<ResourceEntry> entry = FindEntry("file:2_file_resource_id");
+ scoped_ptr<FileResource> entry = FindEntry("file:2_file_resource_id");
ASSERT_TRUE(entry);
FakeDriveService::InitiateUploadExistingFileOptions options;
@@ -1871,19 +1859,19 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) {
ASSERT_EQ(HTTP_SUCCESS, error);
UploadRangeResponse response;
- entry.reset();
+ scoped_ptr<ResourceEntry> resource_entry;
std::vector<test_util::ProgressInfo> upload_progress_values;
fake_service_.ResumeUpload(
upload_location,
0, contents.size() / 2, contents.size(), "text/plain",
local_file_path,
- test_util::CreateCopyResultCallback(&response, &entry),
+ test_util::CreateCopyResultCallback(&response, &resource_entry),
base::Bind(&test_util::AppendProgressCallbackResult,
&upload_progress_values));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code);
- EXPECT_FALSE(entry.get());
+ EXPECT_FALSE(resource_entry.get());
ASSERT_TRUE(!upload_progress_values.empty());
EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
EXPECT_LE(0, upload_progress_values.front().first);
@@ -1895,22 +1883,22 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) {
upload_location,
contents.size() / 2, contents.size(), contents.size(), "text/plain",
local_file_path,
- test_util::CreateCopyResultCallback(&response, &entry),
+ test_util::CreateCopyResultCallback(&response, &resource_entry),
base::Bind(&test_util::AppendProgressCallbackResult,
&upload_progress_values));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_SUCCESS, response.code);
- EXPECT_TRUE(entry.get());
+ EXPECT_TRUE(resource_entry.get());
EXPECT_EQ(static_cast<int64>(contents.size()),
- entry->file_size());
- EXPECT_TRUE(Exists(entry->resource_id()));
+ resource_entry->file_size());
+ EXPECT_TRUE(Exists(resource_entry->resource_id()));
ASSERT_TRUE(!upload_progress_values.empty());
EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
EXPECT_LE(0, upload_progress_values.front().first);
EXPECT_GE(static_cast<int64>(contents.size() - contents.size() / 2),
upload_progress_values.back().first);
- EXPECT_EQ(base::MD5String(contents), entry->file_md5());
+ EXPECT_EQ(base::MD5String(contents), resource_entry->file_md5());
}
TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) {
@@ -1991,31 +1979,28 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectory) {
const std::string kTitle = "new file";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewFile(
kContentType,
kContentData,
fake_service_.GetRootResourceId(),
kTitle,
false, // shared_with_me
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_CREATED, error);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->is_file());
- EXPECT_EQ(kContentType, resource_entry->content_mime_type());
- EXPECT_EQ(static_cast<int64>(kContentData.size()),
- resource_entry->file_size());
- EXPECT_EQ("resource_id_1", resource_entry->resource_id());
- EXPECT_EQ(kTitle, resource_entry->title());
- EXPECT_TRUE(HasParent(resource_entry->resource_id(),
- fake_service_.GetRootResourceId()));
+ ASSERT_TRUE(entry);
+ EXPECT_EQ(kContentType, entry->mime_type());
+ EXPECT_EQ(static_cast<int64>(kContentData.size()), entry->file_size());
+ EXPECT_EQ("resource_id_1", entry->file_id());
+ EXPECT_EQ(kTitle, entry->title());
+ EXPECT_TRUE(HasParent(entry->file_id(), fake_service_.GetRootResourceId()));
// Should be incremented as a new directory was created.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
- EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
+ EXPECT_EQ(base::MD5String(kContentData), entry->md5_checksum());
}
TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectoryOnEmptyFileSystem) {
@@ -2026,31 +2011,28 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectoryOnEmptyFileSystem) {
const std::string kTitle = "new file";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewFile(
kContentType,
kContentData,
fake_service_.GetRootResourceId(),
kTitle,
false, // shared_with_me
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_CREATED, error);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->is_file());
- EXPECT_EQ(kContentType, resource_entry->content_mime_type());
- EXPECT_EQ(static_cast<int64>(kContentData.size()),
- resource_entry->file_size());
- EXPECT_EQ("resource_id_1", resource_entry->resource_id());
- EXPECT_EQ(kTitle, resource_entry->title());
- EXPECT_TRUE(HasParent(resource_entry->resource_id(),
- fake_service_.GetRootResourceId()));
+ ASSERT_TRUE(entry);
+ EXPECT_EQ(kContentType, entry->mime_type());
+ EXPECT_EQ(static_cast<int64>(kContentData.size()), entry->file_size());
+ EXPECT_EQ("resource_id_1", entry->file_id());
+ EXPECT_EQ(kTitle, entry->title());
+ EXPECT_TRUE(HasParent(entry->file_id(), fake_service_.GetRootResourceId()));
// Should be incremented as a new directory was created.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
- EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
+ EXPECT_EQ(base::MD5String(kContentData), entry->md5_checksum());
}
TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) {
@@ -2064,30 +2046,28 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) {
const std::string kParentResourceId = "folder:1_folder_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewFile(
kContentType,
kContentData,
kParentResourceId,
kTitle,
false, // shared_with_me
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_CREATED, error);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->is_file());
- EXPECT_EQ(kContentType, resource_entry->content_mime_type());
- EXPECT_EQ(static_cast<int64>(kContentData.size()),
- resource_entry->file_size());
- EXPECT_EQ("resource_id_1", resource_entry->resource_id());
- EXPECT_EQ(kTitle, resource_entry->title());
- EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId));
+ ASSERT_TRUE(entry);
+ EXPECT_EQ(kContentType, entry->mime_type());
+ EXPECT_EQ(static_cast<int64>(kContentData.size()), entry->file_size());
+ EXPECT_EQ("resource_id_1", entry->file_id());
+ EXPECT_EQ(kTitle, entry->title());
+ EXPECT_TRUE(HasParent(entry->file_id(), kParentResourceId));
// Should be incremented as a new directory was created.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
- EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
+ EXPECT_EQ(base::MD5String(kContentData), entry->md5_checksum());
}
TEST_F(FakeDriveServiceTest, AddNewFile_ToNonexistingDirectory) {
@@ -2099,18 +2079,18 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToNonexistingDirectory) {
const std::string kParentResourceId = "folder:nonexisting_resource_id";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewFile(
kContentType,
kContentData,
kParentResourceId,
kTitle,
false, // shared_with_me
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_NOT_FOUND, error);
- EXPECT_FALSE(resource_entry);
+ EXPECT_FALSE(entry);
}
TEST_F(FakeDriveServiceTest, AddNewFile_Offline) {
@@ -2122,18 +2102,18 @@ TEST_F(FakeDriveServiceTest, AddNewFile_Offline) {
const std::string kTitle = "new file";
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewFile(
kContentType,
kContentData,
fake_service_.GetRootResourceId(),
kTitle,
false, // shared_with_me
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(GDATA_NO_CONNECTION, error);
- EXPECT_FALSE(resource_entry);
+ EXPECT_FALSE(entry);
}
TEST_F(FakeDriveServiceTest, AddNewFile_SharedWithMeLabel) {
@@ -2146,33 +2126,29 @@ TEST_F(FakeDriveServiceTest, AddNewFile_SharedWithMeLabel) {
int64 old_largest_change_id = GetLargestChangeByAboutResource();
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.AddNewFile(
kContentType,
kContentData,
fake_service_.GetRootResourceId(),
kTitle,
true, // shared_with_me
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_CREATED, error);
- ASSERT_TRUE(resource_entry);
- EXPECT_TRUE(resource_entry->is_file());
- EXPECT_EQ(kContentType, resource_entry->content_mime_type());
- EXPECT_EQ(static_cast<int64>(kContentData.size()),
- resource_entry->file_size());
- EXPECT_EQ("resource_id_1", resource_entry->resource_id());
- EXPECT_EQ(kTitle, resource_entry->title());
- EXPECT_TRUE(HasParent(resource_entry->resource_id(),
- fake_service_.GetRootResourceId()));
- ASSERT_EQ(1U, resource_entry->labels().size());
- EXPECT_EQ("shared-with-me", resource_entry->labels()[0]);
+ ASSERT_TRUE(entry);
+ EXPECT_EQ(kContentType, entry->mime_type());
+ EXPECT_EQ(static_cast<int64>(kContentData.size()), entry->file_size());
+ EXPECT_EQ("resource_id_1", entry->file_id());
+ EXPECT_EQ(kTitle, entry->title());
+ EXPECT_TRUE(HasParent(entry->file_id(), fake_service_.GetRootResourceId()));
+ EXPECT_FALSE(entry->shared_with_me_date().is_null());
// Should be incremented as a new directory was created.
EXPECT_EQ(old_largest_change_id + 1,
fake_service_.about_resource().largest_change_id());
EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
- EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
+ EXPECT_EQ(base::MD5String(kContentData), entry->md5_checksum());
}
TEST_F(FakeDriveServiceTest, SetLastModifiedTime_ExistingFile) {
@@ -2183,16 +2159,16 @@ TEST_F(FakeDriveServiceTest, SetLastModifiedTime_ExistingFile) {
ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time));
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.SetLastModifiedTime(
kResourceId,
time,
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_SUCCESS, error);
- ASSERT_TRUE(resource_entry);
- EXPECT_EQ(time, resource_entry->updated_time());
+ ASSERT_TRUE(entry);
+ EXPECT_EQ(time, entry->modified_date());
}
TEST_F(FakeDriveServiceTest, SetLastModifiedTime_NonexistingFile) {
@@ -2203,15 +2179,15 @@ TEST_F(FakeDriveServiceTest, SetLastModifiedTime_NonexistingFile) {
ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time));
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.SetLastModifiedTime(
kResourceId,
time,
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HTTP_NOT_FOUND, error);
- EXPECT_FALSE(resource_entry);
+ EXPECT_FALSE(entry);
}
TEST_F(FakeDriveServiceTest, SetLastModifiedTime_Offline) {
@@ -2223,15 +2199,15 @@ TEST_F(FakeDriveServiceTest, SetLastModifiedTime_Offline) {
ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time));
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> resource_entry;
+ scoped_ptr<FileResource> entry;
fake_service_.SetLastModifiedTime(
kResourceId,
time,
- test_util::CreateCopyResultCallback(&error, &resource_entry));
+ test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(GDATA_NO_CONNECTION, error);
- EXPECT_FALSE(resource_entry);
+ EXPECT_FALSE(entry);
}
} // namespace
diff --git a/chrome/browser/drive/test_util.cc b/chrome/browser/drive/test_util.cc
index 105627f..be1ef74 100644
--- a/chrome/browser/drive/test_util.cc
+++ b/chrome/browser/drive/test_util.cc
@@ -7,20 +7,20 @@
#include "base/run_loop.h"
#include "chrome/browser/drive/drive_api_util.h"
#include "chrome/browser/drive/fake_drive_service.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
+using google_apis::FileResource;
using google_apis::GDATA_OTHER_ERROR;
using google_apis::GDataErrorCode;
using google_apis::HTTP_CREATED;
-using google_apis::ResourceEntry;
namespace drive {
namespace test_util {
bool SetUpTestEntries(FakeDriveService* drive_service) {
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> entry;
+ scoped_ptr<FileResource> entry;
drive_service->AddNewFileWithResourceId(
"file:2_file_resource_id",
diff --git a/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc b/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
index f5b5d00..77dd68b 100644
--- a/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
+++ b/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/extensions/api/file_system/file_system_api.h"
#include "chrome/browser/extensions/component_loader.h"
#include "content/public/test/test_utils.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
namespace extensions {
@@ -84,28 +85,25 @@ class FileSystemApiTestForDrive : public PlatformAppBrowserTest {
bool AddTestFile(const std::string& title,
const std::string& data,
const std::string& parent_id) {
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
+ scoped_ptr<google_apis::FileResource> entry;
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
fake_drive_service_->AddNewFile(
"text/plain", data, parent_id, title, false,
- google_apis::test_util::CreateCopyResultCallback(&error,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&error, &entry));
content::RunAllPendingInMessageLoop();
- return error == google_apis::HTTP_CREATED && resource_entry;
+ return error == google_apis::HTTP_CREATED && entry;
}
std::string AddTestDirectory(const std::string& title,
const std::string& parent_id) {
- scoped_ptr<google_apis::ResourceEntry> resource_entry;
+ scoped_ptr<google_apis::FileResource> entry;
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
fake_drive_service_->AddNewDirectory(
parent_id, title,
drive::DriveServiceInterface::AddNewDirectoryOptions(),
- google_apis::test_util::CreateCopyResultCallback(&error,
- &resource_entry));
+ google_apis::test_util::CreateCopyResultCallback(&error, &entry));
content::RunAllPendingInMessageLoop();
- return error == google_apis::HTTP_CREATED && resource_entry ?
- resource_entry->resource_id() : "";
+ return error == google_apis::HTTP_CREATED && entry ? entry->file_id() : "";
}
base::ScopedTempDir test_cache_root_;
diff --git a/chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc b/chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc
index 75e6d35..449e7a9 100644
--- a/chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc
+++ b/chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc
@@ -267,7 +267,7 @@ bool ConflictResolver::IsContextReady() {
void ConflictResolver::UpdateFileMetadata(
const std::string& file_id,
const SyncStatusCallback& callback) {
- drive_service()->GetResourceEntry(
+ drive_service()->GetFileResource(
file_id,
base::Bind(&ConflictResolver::DidGetRemoteMetadata,
weak_ptr_factory_.GetWeakPtr(), file_id, callback));
@@ -277,7 +277,7 @@ void ConflictResolver::DidGetRemoteMetadata(
const std::string& file_id,
const SyncStatusCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry) {
+ scoped_ptr<google_apis::FileResource> entry) {
SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
if (status != SYNC_STATUS_OK && error != google_apis::HTTP_NOT_FOUND) {
callback.Run(status);
@@ -295,9 +295,7 @@ void ConflictResolver::DidGetRemoteMetadata(
return;
}
- metadata_database()->UpdateByFileResource(
- *drive::util::ConvertResourceEntryToFileResource(*entry),
- callback);
+ metadata_database()->UpdateByFileResource(*entry, callback);
}
drive::DriveServiceInterface* ConflictResolver::drive_service() {
diff --git a/chrome/browser/sync_file_system/drive_backend/conflict_resolver.h b/chrome/browser/sync_file_system/drive_backend/conflict_resolver.h
index 7bba31c..0e07668 100644
--- a/chrome/browser/sync_file_system/drive_backend/conflict_resolver.h
+++ b/chrome/browser/sync_file_system/drive_backend/conflict_resolver.h
@@ -20,7 +20,7 @@ class DriveServiceInterface;
}
namespace google_apis {
-class ResourceEntry;
+class FileResource;
}
namespace sync_file_system {
@@ -62,7 +62,7 @@ class ConflictResolver : public ExclusiveTask {
void DidGetRemoteMetadata(const std::string& file_id,
const SyncStatusCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry);
+ scoped_ptr<google_apis::FileResource> entry);
std::string target_file_id_;
std::vector<std::string> parents_to_remove_;
diff --git a/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc b/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc
index 5c00ff3..889a8a1 100644
--- a/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc
@@ -27,6 +27,7 @@
#include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
#include "chrome/browser/sync_file_system/syncable_file_system_util.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/gdata_errorcode.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/leveldatabase/src/helpers/memenv/memenv.h"
@@ -171,17 +172,10 @@ class ConflictResolverTest : public testing::Test {
}
int CountParents(const std::string& file_id) {
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
EXPECT_EQ(google_apis::HTTP_SUCCESS,
- fake_drive_helper_->GetResourceEntry(file_id, &entry));
- int count = 0;
- const ScopedVector<google_apis::Link>& links = entry->links();
- for (ScopedVector<google_apis::Link>::const_iterator itr = links.begin();
- itr != links.end(); ++itr) {
- if ((*itr)->type() == google_apis::Link::LINK_PARENT)
- ++count;
- }
- return count;
+ fake_drive_helper_->GetFileResource(file_id, &entry));
+ return entry->parents().size();
}
SyncStatusCode RunRemoteToLocalSyncer() {
diff --git a/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.cc b/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.cc
index 8fc92d7..be182df 100644
--- a/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.cc
+++ b/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.cc
@@ -31,7 +31,7 @@ google_apis::CancelCallback DriveServiceOnWorker::AddNewDirectory(
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const google_apis::GetResourceEntryCallback& callback) {
+ const google_apis::FileResourceCallback& callback) {
ui_task_runner_->PostTask(
FROM_HERE,
base::Bind(&DriveServiceWrapper::AddNewDirectory,
@@ -162,12 +162,12 @@ google_apis::CancelCallback DriveServiceOnWorker::GetRemainingFileList(
}
-google_apis::CancelCallback DriveServiceOnWorker::GetResourceEntry(
+google_apis::CancelCallback DriveServiceOnWorker::GetFileResource(
const std::string& resource_id,
- const google_apis::GetResourceEntryCallback& callback) {
+ const google_apis::FileResourceCallback& callback) {
ui_task_runner_->PostTask(
FROM_HERE,
- base::Bind(&DriveServiceWrapper::GetResourceEntry,
+ base::Bind(&DriveServiceWrapper::GetFileResource,
wrapper_,
resource_id,
RelayCallbackToTaskRunner(
@@ -316,7 +316,7 @@ google_apis::CancelCallback DriveServiceOnWorker::CopyResource(
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
- const google_apis::GetResourceEntryCallback& callback) {
+ const google_apis::FileResourceCallback& callback) {
NOTREACHED();
return google_apis::CancelCallback();
}
@@ -327,7 +327,7 @@ google_apis::CancelCallback DriveServiceOnWorker::UpdateResource(
const std::string& new_title,
const base::Time& last_modified,
const base::Time& last_viewed_by_me,
- const google_apis::GetResourceEntryCallback& callback) {
+ const google_apis::FileResourceCallback& callback) {
NOTREACHED();
return google_apis::CancelCallback();
}
diff --git a/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.h b/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.h
index a69e033..c507178 100644
--- a/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.h
+++ b/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.h
@@ -35,7 +35,7 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback DeleteResource(
const std::string& resource_id,
@@ -66,9 +66,9 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface {
const GURL& next_link,
const google_apis::FileListCallback& callback) OVERRIDE;
- virtual google_apis::CancelCallback GetResourceEntry(
+ virtual google_apis::CancelCallback GetFileResource(
const std::string& resource_id,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetFileListInDirectory(
const std::string& directory_resource_id,
@@ -117,14 +117,14 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface {
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
const base::Time& last_viewed_by_me,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback RenameResource(
const std::string& resource_id,
const std::string& new_title,
diff --git a/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.cc b/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.cc
index 24c328f..659f537 100644
--- a/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.cc
+++ b/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.cc
@@ -22,7 +22,7 @@ void DriveServiceWrapper::AddNewDirectory(
const std::string& parent_resource_id,
const std::string& directory_title,
const drive::DriveServiceInterface::AddNewDirectoryOptions& options,
- const google_apis::GetResourceEntryCallback& callback) {
+ const google_apis::FileResourceCallback& callback) {
drive_service_->AddNewDirectory(parent_resource_id,
directory_title,
options,
@@ -74,10 +74,10 @@ void DriveServiceWrapper::GetRemainingFileList(
drive_service_->GetRemainingFileList(next_link, callback);
}
-void DriveServiceWrapper::GetResourceEntry(
+void DriveServiceWrapper::GetFileResource(
const std::string& resource_id,
- const google_apis::GetResourceEntryCallback& callback) {
- drive_service_->GetResourceEntry(resource_id, callback);
+ const google_apis::FileResourceCallback& callback) {
+ drive_service_->GetFileResource(resource_id, callback);
}
void DriveServiceWrapper::GetFileListInDirectory(
diff --git a/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.h b/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.h
index ce15950..2d152454 100644
--- a/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.h
+++ b/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.h
@@ -23,7 +23,7 @@ class DriveServiceWrapper : public base::SupportsWeakPtr<DriveServiceWrapper> {
const std::string& parent_resource_id,
const std::string& directory_title,
const drive::DriveServiceInterface::AddNewDirectoryOptions& options,
- const google_apis::GetResourceEntryCallback& callback);
+ const google_apis::FileResourceCallback& callback);
void DeleteResource(
const std::string& resource_id,
@@ -52,9 +52,9 @@ class DriveServiceWrapper : public base::SupportsWeakPtr<DriveServiceWrapper> {
const GURL& next_link,
const google_apis::FileListCallback& callback);
- void GetResourceEntry(
+ void GetFileResource(
const std::string& resource_id,
- const google_apis::GetResourceEntryCallback& callback);
+ const google_apis::FileResourceCallback& callback);
void GetFileListInDirectory(
const std::string& directory_resource_id,
diff --git a/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc b/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc
index f2ce402..bb2c9b8 100644
--- a/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc
+++ b/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc
@@ -87,7 +87,7 @@ GDataErrorCode FakeDriveServiceHelper::AddFolder(
const std::string& title,
std::string* folder_id) {
GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> folder;
+ scoped_ptr<FileResource> folder;
fake_drive_service_->AddNewDirectory(
parent_folder_id, title,
drive::DriveServiceInterface::AddNewDirectoryOptions(),
@@ -95,7 +95,7 @@ GDataErrorCode FakeDriveServiceHelper::AddFolder(
base::RunLoop().RunUntilIdle();
if (error == google_apis::HTTP_CREATED && folder_id)
- *folder_id = folder->resource_id();
+ *folder_id = folder->file_id();
return error;
}
@@ -162,14 +162,14 @@ GDataErrorCode FakeDriveServiceHelper::UpdateModificationTime(
const std::string& file_id,
const base::Time& modification_time) {
GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<ResourceEntry> entry;
- error = GetResourceEntry(file_id, &entry);
+ scoped_ptr<FileResource> entry;
+ error = GetFileResource(file_id, &entry);
if (error != google_apis::HTTP_SUCCESS)
return error;
fake_drive_service_->UpdateResource(
file_id, std::string(), entry->title(),
- modification_time, entry->last_viewed_time(),
+ modification_time, entry->last_viewed_by_me_date(),
CreateResultReceiver(&error, &entry));
base::RunLoop().RunUntilIdle();
return error;
@@ -262,11 +262,11 @@ GDataErrorCode FakeDriveServiceHelper::SearchByTitle(
return CompleteListing(list.Pass(), entries);
}
-GDataErrorCode FakeDriveServiceHelper::GetResourceEntry(
+GDataErrorCode FakeDriveServiceHelper::GetFileResource(
const std::string& file_id,
- scoped_ptr<ResourceEntry>* entry) {
+ scoped_ptr<FileResource>* entry) {
GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- fake_drive_service_->GetResourceEntry(
+ fake_drive_service_->GetFileResource(
file_id,
CreateResultReceiver(&error, entry));
base::RunLoop().RunUntilIdle();
@@ -276,8 +276,8 @@ GDataErrorCode FakeDriveServiceHelper::GetResourceEntry(
GDataErrorCode FakeDriveServiceHelper::ReadFile(
const std::string& file_id,
std::string* file_content) {
- scoped_ptr<google_apis::ResourceEntry> file;
- GDataErrorCode error = GetResourceEntry(file_id, &file);
+ scoped_ptr<google_apis::FileResource> file;
+ GDataErrorCode error = GetFileResource(file_id, &file);
if (error != google_apis::HTTP_SUCCESS)
return error;
if (!file)
@@ -287,7 +287,7 @@ GDataErrorCode FakeDriveServiceHelper::ReadFile(
base::FilePath temp_file;
EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_dir_, &temp_file));
fake_drive_service_->DownloadFile(
- temp_file, file->resource_id(),
+ temp_file, file->file_id(),
base::Bind(&DownloadResultCallback, &error),
google_apis::GetContentCallback(),
google_apis::ProgressCallback());
diff --git a/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.h b/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.h
index 31e60fab..3a3b20a 100644
--- a/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.h
+++ b/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.h
@@ -66,9 +66,9 @@ class FakeDriveServiceHelper {
const std::string& folder_id,
const std::string& title,
ScopedVector<google_apis::ResourceEntry>* entries);
- google_apis::GDataErrorCode GetResourceEntry(
+ google_apis::GDataErrorCode GetFileResource(
const std::string& file_id,
- scoped_ptr<google_apis::ResourceEntry>* entry);
+ scoped_ptr<google_apis::FileResource>* entry);
google_apis::GDataErrorCode ReadFile(
const std::string& file_id,
std::string* file_content);
diff --git a/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.cc b/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.cc
index e11d7bc..f20c85c 100644
--- a/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.cc
+++ b/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.cc
@@ -9,16 +9,19 @@
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "chrome/browser/drive/drive_api_util.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "testing/gtest/include/gtest/gtest.h"
using drive::FakeDriveService;
using drive::UploadCompletionCallback;
using google_apis::CancelCallback;
+using google_apis::FileResource;
+using google_apis::FileResourceCallback;
using google_apis::GDataErrorCode;
using google_apis::GetResourceEntryCallback;
using google_apis::ProgressCallback;
using google_apis::ResourceEntry;
-using google_apis::ResourceList;
namespace sync_file_system {
namespace drive_backend {
@@ -26,7 +29,7 @@ namespace drive_backend {
namespace {
void DidAddFileOrDirectoryForMakingConflict(GDataErrorCode error,
- scoped_ptr<ResourceEntry> entry) {
+ scoped_ptr<FileResource> entry) {
ASSERT_EQ(google_apis::HTTP_CREATED, error);
ASSERT_TRUE(entry);
}
@@ -34,7 +37,7 @@ void DidAddFileOrDirectoryForMakingConflict(GDataErrorCode error,
void DidAddFileForUploadNew(
const UploadCompletionCallback& callback,
GDataErrorCode error,
- scoped_ptr<ResourceEntry> entry) {
+ scoped_ptr<FileResource> entry) {
ASSERT_EQ(google_apis::HTTP_CREATED, error);
ASSERT_TRUE(entry);
base::MessageLoopProxy::current()->PostTask(
@@ -42,19 +45,23 @@ void DidAddFileForUploadNew(
base::Bind(callback,
google_apis::HTTP_SUCCESS,
GURL(),
- base::Passed(&entry)));
+ base::Passed(
+ drive::util::ConvertFileResourceToResourceEntry(*entry))));
}
-void DidGetResourceEntryForUploadExisting(
+void DidGetFileResourceForUploadExisting(
const UploadCompletionCallback& callback,
GDataErrorCode error,
- scoped_ptr<ResourceEntry> entry) {
+ scoped_ptr<FileResource> entry) {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(callback,
error,
GURL(),
- base::Passed(&entry)));
+ base::Passed(
+ entry ?
+ drive::util::ConvertFileResourceToResourceEntry(*entry) :
+ scoped_ptr<ResourceEntry>())));
}
} // namespace
@@ -68,7 +75,7 @@ CancelCallback FakeDriveServiceWrapper::AddNewDirectory(
const std::string& parent_resource_id,
const std::string& directory_name,
const AddNewDirectoryOptions& options,
- const GetResourceEntryCallback& callback) {
+ const FileResourceCallback& callback) {
if (make_directory_conflict_) {
FakeDriveService::AddNewDirectory(
parent_resource_id,
@@ -128,9 +135,9 @@ CancelCallback FakeDriveUploader::UploadExistingFile(
const UploadCompletionCallback& callback,
const ProgressCallback& progress_callback) {
DCHECK(!callback.is_null());
- return fake_drive_service_->GetResourceEntry(
+ return fake_drive_service_->GetFileResource(
resource_id,
- base::Bind(&DidGetResourceEntryForUploadExisting, callback));
+ base::Bind(&DidGetFileResourceForUploadExisting, callback));
}
CancelCallback FakeDriveUploader::ResumeUploadFile(
diff --git a/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h b/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h
index ff8dbb0..7c12e7e 100644
--- a/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h
+++ b/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h
@@ -30,7 +30,7 @@ class FakeDriveServiceWrapper : public drive::FakeDriveService {
const std::string& parent_resource_id,
const std::string& directory_name,
const AddNewDirectoryOptions& options,
- const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ const google_apis::FileResourceCallback& callback) OVERRIDE;
void set_make_directory_conflict(bool enable) {
make_directory_conflict_ = enable;
diff --git a/chrome/browser/sync_file_system/drive_backend/folder_creator.cc b/chrome/browser/sync_file_system/drive_backend/folder_creator.cc
index 670c4c7..6176ed4 100644
--- a/chrome/browser/sync_file_system/drive_backend/folder_creator.cc
+++ b/chrome/browser/sync_file_system/drive_backend/folder_creator.cc
@@ -50,7 +50,7 @@ void FolderCreator::Run(const FileIDCallback& callback) {
void FolderCreator::DidCreateFolder(
const FileIDCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry) {
+ scoped_ptr<google_apis::FileResource> entry) {
SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
if (status != SYNC_STATUS_OK) {
callback.Run(std::string(), status);
diff --git a/chrome/browser/sync_file_system/drive_backend/folder_creator.h b/chrome/browser/sync_file_system/drive_backend/folder_creator.h
index 472989b..d138278 100644
--- a/chrome/browser/sync_file_system/drive_backend/folder_creator.h
+++ b/chrome/browser/sync_file_system/drive_backend/folder_creator.h
@@ -45,7 +45,7 @@ class FolderCreator {
private:
void DidCreateFolder(const FileIDCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry);
+ scoped_ptr<google_apis::FileResource> entry);
void DidListFolders(const FileIDCallback& callback,
ScopedVector<google_apis::FileResource> candidates,
google_apis::GDataErrorCode error,
diff --git a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc
index 1ab05328..ecc2f29 100644
--- a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc
+++ b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc
@@ -498,7 +498,7 @@ void LocalToRemoteSyncer::UpdateRemoteMetadata(
const std::string& file_id,
const SyncStatusCallback& callback) {
DCHECK(remote_file_tracker_);
- drive_service()->GetResourceEntry(
+ drive_service()->GetFileResource(
file_id,
base::Bind(&LocalToRemoteSyncer::DidGetRemoteMetadata,
weak_ptr_factory_.GetWeakPtr(),
@@ -509,7 +509,7 @@ void LocalToRemoteSyncer::DidGetRemoteMetadata(
const std::string& file_id,
const SyncStatusCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry) {
+ scoped_ptr<google_apis::FileResource> entry) {
if (error == google_apis::HTTP_NOT_FOUND) {
metadata_database()->UpdateByDeletedRemoteFile(file_id, callback);
return;
@@ -527,8 +527,7 @@ void LocalToRemoteSyncer::DidGetRemoteMetadata(
return;
}
- metadata_database()->UpdateByFileResource(
- *drive::util::ConvertResourceEntryToFileResource(*entry), callback);
+ metadata_database()->UpdateByFileResource(*entry, callback);
}
void LocalToRemoteSyncer::DidDeleteForUploadNewFile(
diff --git a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h
index 69433d1..c427e81 100644
--- a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h
+++ b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h
@@ -23,6 +23,7 @@ class DriveUploaderInterface;
}
namespace google_apis {
+class FileResource;
class ResourceEntry;
class ResourceList;
}
@@ -82,7 +83,7 @@ class LocalToRemoteSyncer : public SyncTask {
void DidGetRemoteMetadata(const std::string& file_id,
const SyncStatusCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry);
+ scoped_ptr<google_apis::FileResource> entry);
void DidDeleteForUploadNewFile(const SyncStatusCallback& callback,
SyncStatusCode status);
diff --git a/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc b/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc
index 57536c8..59c4849 100644
--- a/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc
@@ -21,7 +21,7 @@
#include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h"
#include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
#include "content/public/test/test_browser_thread_bundle.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
+#include "google_apis/drive/drive_api_parser.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/leveldatabase/src/helpers/memenv/memenv.h"
#include "third_party/leveldatabase/src/include/leveldb/db.h"
@@ -223,13 +223,12 @@ class RegisterAppTaskTest : public testing::Test {
EXPECT_TRUE(context_->GetMetadataDatabase()->FindTrackerByTrackerID(
files.active_tracker(), &app_root_tracker));
std::string app_root_folder_id = app_root_tracker.file_id();
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
if (google_apis::HTTP_SUCCESS !=
- fake_drive_service_helper_->GetResourceEntry(
- app_root_folder_id, &entry))
+ fake_drive_service_helper_->GetFileResource(app_root_folder_id, &entry))
return false;
- return !entry->deleted();
+ return !entry->labels().is_trashed();
}
private:
diff --git a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.cc b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.cc
index 7c32d27..1a34800 100644
--- a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.cc
+++ b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.cc
@@ -285,7 +285,7 @@ void RemoteToLocalSyncer::HandleMissingRemoteMetadata(
const SyncStatusCallback& callback) {
DCHECK(dirty_tracker_);
- drive_service()->GetResourceEntry(
+ drive_service()->GetFileResource(
dirty_tracker_->file_id(),
base::Bind(&RemoteToLocalSyncer::DidGetRemoteMetadata,
weak_ptr_factory_.GetWeakPtr(),
@@ -295,7 +295,7 @@ void RemoteToLocalSyncer::HandleMissingRemoteMetadata(
void RemoteToLocalSyncer::DidGetRemoteMetadata(
const SyncStatusCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry) {
+ scoped_ptr<google_apis::FileResource> entry) {
SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
if (status != SYNC_STATUS_OK &&
error != google_apis::HTTP_NOT_FOUND) {
@@ -316,7 +316,7 @@ void RemoteToLocalSyncer::DidGetRemoteMetadata(
}
metadata_database()->UpdateByFileResource(
- *drive::util::ConvertResourceEntryToFileResource(*entry),
+ *entry,
base::Bind(&RemoteToLocalSyncer::DidUpdateDatabaseForRemoteMetadata,
weak_ptr_factory_.GetWeakPtr(), callback));
}
diff --git a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h
index 84fa6047..fdcba1e 100644
--- a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h
+++ b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h
@@ -108,7 +108,7 @@ class RemoteToLocalSyncer : public ExclusiveTask {
void HandleMissingRemoteMetadata(const SyncStatusCallback& callback);
void DidGetRemoteMetadata(const SyncStatusCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry);
+ scoped_ptr<google_apis::FileResource> entry);
void DidUpdateDatabaseForRemoteMetadata(const SyncStatusCallback& callback,
SyncStatusCode status);
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.cc
index e5e6f43..82dd752 100644
--- a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.cc
+++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.cc
@@ -250,7 +250,7 @@ void SyncEngineInitializer::CreateSyncRoot(scoped_ptr<SyncTaskToken> token) {
void SyncEngineInitializer::DidCreateSyncRoot(
scoped_ptr<SyncTaskToken> token,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry) {
+ scoped_ptr<google_apis::FileResource> entry) {
DCHECK(!sync_root_folder_);
cancel_callback_.Reset();
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h
index 366e191..fcdcb1f 100644
--- a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h
+++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h
@@ -93,7 +93,7 @@ class SyncEngineInitializer : public SyncTask {
void CreateSyncRoot(scoped_ptr<SyncTaskToken> token);
void DidCreateSyncRoot(scoped_ptr<SyncTaskToken> token,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry);
+ scoped_ptr<google_apis::FileResource> entry);
void DetachSyncRoot(scoped_ptr<SyncTaskToken> token);
void DidDetachSyncRoot(scoped_ptr<SyncTaskToken> token,
google_apis::GDataErrorCode error);
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc
index e64f053..09a1524 100644
--- a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc
@@ -141,7 +141,7 @@ class SyncEngineInitializerTest : public testing::Test {
const std::string& parent_folder_id,
const std::string& title) {
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> entry;
+ scoped_ptr<google_apis::FileResource> entry;
sync_context_->GetDriveService()->AddNewDirectory(
parent_folder_id, title,
drive::DriveServiceInterface::AddNewDirectoryOptions(),
@@ -149,9 +149,7 @@ class SyncEngineInitializerTest : public testing::Test {
base::RunLoop().RunUntilIdle();
EXPECT_EQ(google_apis::HTTP_CREATED, error);
- if (!entry)
- scoped_ptr<google_apis::FileResource>();
- return drive::util::ConvertResourceEntryToFileResource(*entry);
+ return entry.Pass();
}
scoped_ptr<google_apis::FileResource> CreateRemoteSyncRoot() {
@@ -193,13 +191,13 @@ class SyncEngineInitializerTest : public testing::Test {
bool HasNoParent(const std::string& file_id) {
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- scoped_ptr<google_apis::ResourceEntry> entry;
- sync_context_->GetDriveService()->GetResourceEntry(
+ scoped_ptr<google_apis::FileResource> entry;
+ sync_context_->GetDriveService()->GetFileResource(
file_id,
CreateResultReceiver(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
- return !entry->GetLinkByType(google_apis::Link::LINK_PARENT);
+ return entry->parents().empty();
}
size_t CountFileMetadata() {
diff --git a/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc b/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc
index 02dec0f..adbb63f 100644
--- a/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc
+++ b/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc
@@ -359,7 +359,7 @@ void APIUtil::DidCreateDirectory(const std::string& parent_resource_id,
const std::string& title,
const ResourceIdCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry) {
+ scoped_ptr<google_apis::FileResource> entry) {
DCHECK(CalledOnValidThread());
if (error != google_apis::HTTP_SUCCESS &&
@@ -426,9 +426,9 @@ void APIUtil::GetResourceEntry(const std::string& resource_id,
DCHECK(CalledOnValidThread());
DVLOG(2) << "Getting ResourceEntry for: " << resource_id;
- drive_service_->GetResourceEntry(
+ drive_service_->GetFileResource(
resource_id,
- base::Bind(&APIUtil::DidGetResourceEntry, AsWeakPtr(), callback));
+ base::Bind(&APIUtil::DidGetFileResource, AsWeakPtr(), callback));
}
void APIUtil::DidGetLargestChangeStamp(
@@ -544,9 +544,9 @@ void APIUtil::UploadExistingFile(const std::string& resource_id,
const UploadFileCallback& callback) {
DCHECK(CalledOnValidThread());
DVLOG(2) << "Uploading existing file [" << resource_id << "]";
- drive_service_->GetResourceEntry(
+ drive_service_->GetFileResource(
resource_id,
- base::Bind(&APIUtil::DidGetResourceEntry,
+ base::Bind(&APIUtil::DidGetFileResource,
AsWeakPtr(),
base::Bind(&APIUtil::UploadExistingFileInternal,
AsWeakPtr(),
@@ -582,9 +582,9 @@ void APIUtil::DeleteFile(const std::string& resource_id,
// Load actual remote_file_md5 to check for conflict before deletion.
if (!remote_file_md5.empty()) {
- drive_service_->GetResourceEntry(
+ drive_service_->GetFileResource(
resource_id,
- base::Bind(&APIUtil::DidGetResourceEntry,
+ base::Bind(&APIUtil::DidGetFileResource,
AsWeakPtr(),
base::Bind(&APIUtil::DeleteFileInternal,
AsWeakPtr(),
@@ -711,10 +711,10 @@ void APIUtil::DidGetChangeList(
drive::util::ConvertChangeListToResourceList(*change_list));
}
-void APIUtil::DidGetResourceEntry(
+void APIUtil::DidGetFileResource(
const ResourceEntryCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry) {
+ scoped_ptr<google_apis::FileResource> entry) {
DCHECK(CalledOnValidThread());
if (error != google_apis::HTTP_SUCCESS) {
@@ -722,16 +722,17 @@ void APIUtil::DidGetResourceEntry(
callback.Run(error, scoped_ptr<google_apis::ResourceEntry>());
return;
}
+ DCHECK(entry);
- if (entry->deleted()) {
+ if (entry->labels().is_trashed()) {
DVLOG(2) << "Got resource entry, the entry was trashed.";
- callback.Run(google_apis::HTTP_NOT_FOUND, entry.Pass());
+ callback.Run(google_apis::HTTP_NOT_FOUND,
+ drive::util::ConvertFileResourceToResourceEntry(*entry));
return;
}
DVLOG(2) << "Got resource entry";
- DCHECK(entry);
- callback.Run(error, entry.Pass());
+ callback.Run(error, drive::util::ConvertFileResourceToResourceEntry(*entry));
}
void APIUtil::DidGetTemporaryFileForDownload(
@@ -747,9 +748,9 @@ void APIUtil::DidGetTemporaryFileForDownload(
local_file->Pass());
return;
}
- drive_service_->GetResourceEntry(
+ drive_service_->GetFileResource(
resource_id,
- base::Bind(&APIUtil::DidGetResourceEntry,
+ base::Bind(&APIUtil::DidGetFileResource,
AsWeakPtr(),
base::Bind(&APIUtil::DownloadFileInternal,
AsWeakPtr(),
diff --git a/chrome/browser/sync_file_system/drive_backend_v1/api_util.h b/chrome/browser/sync_file_system/drive_backend_v1/api_util.h
index fa52855..052d82d 100644
--- a/chrome/browser/sync_file_system/drive_backend_v1/api_util.h
+++ b/chrome/browser/sync_file_system/drive_backend_v1/api_util.h
@@ -137,7 +137,7 @@ class APIUtil : public APIUtilInterface,
const std::string& title,
const ResourceIdCallback& callback,
google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry);
+ scoped_ptr<google_apis::FileResource> entry);
void DidEnsureUniquenessForCreateDirectory(
const ResourceIdCallback& callback,
@@ -166,9 +166,9 @@ class APIUtil : public APIUtilInterface,
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ChangeList> change_list);
- void DidGetResourceEntry(const ResourceEntryCallback& callback,
- google_apis::GDataErrorCode error,
- scoped_ptr<google_apis::ResourceEntry> entry);
+ void DidGetFileResource(const ResourceEntryCallback& callback,
+ google_apis::GDataErrorCode error,
+ scoped_ptr<google_apis::FileResource> entry);
void DidGetTemporaryFileForDownload(
const std::string& resource_id,
diff --git a/chrome/browser/sync_file_system/drive_backend_v1/api_util_unittest.cc b/chrome/browser/sync_file_system/drive_backend_v1/api_util_unittest.cc
index 8a7e3ad..4348d1a 100644
--- a/chrome/browser/sync_file_system/drive_backend_v1/api_util_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend_v1/api_util_unittest.cc
@@ -27,6 +27,7 @@
using drive::DriveServiceInterface;
using drive::DriveUploaderInterface;
+using google_apis::FileResource;
using google_apis::GDataErrorCode;
using google_apis::ResourceEntry;
using google_apis::ResourceList;
@@ -100,7 +101,7 @@ class APIUtilTest : public testing::Test {
void SetUpFile(const std::string& origin_root_id,
const std::string& content_data,
const std::string& title,
- scoped_ptr<ResourceEntry>* entry) {
+ scoped_ptr<FileResource>* entry) {
ASSERT_TRUE(entry);
std::string file_resource_id;
EXPECT_EQ(google_apis::HTTP_SUCCESS,
@@ -110,7 +111,7 @@ class APIUtilTest : public testing::Test {
content_data,
&file_resource_id));
EXPECT_EQ(google_apis::HTTP_SUCCESS,
- fake_drive_helper_->GetResourceEntry(
+ fake_drive_helper_->GetFileResource(
file_resource_id,
entry));
}
@@ -350,7 +351,7 @@ void APIUtilTest::TestListFiles() {
int kNumberOfFiles = 5;
for (int i = 0; i < kNumberOfFiles; ++i) {
- scoped_ptr<ResourceEntry> file;
+ scoped_ptr<FileResource> file;
std::string file_content = base::StringPrintf("test content %d", i);
std::string file_title = base::StringPrintf("test_%d.txt", i);
SetUpFile(origin_root_id, file_content, file_title, &file);
@@ -392,7 +393,7 @@ void APIUtilTest::TestListChanges() {
// directory is #3.
const int kNumberOfFiles = 5;
for (int i = 0; i < kNumberOfFiles; ++i) {
- scoped_ptr<ResourceEntry> file;
+ scoped_ptr<FileResource> file;
std::string file_content = base::StringPrintf("test content %d", i);
std::string file_title = base::StringPrintf("test_%d.txt", i);
SetUpFile(origin_root_id, file_content, file_title, &file);
@@ -426,17 +427,17 @@ void APIUtilTest::TestDownloadFile() {
const std::string sync_root_id = SetUpSyncRootDirectory();
const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
- scoped_ptr<ResourceEntry> file;
+ scoped_ptr<FileResource> file;
SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
Output output;
api_util()->DownloadFile(
- file->resource_id(),
+ file->file_id(),
"", // local_file_md5
base::Bind(&DidDownloadFile, &output));
base::MessageLoop::current()->RunUntilIdle();
- EXPECT_EQ(file->file_md5(), output.file_md5);
+ EXPECT_EQ(file->md5_checksum(), output.file_md5);
EXPECT_EQ(google_apis::HTTP_SUCCESS, output.error);
}
@@ -446,19 +447,19 @@ void APIUtilTest::TestDownloadFileInNotModified() {
const std::string sync_root_id = SetUpSyncRootDirectory();
const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
- scoped_ptr<ResourceEntry> file;
+ scoped_ptr<FileResource> file;
SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
// Since local file's hash value is equal to remote file's one, it is expected
// to cancel download the file and to return NOT_MODIFIED status code.
Output output;
api_util()->DownloadFile(
- file->resource_id(),
- file->file_md5(),
+ file->file_id(),
+ file->md5_checksum(),
base::Bind(&DidDownloadFile, &output));
base::MessageLoop::current()->RunUntilIdle();
- EXPECT_EQ(file->file_md5(), output.file_md5);
+ EXPECT_EQ(file->md5_checksum(), output.file_md5);
EXPECT_EQ(google_apis::HTTP_NOT_MODIFIED, output.error);
}
@@ -519,24 +520,24 @@ void APIUtilTest::TestUploadExistingFile() {
const std::string sync_root_id = SetUpSyncRootDirectory();
const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
- scoped_ptr<ResourceEntry> file;
+ scoped_ptr<FileResource> file;
SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
Output output;
api_util()->UploadExistingFile(
- file->resource_id(),
- file->file_md5(),
+ file->file_id(),
+ file->md5_checksum(),
kLocalFilePath,
base::Bind(&DidUploadFile, &output));
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(google_apis::HTTP_SUCCESS, output.error);
- EXPECT_EQ(file->resource_id(), output.resource_id);
+ EXPECT_EQ(file->file_id(), output.resource_id);
VerifyTitleUniqueness(origin_root_id,
file->title(),
- file->resource_id(),
- file->kind());
+ file->file_id(),
+ google_apis::ENTRY_KIND_FILE);
}
void APIUtilTest::TestUploadExistingFileInConflict() {
@@ -546,7 +547,7 @@ void APIUtilTest::TestUploadExistingFileInConflict() {
const std::string sync_root_id = SetUpSyncRootDirectory();
const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
- scoped_ptr<ResourceEntry> file;
+ scoped_ptr<FileResource> file;
SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
// Since remote file's hash value is different from the expected one, it is
@@ -555,7 +556,7 @@ void APIUtilTest::TestUploadExistingFileInConflict() {
Output output;
api_util()->UploadExistingFile(
- file->resource_id(),
+ file->file_id(),
kExpectedRemoteFileMD5,
kLocalFilePath,
base::Bind(&DidUploadFile, &output));
@@ -567,8 +568,8 @@ void APIUtilTest::TestUploadExistingFileInConflict() {
// Verify that there is no duplicated file on the remote side.
VerifyTitleUniqueness(origin_root_id,
file->title(),
- file->resource_id(),
- file->kind());
+ file->file_id(),
+ google_apis::ENTRY_KIND_FILE);
}
void APIUtilTest::TestDeleteFile() {
@@ -577,12 +578,12 @@ void APIUtilTest::TestDeleteFile() {
const std::string sync_root_id = SetUpSyncRootDirectory();
const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
- scoped_ptr<ResourceEntry> file;
+ scoped_ptr<FileResource> file;
SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- api_util()->DeleteFile(file->resource_id(),
- file->file_md5(),
+ api_util()->DeleteFile(file->file_id(),
+ file->md5_checksum(),
base::Bind(&DidDeleteFile, &error));
base::MessageLoop::current()->RunUntilIdle();
@@ -597,7 +598,7 @@ void APIUtilTest::TestDeleteFileInConflict() {
const std::string sync_root_id = SetUpSyncRootDirectory();
const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
- scoped_ptr<ResourceEntry> file;
+ scoped_ptr<FileResource> file;
SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
// Since remote file's hash value is different from the expected one, it is
@@ -605,7 +606,7 @@ void APIUtilTest::TestDeleteFileInConflict() {
const std::string kExpectedRemoteFileMD5 = "123456";
GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- api_util()->DeleteFile(file->resource_id(),
+ api_util()->DeleteFile(file->file_id(),
kExpectedRemoteFileMD5,
base::Bind(&DidDeleteFile, &error));
base::MessageLoop::current()->RunUntilIdle();
@@ -615,8 +616,8 @@ void APIUtilTest::TestDeleteFileInConflict() {
// Verify that the conflict file was not deleted on the remote side.
VerifyTitleUniqueness(origin_root_id,
file->title(),
- file->resource_id(),
- file->kind());
+ file->file_id(),
+ google_apis::ENTRY_KIND_FILE);
}
void APIUtilTest::TestCreateDirectory() {
diff --git a/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc b/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc
index 9be0a1a..26d8424 100644
--- a/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc
@@ -10,6 +10,7 @@
#include "base/file_util.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
+#include "chrome/browser/drive/drive_api_util.h"
#include "chrome/browser/drive/drive_uploader.h"
#include "chrome/browser/drive/fake_drive_service.h"
#include "chrome/browser/extensions/test_extension_service.h"
@@ -58,8 +59,8 @@ using drive::FakeDriveService;
using extensions::Extension;
using extensions::DictionaryBuilder;
+using google_apis::FileResource;
using google_apis::GDataErrorCode;
-using google_apis::ResourceEntry;
namespace sync_file_system {
@@ -341,10 +342,12 @@ class DriveFileSyncServiceFakeTest : public testing::Test {
bool AppendIncrementalRemoteChangeByResourceId(
const std::string& resource_id,
const GURL& origin) {
- scoped_ptr<ResourceEntry> entry;
+ scoped_ptr<FileResource> entry;
EXPECT_EQ(google_apis::HTTP_SUCCESS,
- fake_drive_helper_->GetResourceEntry(resource_id, &entry));
- return sync_service_->AppendRemoteChange(origin, *entry, 12345);
+ fake_drive_helper_->GetFileResource(resource_id, &entry));
+ return sync_service_->AppendRemoteChange(
+ origin, *drive::util::ConvertFileResourceToResourceEntry(*entry),
+ 12345);
}
bool AppendIncrementalRemoteChange(
@@ -379,18 +382,18 @@ class DriveFileSyncServiceFakeTest : public testing::Test {
const std::string& parent_resource_id,
const std::string& title,
const std::string& content,
- scoped_ptr<google_apis::ResourceEntry>* entry) {
+ scoped_ptr<google_apis::FileResource>* entry) {
std::string file_id;
ASSERT_EQ(google_apis::HTTP_SUCCESS,
fake_drive_helper_->AddFile(
parent_resource_id, title, content, &file_id));
ASSERT_EQ(google_apis::HTTP_SUCCESS,
- fake_drive_helper_->GetResourceEntry(
+ fake_drive_helper_->GetFileResource(
file_id, entry));
DriveMetadata metadata;
metadata.set_resource_id(file_id);
- metadata.set_md5_checksum((*entry)->file_md5());
+ metadata.set_md5_checksum((*entry)->md5_checksum());
metadata.set_conflicted(false);
metadata.set_to_be_fetched(false);
metadata.set_type(DriveMetadata::RESOURCE_TYPE_FILE);