drive: Replace GetResourceListCallback in DriveServiceInterface with FileListCallback

Replace GetResourceListCallback with FileListCallback.
Rename GetAllResourceList and GetResourceListInDirectory to GetAllFileList and GetFileListInDirectory.
Rename FakeDriveService counter variables.
Remove GetOldestCreatedFolderResource in drive_backend_util.cc and merged the code to folder_creator.cc

BUG=231125
TEST=unit_tests

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274175 0039d316-1c4b-4281-b951-d872f2087c98
parent d32e6403
...@@ -164,7 +164,7 @@ TEST_F(ChangeListLoaderTest, Load) { ...@@ -164,7 +164,7 @@ TEST_F(ChangeListLoaderTest, Load) {
int64 changestamp = 0; int64 changestamp = 0;
EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp));
EXPECT_LT(0, changestamp); EXPECT_LT(0, changestamp);
EXPECT_EQ(1, drive_service_->resource_list_load_count()); EXPECT_EQ(1, drive_service_->file_list_load_count());
EXPECT_EQ(1, drive_service_->about_resource_load_count()); EXPECT_EQ(1, drive_service_->about_resource_load_count());
EXPECT_EQ(1, observer.initial_load_complete_count()); EXPECT_EQ(1, observer.initial_load_complete_count());
EXPECT_EQ(1, observer.load_from_server_complete_count()); EXPECT_EQ(1, observer.load_from_server_complete_count());
...@@ -200,8 +200,8 @@ TEST_F(ChangeListLoaderTest, Load_LocalMetadataAvailable) { ...@@ -200,8 +200,8 @@ TEST_F(ChangeListLoaderTest, Load_LocalMetadataAvailable) {
// Start loading. Because local metadata is available, the load results in // Start loading. Because local metadata is available, the load results in
// returning FILE_ERROR_OK without fetching full list of resources. // returning FILE_ERROR_OK without fetching full list of resources.
const int previous_resource_list_load_count = const int previous_file_list_load_count =
drive_service_->resource_list_load_count(); drive_service_->file_list_load_count();
TestChangeListLoaderObserver observer(change_list_loader_.get()); TestChangeListLoaderObserver observer(change_list_loader_.get());
change_list_loader_->LoadIfNeeded( change_list_loader_->LoadIfNeeded(
...@@ -209,8 +209,8 @@ TEST_F(ChangeListLoaderTest, Load_LocalMetadataAvailable) { ...@@ -209,8 +209,8 @@ TEST_F(ChangeListLoaderTest, Load_LocalMetadataAvailable) {
EXPECT_TRUE(change_list_loader_->IsRefreshing()); EXPECT_TRUE(change_list_loader_->IsRefreshing());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(FILE_ERROR_OK, error);
EXPECT_EQ(previous_resource_list_load_count, EXPECT_EQ(previous_file_list_load_count,
drive_service_->resource_list_load_count()); drive_service_->file_list_load_count());
EXPECT_EQ(1, observer.initial_load_complete_count()); EXPECT_EQ(1, observer.initial_load_complete_count());
// Update should be checked by Load(). // Update should be checked by Load().
...@@ -242,7 +242,7 @@ TEST_F(ChangeListLoaderTest, CheckForUpdates) { ...@@ -242,7 +242,7 @@ TEST_F(ChangeListLoaderTest, CheckForUpdates) {
int64 changestamp = 0; int64 changestamp = 0;
EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp));
EXPECT_EQ(0, changestamp); EXPECT_EQ(0, changestamp);
EXPECT_EQ(0, drive_service_->resource_list_load_count()); EXPECT_EQ(0, drive_service_->file_list_load_count());
EXPECT_EQ(0, drive_service_->about_resource_load_count()); EXPECT_EQ(0, drive_service_->about_resource_load_count());
// Start initial load. // Start initial load.
...@@ -262,7 +262,7 @@ TEST_F(ChangeListLoaderTest, CheckForUpdates) { ...@@ -262,7 +262,7 @@ TEST_F(ChangeListLoaderTest, CheckForUpdates) {
EXPECT_EQ(FILE_ERROR_OK, check_for_updates_error); EXPECT_EQ(FILE_ERROR_OK, check_for_updates_error);
EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp));
EXPECT_LT(0, changestamp); EXPECT_LT(0, changestamp);
EXPECT_EQ(1, drive_service_->resource_list_load_count()); EXPECT_EQ(1, drive_service_->file_list_load_count());
int64 previous_changestamp = 0; int64 previous_changestamp = 0;
EXPECT_EQ(FILE_ERROR_OK, EXPECT_EQ(FILE_ERROR_OK,
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/file_errors.h"
#include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/drive/resource_entry_conversion.h" #include "chrome/browser/chromeos/drive/resource_entry_conversion.h"
#include "chrome/browser/drive/drive_api_util.h"
#include "chrome/browser/drive/drive_service_interface.h" #include "chrome/browser/drive/drive_service_interface.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "google_apis/drive/drive_api_parser.h" #include "google_apis/drive/drive_api_parser.h"
...@@ -349,18 +350,18 @@ void FakeFileSystem::GetResourceEntryAfterGetParentEntryInfo( ...@@ -349,18 +350,18 @@ void FakeFileSystem::GetResourceEntryAfterGetParentEntryInfo(
} }
DCHECK(parent_entry); DCHECK(parent_entry);
drive_service_->GetResourceListInDirectory( drive_service_->GetFileListInDirectory(
parent_entry->resource_id(), parent_entry->resource_id(),
base::Bind( base::Bind(
&FakeFileSystem::GetResourceEntryAfterGetResourceList, &FakeFileSystem::GetResourceEntryAfterGetFileList,
weak_ptr_factory_.GetWeakPtr(), base_name, callback)); weak_ptr_factory_.GetWeakPtr(), base_name, callback));
} }
void FakeFileSystem::GetResourceEntryAfterGetResourceList( void FakeFileSystem::GetResourceEntryAfterGetFileList(
const base::FilePath& base_name, const base::FilePath& base_name,
const GetResourceEntryCallback& callback, const GetResourceEntryCallback& callback,
google_apis::GDataErrorCode gdata_error, google_apis::GDataErrorCode gdata_error,
scoped_ptr<google_apis::ResourceList> resource_list) { scoped_ptr<google_apis::FileList> file_list) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
FileError error = GDataToFileError(gdata_error); FileError error = GDataToFileError(gdata_error);
...@@ -369,14 +370,14 @@ void FakeFileSystem::GetResourceEntryAfterGetResourceList( ...@@ -369,14 +370,14 @@ void FakeFileSystem::GetResourceEntryAfterGetResourceList(
return; return;
} }
DCHECK(resource_list); DCHECK(file_list);
const ScopedVector<google_apis::ResourceEntry>& entries = const ScopedVector<google_apis::FileResource>& entries = file_list->items();
resource_list->entries();
for (size_t i = 0; i < entries.size(); ++i) { for (size_t i = 0; i < entries.size(); ++i) {
scoped_ptr<ResourceEntry> entry(new ResourceEntry); scoped_ptr<ResourceEntry> entry(new ResourceEntry);
std::string parent_resource_id; std::string parent_resource_id;
bool converted = bool converted = ConvertToResourceEntry(
ConvertToResourceEntry(*entries[i], entry.get(), &parent_resource_id); *util::ConvertFileResourceToResourceEntry(*entries[i]), entry.get(),
&parent_resource_id);
DCHECK(converted); DCHECK(converted);
entry->set_parent_local_id(parent_resource_id); entry->set_parent_local_id(parent_resource_id);
......
...@@ -19,7 +19,6 @@ namespace google_apis { ...@@ -19,7 +19,6 @@ namespace google_apis {
class AboutResource; class AboutResource;
class ResourceEntry; class ResourceEntry;
class ResourceList;
} // namespace google_apis } // namespace google_apis
...@@ -173,11 +172,11 @@ class FakeFileSystem : public FileSystemInterface { ...@@ -173,11 +172,11 @@ class FakeFileSystem : public FileSystemInterface {
const GetResourceEntryCallback& callback, const GetResourceEntryCallback& callback,
FileError error, FileError error,
scoped_ptr<ResourceEntry> parent_entry); scoped_ptr<ResourceEntry> parent_entry);
void GetResourceEntryAfterGetResourceList( void GetResourceEntryAfterGetFileList(
const base::FilePath& base_name, const base::FilePath& base_name,
const GetResourceEntryCallback& callback, const GetResourceEntryCallback& callback,
google_apis::GDataErrorCode gdata_error, google_apis::GDataErrorCode gdata_error,
scoped_ptr<google_apis::ResourceList> resource_list); scoped_ptr<google_apis::FileList> file_list);
DriveServiceInterface* drive_service_; // Not owned. DriveServiceInterface* drive_service_; // Not owned.
base::ScopedTempDir cache_dir_; base::ScopedTempDir cache_dir_;
......
...@@ -543,7 +543,7 @@ TEST_F(FileSystemTest, DuplicatedAsyncInitialization) { ...@@ -543,7 +543,7 @@ TEST_F(FileSystemTest, DuplicatedAsyncInitialization) {
loop.Run(); // Wait to get our result loop.Run(); // Wait to get our result
EXPECT_EQ(2, counter); EXPECT_EQ(2, counter);
EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); EXPECT_EQ(1, fake_drive_service_->file_list_load_count());
} }
TEST_F(FileSystemTest, GetGrandRootEntry) { TEST_F(FileSystemTest, GetGrandRootEntry) {
...@@ -567,13 +567,13 @@ TEST_F(FileSystemTest, GetMyDriveRoot) { ...@@ -567,13 +567,13 @@ TEST_F(FileSystemTest, GetMyDriveRoot) {
EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id());
// After "fast fetch" is done, full resource list is fetched. // After "fast fetch" is done, full resource list is fetched.
EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); EXPECT_EQ(1, fake_drive_service_->file_list_load_count());
} }
TEST_F(FileSystemTest, GetExistingFile) { TEST_F(FileSystemTest, GetExistingFile) {
// Simulate the situation that full feed fetching takes very long time, // Simulate the situation that full feed fetching takes very long time,
// to test the recursive "fast fetch" feature is properly working. // to test the recursive "fast fetch" feature is properly working.
fake_drive_service_->set_never_return_all_resource_list(true); fake_drive_service_->set_never_return_all_file_list(true);
const base::FilePath kFilePath( const base::FilePath kFilePath(
FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt"));
...@@ -583,7 +583,7 @@ TEST_F(FileSystemTest, GetExistingFile) { ...@@ -583,7 +583,7 @@ TEST_F(FileSystemTest, GetExistingFile) {
EXPECT_EQ(1, fake_drive_service_->about_resource_load_count()); EXPECT_EQ(1, fake_drive_service_->about_resource_load_count());
EXPECT_EQ(2, fake_drive_service_->directory_load_count()); EXPECT_EQ(2, fake_drive_service_->directory_load_count());
EXPECT_EQ(1, fake_drive_service_->blocked_resource_list_load_count()); EXPECT_EQ(1, fake_drive_service_->blocked_file_list_load_count());
} }
TEST_F(FileSystemTest, GetExistingDocument) { TEST_F(FileSystemTest, GetExistingDocument) {
...@@ -661,7 +661,7 @@ TEST_F(FileSystemTest, LoadFileSystemFromUpToDateCache) { ...@@ -661,7 +661,7 @@ TEST_F(FileSystemTest, LoadFileSystemFromUpToDateCache) {
// SetUpTestFileSystem and FakeDriveService have the same // SetUpTestFileSystem and FakeDriveService have the same
// changestamp (i.e. the local metadata is up-to-date), so no request for // changestamp (i.e. the local metadata is up-to-date), so no request for
// new resource list (i.e., call to GetResourceList) should happen. // new resource list (i.e., call to GetResourceList) should happen.
EXPECT_EQ(0, fake_drive_service_->resource_list_load_count()); EXPECT_EQ(0, fake_drive_service_->file_list_load_count());
// Since the file system has verified that it holds the latest snapshot, // Since the file system has verified that it holds the latest snapshot,
// it should change its state to "loaded", which admits periodic refresh. // it should change its state to "loaded", which admits periodic refresh.
......
...@@ -275,9 +275,9 @@ void JobScheduler::GetAllResourceList( ...@@ -275,9 +275,9 @@ void JobScheduler::GetAllResourceList(
JobEntry* new_job = CreateNewJob(TYPE_GET_ALL_RESOURCE_LIST); JobEntry* new_job = CreateNewJob(TYPE_GET_ALL_RESOURCE_LIST);
new_job->task = base::Bind( new_job->task = base::Bind(
&DriveServiceInterface::GetAllResourceList, &DriveServiceInterface::GetAllFileList,
base::Unretained(drive_service_), base::Unretained(drive_service_),
base::Bind(&JobScheduler::OnGetResourceListJobDone, base::Bind(&JobScheduler::OnGetFileListJobDone,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
new_job->job_info.job_id, new_job->job_info.job_id,
callback)); callback));
...@@ -294,10 +294,10 @@ void JobScheduler::GetResourceListInDirectory( ...@@ -294,10 +294,10 @@ void JobScheduler::GetResourceListInDirectory(
JobEntry* new_job = CreateNewJob( JobEntry* new_job = CreateNewJob(
TYPE_GET_RESOURCE_LIST_IN_DIRECTORY); TYPE_GET_RESOURCE_LIST_IN_DIRECTORY);
new_job->task = base::Bind( new_job->task = base::Bind(
&DriveServiceInterface::GetResourceListInDirectory, &DriveServiceInterface::GetFileListInDirectory,
base::Unretained(drive_service_), base::Unretained(drive_service_),
directory_resource_id, directory_resource_id,
base::Bind(&JobScheduler::OnGetResourceListJobDone, base::Bind(&JobScheduler::OnGetFileListJobDone,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
new_job->job_info.job_id, new_job->job_info.job_id,
callback)); callback));
...@@ -316,7 +316,7 @@ void JobScheduler::Search( ...@@ -316,7 +316,7 @@ void JobScheduler::Search(
&DriveServiceInterface::Search, &DriveServiceInterface::Search,
base::Unretained(drive_service_), base::Unretained(drive_service_),
search_query, search_query,
base::Bind(&JobScheduler::OnGetResourceListJobDone, base::Bind(&JobScheduler::OnGetFileListJobDone,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
new_job->job_info.job_id, new_job->job_info.job_id,
callback)); callback));
...@@ -373,7 +373,7 @@ void JobScheduler::GetRemainingFileList( ...@@ -373,7 +373,7 @@ void JobScheduler::GetRemainingFileList(
&DriveServiceInterface::GetRemainingFileList, &DriveServiceInterface::GetRemainingFileList,
base::Unretained(drive_service_), base::Unretained(drive_service_),
next_link, next_link,
base::Bind(&JobScheduler::OnGetResourceListJobDone, base::Bind(&JobScheduler::OnGetFileListJobDone,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
new_job->job_info.job_id, new_job->job_info.job_id,
callback)); callback));
...@@ -899,32 +899,35 @@ bool JobScheduler::OnJobDone(JobID job_id, google_apis::GDataErrorCode error) { ...@@ -899,32 +899,35 @@ bool JobScheduler::OnJobDone(JobID job_id, google_apis::GDataErrorCode error) {
return !should_retry; return !should_retry;
} }
void JobScheduler::OnGetChangeListJobDone( void JobScheduler::OnGetFileListJobDone(
JobID job_id, JobID job_id,
const google_apis::GetResourceListCallback& callback, const google_apis::GetResourceListCallback& callback,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ChangeList> change_list) { scoped_ptr<google_apis::FileList> file_list) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
if (OnJobDone(job_id, error)) { if (OnJobDone(job_id, error)) {
callback.Run(error, change_list ? callback.Run(error, file_list ?
util::ConvertChangeListToResourceList(*change_list) : util::ConvertFileListToResourceList(*file_list) :
scoped_ptr<google_apis::ResourceList>()); scoped_ptr<google_apis::ResourceList>());
} }
} }
void JobScheduler::OnGetResourceListJobDone( void JobScheduler::OnGetChangeListJobDone(
JobID job_id, JobID job_id,
const google_apis::GetResourceListCallback& callback, const google_apis::GetResourceListCallback& callback,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list) { scoped_ptr<google_apis::ChangeList> change_list) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
if (OnJobDone(job_id, error)) if (OnJobDone(job_id, error)) {
callback.Run(error, resource_list.Pass()); callback.Run(error, change_list ?
util::ConvertChangeListToResourceList(*change_list) :
scoped_ptr<google_apis::ResourceList>());
}
} }
void JobScheduler::OnGetResourceEntryJobDone( void JobScheduler::OnGetResourceEntryJobDone(
......
...@@ -275,19 +275,19 @@ class JobScheduler ...@@ -275,19 +275,19 @@ class JobScheduler
// Retries the job if needed and returns false. Otherwise returns true. // Retries the job if needed and returns false. Otherwise returns true.
bool OnJobDone(JobID job_id, google_apis::GDataErrorCode error); bool OnJobDone(JobID job_id, google_apis::GDataErrorCode error);
// Callback for job finishing with a ChangeListCallback. // Callback for job finishing with a FileListCallback.
void OnGetChangeListJobDone( void OnGetFileListJobDone(
JobID job_id, JobID job_id,
const google_apis::GetResourceListCallback& callback, const google_apis::GetResourceListCallback& callback,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ChangeList> change_list); scoped_ptr<google_apis::FileList> file_list);
// Callback for job finishing with a GetResourceListCallback. // Callback for job finishing with a ChangeListCallback.
void OnGetResourceListJobDone( void OnGetChangeListJobDone(
JobID job_id, JobID job_id,
const google_apis::GetResourceListCallback& callback, const google_apis::GetResourceListCallback& callback,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list); scoped_ptr<google_apis::ChangeList> change_list);
// Callback for job finishing with a GetResourceEntryCallback. // Callback for job finishing with a GetResourceEntryCallback.
void OnGetResourceEntryJobDone( void OnGetResourceEntryJobDone(
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
using content::BrowserThread; using content::BrowserThread;
using google_apis::AboutResourceCallback;
using google_apis::AppList; using google_apis::AppList;
using google_apis::AppListCallback; using google_apis::AppListCallback;
using google_apis::AuthStatusCallback; using google_apis::AuthStatusCallback;
...@@ -35,15 +36,14 @@ using google_apis::ChangeListCallback; ...@@ -35,15 +36,14 @@ using google_apis::ChangeListCallback;
using google_apis::DownloadActionCallback; using google_apis::DownloadActionCallback;
using google_apis::EntryActionCallback; using google_apis::EntryActionCallback;
using google_apis::FileList; using google_apis::FileList;
using google_apis::FileListCallback;
using google_apis::FileResource; using google_apis::FileResource;
using google_apis::GDATA_OTHER_ERROR; using google_apis::GDATA_OTHER_ERROR;
using google_apis::GDATA_PARSE_ERROR; using google_apis::GDATA_PARSE_ERROR;
using google_apis::GDataErrorCode; using google_apis::GDataErrorCode;
using google_apis::AboutResourceCallback;
using google_apis::GetContentCallback; using google_apis::GetContentCallback;
using google_apis::GetResourceEntryCallback; using google_apis::GetResourceEntryCallback;
using google_apis::GetResourceEntryRequest; using google_apis::GetResourceEntryRequest;
using google_apis::GetResourceListCallback;
using google_apis::GetShareUrlCallback; using google_apis::GetShareUrlCallback;
using google_apis::HTTP_NOT_IMPLEMENTED; using google_apis::HTTP_NOT_IMPLEMENTED;
using google_apis::HTTP_SUCCESS; using google_apis::HTTP_SUCCESS;
...@@ -52,7 +52,6 @@ using google_apis::Link; ...@@ -52,7 +52,6 @@ using google_apis::Link;
using google_apis::ProgressCallback; using google_apis::ProgressCallback;
using google_apis::RequestSender; using google_apis::RequestSender;
using google_apis::ResourceEntry; using google_apis::ResourceEntry;
using google_apis::ResourceList;
using google_apis::UploadRangeCallback; using google_apis::UploadRangeCallback;
using google_apis::UploadRangeResponse; using google_apis::UploadRangeResponse;
using google_apis::drive::AboutGetRequest; using google_apis::drive::AboutGetRequest;
...@@ -123,15 +122,6 @@ const char kChangeListFields[] = ...@@ -123,15 +122,6 @@ const char kChangeListFields[] =
"parents/parentLink,alternateLink,modifiedDate,lastViewedByMeDate,shared)," "parents/parentLink,alternateLink,modifiedDate,lastViewedByMeDate,shared),"
"deleted,id,fileId,modificationDate),nextLink,largestChangeId"; "deleted,id,fileId,modificationDate),nextLink,largestChangeId";
// Callback invoked when the parsing of resource list is completed,
// regardless whether it is succeeded or not.
void DidConvertToResourceListOnBlockingPool(
const GetResourceListCallback& callback,
scoped_ptr<ResourceList> resource_list) {
GDataErrorCode error = resource_list ? HTTP_SUCCESS : GDATA_PARSE_ERROR;
callback.Run(error, resource_list.Pass());
}
// Converts the FileResource value to ResourceEntry and runs |callback| on the // Converts the FileResource value to ResourceEntry and runs |callback| on the
// UI thread. // UI thread.
void ConvertFileEntryToResourceEntryAndRun( void ConvertFileEntryToResourceEntryAndRun(
...@@ -157,35 +147,6 @@ void ConvertFileEntryToResourceEntryAndRun( ...@@ -157,35 +147,6 @@ void ConvertFileEntryToResourceEntryAndRun(
callback.Run(error, entry.Pass()); callback.Run(error, entry.Pass());
} }
// Thin adapter of ConvertFileListToResourceList.
scoped_ptr<ResourceList> ConvertFileListToResourceList(
scoped_ptr<FileList> file_list) {
return util::ConvertFileListToResourceList(*file_list);
}
// Converts the FileList value to ResourceList on blocking pool and runs
// |callback| on the UI thread.
void ConvertFileListToResourceListOnBlockingPoolAndRun(
scoped_refptr<base::TaskRunner> blocking_task_runner,
const GetResourceListCallback& callback,
GDataErrorCode error,
scoped_ptr<FileList> value) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
if (!value) {
callback.Run(error, scoped_ptr<ResourceList>());
return;
}
// Convert the value on blocking pool.
base::PostTaskAndReplyWithResult(
blocking_task_runner.get(),
FROM_HERE,
base::Bind(&ConvertFileListToResourceList, base::Passed(&value)),
base::Bind(&DidConvertToResourceListOnBlockingPool, callback));
}
// Converts the FileResource value to ResourceEntry for upload range request, // Converts the FileResource value to ResourceEntry for upload range request,
// and runs |callback| on the UI thread. // and runs |callback| on the UI thread.
void ConvertFileResourceToResourceEntryForUploadRangeAndRun( void ConvertFileResourceToResourceEntryForUploadRangeAndRun(
...@@ -283,7 +244,7 @@ void DriveAPIService::Initialize(const std::string& account_id) { ...@@ -283,7 +244,7 @@ void DriveAPIService::Initialize(const std::string& account_id) {
scopes.push_back(kDriveAppsReadonlyScope); scopes.push_back(kDriveAppsReadonlyScope);
scopes.push_back(util::kDriveAppsScope); scopes.push_back(util::kDriveAppsScope);
// GData WAPI token for GetShareUrl() and GetResourceListInDirectoryByWapi(). // GData WAPI token for GetShareUrl().
scopes.push_back(util::kDocsListScope); scopes.push_back(util::kDocsListScope);
sender_.reset(new RequestSender( sender_.reset(new RequestSender(
...@@ -319,24 +280,22 @@ std::string DriveAPIService::GetRootResourceId() const { ...@@ -319,24 +280,22 @@ std::string DriveAPIService::GetRootResourceId() const {
return kDriveApiRootDirectoryResourceId; return kDriveApiRootDirectoryResourceId;
} }
CancelCallback DriveAPIService::GetAllResourceList( CancelCallback DriveAPIService::GetAllFileList(
const GetResourceListCallback& callback) { const FileListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
FilesListRequest* request = new FilesListRequest( FilesListRequest* request = new FilesListRequest(
sender_.get(), url_generator_, sender_.get(), url_generator_, callback);
base::Bind(&ConvertFileListToResourceListOnBlockingPoolAndRun,
blocking_task_runner_, callback));
request->set_max_results(kMaxNumFilesResourcePerRequest); request->set_max_results(kMaxNumFilesResourcePerRequest);
request->set_q("trashed = false"); // Exclude trashed files. request->set_q("trashed = false"); // Exclude trashed files.
request->set_fields(kFileListFields); request->set_fields(kFileListFields);
return sender_->StartRequestWithRetry(request); return sender_->StartRequestWithRetry(request);
} }
CancelCallback DriveAPIService::GetResourceListInDirectory( CancelCallback DriveAPIService::GetFileListInDirectory(
const std::string& directory_resource_id, const std::string& directory_resource_id,
const GetResourceListCallback& callback) { const FileListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!directory_resource_id.empty()); DCHECK(!directory_resource_id.empty());
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
...@@ -349,9 +308,7 @@ CancelCallback DriveAPIService::GetResourceListInDirectory( ...@@ -349,9 +308,7 @@ CancelCallback DriveAPIService::GetResourceListInDirectory(
// to client side. // to client side.
// We aren't interested in files in trash in this context, neither. // We aren't interested in files in trash in this context, neither.
FilesListRequest* request = new FilesListRequest( FilesListRequest* request = new FilesListRequest(
sender_.get(), url_generator_, sender_.get(), url_generator_, callback);
base::Bind(&ConvertFileListToResourceListOnBlockingPoolAndRun,
blocking_task_runner_, callback));
request->set_max_results(kMaxNumFilesResourcePerRequest); request->set_max_results(kMaxNumFilesResourcePerRequest);
request->set_q(base::StringPrintf( request->set_q(base::StringPrintf(
"'%s' in parents and trashed = false", "'%s' in parents and trashed = false",
...@@ -362,15 +319,13 @@ CancelCallback DriveAPIService::GetResourceListInDirectory( ...@@ -362,15 +319,13 @@ CancelCallback DriveAPIService::GetResourceListInDirectory(
CancelCallback DriveAPIService::Search( CancelCallback DriveAPIService::Search(
const std::string& search_query, const std::string& search_query,
const GetResourceListCallback& callback) { const FileListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!search_query.empty()); DCHECK(!search_query.empty());
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
FilesListRequest* request = new FilesListRequest( FilesListRequest* request = new FilesListRequest(
sender_.get(), url_generator_, sender_.get(), url_generator_, callback);
base::Bind(&ConvertFileListToResourceListOnBlockingPoolAndRun,
blocking_task_runner_, callback));
request->set_max_results(kMaxNumFilesResourcePerRequestForSearch); request->set_max_results(kMaxNumFilesResourcePerRequestForSearch);
request->set_q(drive::util::TranslateQuery(search_query)); request->set_q(drive::util::TranslateQuery(search_query));
request->set_fields(kFileListFields); request->set_fields(kFileListFields);
...@@ -380,7 +335,7 @@ CancelCallback DriveAPIService::Search( ...@@ -380,7 +335,7 @@ CancelCallback DriveAPIService::Search(
CancelCallback DriveAPIService::SearchByTitle( CancelCallback DriveAPIService::SearchByTitle(
const std::string& title, const std::string& title,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const GetResourceListCallback& callback) { const FileListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!title.empty()); DCHECK(!title.empty());
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
...@@ -396,9 +351,7 @@ CancelCallback DriveAPIService::SearchByTitle( ...@@ -396,9 +351,7 @@ CancelCallback DriveAPIService::SearchByTitle(
query += " and trashed = false"; query += " and trashed = false";
FilesListRequest* request = new FilesListRequest( FilesListRequest* request = new FilesListRequest(
sender_.get(), url_generator_, sender_.get(), url_generator_, callback);
base::Bind(&ConvertFileListToResourceListOnBlockingPoolAndRun,
blocking_task_runner_, callback));
request->set_max_results(kMaxNumFilesResourcePerRequest); request->set_max_results(kMaxNumFilesResourcePerRequest);
request->set_q(query); request->set_q(query);
request->set_fields(kFileListFields); request->set_fields(kFileListFields);
...@@ -435,15 +388,13 @@ CancelCallback DriveAPIService::GetRemainingChangeList( ...@@ -435,15 +388,13 @@ CancelCallback DriveAPIService::GetRemainingChangeList(
CancelCallback DriveAPIService::GetRemainingFileList( CancelCallback DriveAPIService::GetRemainingFileList(
const GURL& next_link, const GURL& next_link,
const GetResourceListCallback& callback) { const FileListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!next_link.is_empty()); DCHECK(!next_link.is_empty());
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
FilesListNextPageRequest* request = new FilesListNextPageRequest( FilesListNextPageRequest* request = new FilesListNextPageRequest(
sender_.get(), sender_.get(), callback);
base::Bind(&ConvertFileListToResourceListOnBlockingPoolAndRun,
blocking_task_runner_, callback));
request->set_next_link(next_link); request->set_next_link(next_link);
request->set_fields(kFileListFields); request->set_fields(kFileListFields);
return sender_->StartRequestWithRetry(request); return sender_->StartRequestWithRetry(request);
......
...@@ -74,18 +74,18 @@ class DriveAPIService : public DriveServiceInterface, ...@@ -74,18 +74,18 @@ class DriveAPIService : public DriveServiceInterface,
virtual void ClearAccessToken() OVERRIDE; virtual void ClearAccessToken() OVERRIDE;
virtual void ClearRefreshToken() OVERRIDE; virtual void ClearRefreshToken() OVERRIDE;
virtual std::string GetRootResourceId() const OVERRIDE; virtual std::string GetRootResourceId() const OVERRIDE;
virtual google_apis::CancelCallback GetAllResourceList( virtual google_apis::CancelCallback GetAllFileList(
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetResourceListInDirectory( virtual google_apis::CancelCallback GetFileListInDirectory(
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback Search( virtual google_apis::CancelCallback Search(
const std::string& search_query, const std::string& search_query,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback SearchByTitle( virtual google_apis::CancelCallback SearchByTitle(
const std::string& title, const std::string& title,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetChangeList( virtual google_apis::CancelCallback GetChangeList(
int64 start_changestamp, int64 start_changestamp,
const google_apis::ChangeListCallback& callback) OVERRIDE; const google_apis::ChangeListCallback& callback) OVERRIDE;
...@@ -94,7 +94,7 @@ class DriveAPIService : public DriveServiceInterface, ...@@ -94,7 +94,7 @@ class DriveAPIService : public DriveServiceInterface,
const google_apis::ChangeListCallback& callback) OVERRIDE; const google_apis::ChangeListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetRemainingFileList( virtual google_apis::CancelCallback GetRemainingFileList(
const GURL& next_link, const GURL& next_link,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetResourceEntry( virtual google_apis::CancelCallback GetResourceEntry(
const std::string& resource_id, const std::string& resource_id,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE; const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
......
...@@ -141,17 +141,17 @@ class DriveServiceInterface { ...@@ -141,17 +141,17 @@ class DriveServiceInterface {
// Returns the resource id for the root directory. // Returns the resource id for the root directory.
virtual std::string GetRootResourceId() const = 0; virtual std::string GetRootResourceId() const = 0;
// Fetches a resource list of the account. |callback| will be called upon // Fetches a file list of the account. |callback| will be called upon
// completion. // completion.
// If the list is too long, it may be paged. In such a case, a URL to fetch // If the list is too long, it may be paged. In such a case, a URL to fetch
// remaining results will be included in the returned result. See also // remaining results will be included in the returned result. See also
// GetRemainingFileList. // GetRemainingFileList.
// //
// |callback| must not be null. // |callback| must not be null.
virtual google_apis::CancelCallback GetAllResourceList( virtual google_apis::CancelCallback GetAllFileList(
const google_apis::GetResourceListCallback& callback) = 0; const google_apis::FileListCallback& callback) = 0;
// Fetches a resource list in the directory with |directory_resource_id|. // Fetches a file list in the directory with |directory_resource_id|.
// |callback| will be called upon completion. // |callback| will be called upon completion.
// If the list is too long, it may be paged. In such a case, a URL to fetch // If the list is too long, it may be paged. In such a case, a URL to fetch
// remaining results will be included in the returned result. See also // remaining results will be included in the returned result. See also
...@@ -159,9 +159,9 @@ class DriveServiceInterface { ...@@ -159,9 +159,9 @@ class DriveServiceInterface {
// //
// |directory_resource_id| must not be empty. // |directory_resource_id| must not be empty.
// |callback| must not be null. // |callback| must not be null.
virtual google_apis::CancelCallback GetResourceListInDirectory( virtual google_apis::CancelCallback GetFileListInDirectory(
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) = 0; const google_apis::FileListCallback& callback) = 0;
// Searches the resources for the |search_query| from all the user's // Searches the resources for the |search_query| from all the user's
// resources. |callback| will be called upon completion. // resources. |callback| will be called upon completion.
...@@ -173,7 +173,7 @@ class DriveServiceInterface { ...@@ -173,7 +173,7 @@ class DriveServiceInterface {
// |callback| must not be null. // |callback| must not be null.
virtual google_apis::CancelCallback Search( virtual google_apis::CancelCallback Search(
const std::string& search_query, const std::string& search_query,
const google_apis::GetResourceListCallback& callback) = 0; const google_apis::FileListCallback& callback) = 0;
// Searches the resources with the |title|. // Searches the resources with the |title|.
// |directory_resource_id| is an optional parameter. If it is empty, // |directory_resource_id| is an optional parameter. If it is empty,
...@@ -187,7 +187,7 @@ class DriveServiceInterface { ...@@ -187,7 +187,7 @@ class DriveServiceInterface {
virtual google_apis::CancelCallback SearchByTitle( virtual google_apis::CancelCallback SearchByTitle(
const std::string& title, const std::string& title,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) = 0; const google_apis::FileListCallback& callback) = 0;
// Fetches change list since |start_changestamp|. |callback| will be // Fetches change list since |start_changestamp|. |callback| will be
// called upon completion. // called upon completion.
...@@ -210,7 +210,7 @@ class DriveServiceInterface { ...@@ -210,7 +210,7 @@ class DriveServiceInterface {
const GURL& next_link, const GURL& next_link,
const google_apis::ChangeListCallback& callback) = 0; const google_apis::ChangeListCallback& callback) = 0;
// The result of GetAllResourceList(), GetResourceListInDirectory(), Search() // The result of GetAllFileList(), GetFileListInDirectory(), Search()
// and SearchByTitle() may be paged. In such a case, a next link to fetch // and SearchByTitle() may be paged. In such a case, a next link to fetch
// remaining result is returned. The page token can be used for this method. // remaining result is returned. The page token can be used for this method.
// |callback| will be called upon completion. // |callback| will be called upon completion.
...@@ -218,7 +218,7 @@ class DriveServiceInterface { ...@@ -218,7 +218,7 @@ class DriveServiceInterface {
// |next_link| must not be empty. |callback| must not be null. // |next_link| must not be empty. |callback| must not be null.
virtual google_apis::CancelCallback GetRemainingFileList( virtual google_apis::CancelCallback GetRemainingFileList(
const GURL& next_link, const GURL& next_link,
const google_apis::GetResourceListCallback& callback) = 0; 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 resource id equals
// |resource_id|. // |resource_id|.
......
...@@ -15,9 +15,9 @@ using google_apis::CancelCallback; ...@@ -15,9 +15,9 @@ using google_apis::CancelCallback;
using google_apis::ChangeListCallback; using google_apis::ChangeListCallback;
using google_apis::DownloadActionCallback; using google_apis::DownloadActionCallback;
using google_apis::EntryActionCallback; using google_apis::EntryActionCallback;
using google_apis::FileListCallback;
using google_apis::GetContentCallback; using google_apis::GetContentCallback;
using google_apis::GetResourceEntryCallback; using google_apis::GetResourceEntryCallback;
using google_apis::GetResourceListCallback;
using google_apis::GetShareUrlCallback; using google_apis::GetShareUrlCallback;
using google_apis::InitiateUploadCallback; using google_apis::InitiateUploadCallback;
using google_apis::ProgressCallback; using google_apis::ProgressCallback;
...@@ -57,21 +57,21 @@ std::string DummyDriveService::GetRootResourceId() const { ...@@ -57,21 +57,21 @@ std::string DummyDriveService::GetRootResourceId() const {
return "dummy_root"; return "dummy_root";
} }
CancelCallback DummyDriveService::GetAllResourceList( CancelCallback DummyDriveService::GetAllFileList(
const GetResourceListCallback& callback) { return CancelCallback(); } const FileListCallback& callback) { return CancelCallback(); }
CancelCallback DummyDriveService::GetResourceListInDirectory( CancelCallback DummyDriveService::GetFileListInDirectory(
const std::string& directory_resource_id, const std::string& directory_resource_id,
const GetResourceListCallback& callback) { return CancelCallback(); } const FileListCallback& callback) { return CancelCallback(); }
CancelCallback DummyDriveService::Search( CancelCallback DummyDriveService::Search(
const std::string& search_query, const std::string& search_query,
const GetResourceListCallback& callback) { return CancelCallback(); } const FileListCallback& callback) { return CancelCallback(); }
CancelCallback DummyDriveService::SearchByTitle( CancelCallback DummyDriveService::SearchByTitle(
const std::string& title, const std::string& title,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const GetResourceListCallback& callback) { return CancelCallback(); } const FileListCallback& callback) { return CancelCallback(); }
CancelCallback DummyDriveService::GetChangeList( CancelCallback DummyDriveService::GetChangeList(
int64 start_changestamp, int64 start_changestamp,
...@@ -83,7 +83,7 @@ CancelCallback DummyDriveService::GetRemainingChangeList( ...@@ -83,7 +83,7 @@ CancelCallback DummyDriveService::GetRemainingChangeList(
CancelCallback DummyDriveService::GetRemainingFileList( CancelCallback DummyDriveService::GetRemainingFileList(
const GURL& next_link, const GURL& next_link,
const GetResourceListCallback& callback) { return CancelCallback(); } const FileListCallback& callback) { return CancelCallback(); }
CancelCallback DummyDriveService::GetResourceEntry( CancelCallback DummyDriveService::GetResourceEntry(
const std::string& resource_id, const std::string& resource_id,
......
...@@ -30,18 +30,18 @@ class DummyDriveService : public DriveServiceInterface { ...@@ -30,18 +30,18 @@ class DummyDriveService : public DriveServiceInterface {
virtual void ClearAccessToken() OVERRIDE; virtual void ClearAccessToken() OVERRIDE;
virtual void ClearRefreshToken() OVERRIDE; virtual void ClearRefreshToken() OVERRIDE;
virtual std::string GetRootResourceId() const OVERRIDE; virtual std::string GetRootResourceId() const OVERRIDE;
virtual google_apis::CancelCallback GetAllResourceList( virtual google_apis::CancelCallback GetAllFileList(
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetResourceListInDirectory( virtual google_apis::CancelCallback GetFileListInDirectory(
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback Search( virtual google_apis::CancelCallback Search(
const std::string& search_query, const std::string& search_query,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback SearchByTitle( virtual google_apis::CancelCallback SearchByTitle(
const std::string& title, const std::string& title,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetChangeList( virtual google_apis::CancelCallback GetChangeList(
int64 start_changestamp, int64 start_changestamp,
const google_apis::ChangeListCallback& callback) OVERRIDE; const google_apis::ChangeListCallback& callback) OVERRIDE;
...@@ -50,7 +50,7 @@ class DummyDriveService : public DriveServiceInterface { ...@@ -50,7 +50,7 @@ class DummyDriveService : public DriveServiceInterface {
const google_apis::ChangeListCallback& callback) OVERRIDE; const google_apis::ChangeListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetRemainingFileList( virtual google_apis::CancelCallback GetRemainingFileList(
const GURL& next_link, const GURL& next_link,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetResourceEntry( virtual google_apis::CancelCallback GetResourceEntry(
const std::string& resource_id, const std::string& resource_id,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE; const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
......
This diff is collapsed.
...@@ -38,13 +38,13 @@ class FakeDriveService : public DriveServiceInterface { ...@@ -38,13 +38,13 @@ class FakeDriveService : public DriveServiceInterface {
// when offline. By default the offline state is false. // when offline. By default the offline state is false.
void set_offline(bool offline) { offline_ = offline; } void set_offline(bool offline) { offline_ = offline; }
// GetAllResourceList never returns result when this is set to true. // GetAllFileList never returns result when this is set to true.
// Used to emulate the real server's slowness. // Used to emulate the real server's slowness.
void set_never_return_all_resource_list(bool value) { void set_never_return_all_file_list(bool value) {
never_return_all_resource_list_ = value; never_return_all_file_list_ = value;
} }
// Changes the default max results returned from GetResourceList(). // Changes the default max results returned from GetAllFileList().
// By default, it's set to 0, which is unlimited. // By default, it's set to 0, which is unlimited.
void set_default_max_results(int default_max_results) { void set_default_max_results(int default_max_results) {
default_max_results_ = default_max_results; default_max_results_ = default_max_results;
...@@ -64,16 +64,16 @@ class FakeDriveService : public DriveServiceInterface { ...@@ -64,16 +64,16 @@ class FakeDriveService : public DriveServiceInterface {
return *about_resource_; return *about_resource_;
} }
// Returns the number of times the resource list is successfully loaded by // Returns the number of times the file list is successfully loaded by
// GetAllResourceList(). // GetAllFileList().
int resource_list_load_count() const { return resource_list_load_count_; } int file_list_load_count() const { return file_list_load_count_; }
// Returns the number of times the resource list is successfully loaded by // Returns the number of times the resource list is successfully loaded by
// GetChangeList(). // GetChangeList().
int change_list_load_count() const { return change_list_load_count_; } int change_list_load_count() const { return change_list_load_count_; }
// Returns the number of times the resource list is successfully loaded by // Returns the number of times the resource list is successfully loaded by
// GetResourceListInDirectory(). // GetFileListInDirectory().
int directory_load_count() const { return directory_load_count_; } int directory_load_count() const { return directory_load_count_; }
// Returns the number of times the about resource is successfully loaded // Returns the number of times the about resource is successfully loaded
...@@ -86,10 +86,10 @@ class FakeDriveService : public DriveServiceInterface { ...@@ -86,10 +86,10 @@ class FakeDriveService : public DriveServiceInterface {
// GetAppList(). // GetAppList().
int app_list_load_count() const { return app_list_load_count_; } int app_list_load_count() const { return app_list_load_count_; }
// Returns the number of times GetAllResourceList are blocked due to // Returns the number of times GetAllFileList are blocked due to
// set_never_return_all_resource_list(). // set_never_return_all_file_list().
int blocked_resource_list_load_count() const { int blocked_file_list_load_count() const {
return blocked_resource_list_load_count_; return blocked_file_list_load_count_;
} }
// Returns the file path whose request is cancelled just before this method // Returns the file path whose request is cancelled just before this method
...@@ -114,20 +114,20 @@ class FakeDriveService : public DriveServiceInterface { ...@@ -114,20 +114,20 @@ class FakeDriveService : public DriveServiceInterface {
virtual bool HasRefreshToken() const OVERRIDE; virtual bool HasRefreshToken() const OVERRIDE;
virtual void ClearAccessToken() OVERRIDE; virtual void ClearAccessToken() OVERRIDE;
virtual void ClearRefreshToken() OVERRIDE; virtual void ClearRefreshToken() OVERRIDE;
virtual google_apis::CancelCallback GetAllResourceList( virtual google_apis::CancelCallback GetAllFileList(
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetResourceListInDirectory( virtual google_apis::CancelCallback GetFileListInDirectory(
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
// See the comment for EntryMatchWidthQuery() in .cc file for details about // See the comment for EntryMatchWidthQuery() in .cc file for details about
// the supported search query types. // the supported search query types.
virtual google_apis::CancelCallback Search( virtual google_apis::CancelCallback Search(
const std::string& search_query, const std::string& search_query,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback SearchByTitle( virtual google_apis::CancelCallback SearchByTitle(
const std::string& title, const std::string& title,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetChangeList( virtual google_apis::CancelCallback GetChangeList(
int64 start_changestamp, int64 start_changestamp,
const google_apis::ChangeListCallback& callback) OVERRIDE; const google_apis::ChangeListCallback& callback) OVERRIDE;
...@@ -136,7 +136,7 @@ class FakeDriveService : public DriveServiceInterface { ...@@ -136,7 +136,7 @@ class FakeDriveService : public DriveServiceInterface {
const google_apis::ChangeListCallback& callback) OVERRIDE; const google_apis::ChangeListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetRemainingFileList( virtual google_apis::CancelCallback GetRemainingFileList(
const GURL& next_link, const GURL& next_link,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetResourceEntry( virtual google_apis::CancelCallback GetResourceEntry(
const std::string& resource_id, const std::string& resource_id,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE; const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
...@@ -299,12 +299,12 @@ class FakeDriveService : public DriveServiceInterface { ...@@ -299,12 +299,12 @@ class FakeDriveService : public DriveServiceInterface {
const std::string& title, const std::string& title,
bool shared_with_me); bool shared_with_me);
// Core implementation of GetResourceList. // Core implementation of GetChangeList.
// This method returns the slice of the all matched entries, and its range // This method returns the slice of the all matched entries, and its range
// is between |start_offset| (inclusive) and |start_offset| + |max_results| // is between |start_offset| (inclusive) and |start_offset| + |max_results|
// (exclusive). // (exclusive).
// Increments *load_counter by 1 before it returns successfully. // Increments *load_counter by 1 before it returns successfully.
void GetResourceListInternal( void GetChangeListInternal(
int64 start_changestamp, int64 start_changestamp,
const std::string& search_query, const std::string& search_query,
const std::string& directory_resource_id, const std::string& directory_resource_id,
...@@ -325,14 +325,14 @@ class FakeDriveService : public DriveServiceInterface { ...@@ -325,14 +325,14 @@ class FakeDriveService : public DriveServiceInterface {
int64 next_upload_sequence_number_; int64 next_upload_sequence_number_;
int default_max_results_; int default_max_results_;
int resource_id_count_; int resource_id_count_;
int resource_list_load_count_; int file_list_load_count_;
int change_list_load_count_; int change_list_load_count_;
int directory_load_count_; int directory_load_count_;
int about_resource_load_count_; int about_resource_load_count_;
int app_list_load_count_; int app_list_load_count_;
int blocked_resource_list_load_count_; int blocked_file_list_load_count_;
bool offline_; bool offline_;
bool never_return_all_resource_list_; bool never_return_all_file_list_;
base::FilePath last_cancelled_file_; base::FilePath last_cancelled_file_;
GURL share_url_base_; GURL share_url_base_;
......
...@@ -182,23 +182,6 @@ std::string GetMimeTypeFromTitle(const base::FilePath& title) { ...@@ -182,23 +182,6 @@ std::string GetMimeTypeFromTitle(const base::FilePath& title) {
return mime_type; return mime_type;
} }
scoped_ptr<google_apis::ResourceEntry> GetOldestCreatedFolderResource(
ScopedVector<google_apis::ResourceEntry> candidates) {
scoped_ptr<google_apis::ResourceEntry> oldest;
for (size_t i = 0; i < candidates.size(); ++i) {
google_apis::ResourceEntry* entry = candidates[i];
if (!entry->is_folder() || entry->deleted())
continue;
if (!oldest || oldest->published_time() > entry->published_time()) {
oldest.reset(entry);
candidates[i] = NULL;
}
}
return oldest.Pass();
}
SyncStatusCode GDataErrorCodeToSyncStatusCode( SyncStatusCode GDataErrorCodeToSyncStatusCode(
google_apis::GDataErrorCode error) { google_apis::GDataErrorCode error) {
// NOTE: Please update DriveFileSyncService::UpdateServiceState when you add // NOTE: Please update DriveFileSyncService::UpdateServiceState when you add
......
...@@ -62,9 +62,6 @@ bool HasFileAsParent(const FileDetails& details, const std::string& file_id); ...@@ -62,9 +62,6 @@ bool HasFileAsParent(const FileDetails& details, const std::string& file_id);
std::string GetMimeTypeFromTitle(const base::FilePath& title); std::string GetMimeTypeFromTitle(const base::FilePath& title);
scoped_ptr<google_apis::ResourceEntry> GetOldestCreatedFolderResource(
ScopedVector<google_apis::ResourceEntry> list);
SyncStatusCode GDataErrorCodeToSyncStatusCode( SyncStatusCode GDataErrorCodeToSyncStatusCode(
google_apis::GDataErrorCode error); google_apis::GDataErrorCode error);
......
...@@ -149,7 +149,7 @@ std::string DriveServiceOnWorker::GetRootResourceId() const { ...@@ -149,7 +149,7 @@ std::string DriveServiceOnWorker::GetRootResourceId() const {
google_apis::CancelCallback DriveServiceOnWorker::GetRemainingFileList( google_apis::CancelCallback DriveServiceOnWorker::GetRemainingFileList(
const GURL& next_link, const GURL& next_link,
const google_apis::GetResourceListCallback& callback) { const google_apis::FileListCallback& callback) {
ui_task_runner_->PostTask( ui_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&DriveServiceWrapper::GetRemainingFileList, base::Bind(&DriveServiceWrapper::GetRemainingFileList,
...@@ -180,12 +180,12 @@ google_apis::CancelCallback DriveServiceOnWorker::GetResourceEntry( ...@@ -180,12 +180,12 @@ google_apis::CancelCallback DriveServiceOnWorker::GetResourceEntry(
return google_apis::CancelCallback(); return google_apis::CancelCallback();
} }
google_apis::CancelCallback DriveServiceOnWorker::GetResourceListInDirectory( google_apis::CancelCallback DriveServiceOnWorker::GetFileListInDirectory(
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) { const google_apis::FileListCallback& callback) {
ui_task_runner_->PostTask( ui_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&DriveServiceWrapper::GetResourceListInDirectory, base::Bind(&DriveServiceWrapper::GetFileListInDirectory,
wrapper_, wrapper_,
directory_resource_id, directory_resource_id,
RelayCallbackToTaskRunner( RelayCallbackToTaskRunner(
...@@ -217,7 +217,7 @@ google_apis::CancelCallback DriveServiceOnWorker::RemoveResourceFromDirectory( ...@@ -217,7 +217,7 @@ google_apis::CancelCallback DriveServiceOnWorker::RemoveResourceFromDirectory(
google_apis::CancelCallback DriveServiceOnWorker::SearchByTitle( google_apis::CancelCallback DriveServiceOnWorker::SearchByTitle(
const std::string& title, const std::string& title,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) { const google_apis::FileListCallback& callback) {
ui_task_runner_->PostTask( ui_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&DriveServiceWrapper::SearchByTitle, base::Bind(&DriveServiceWrapper::SearchByTitle,
...@@ -281,15 +281,15 @@ void DriveServiceOnWorker::ClearRefreshToken() { ...@@ -281,15 +281,15 @@ void DriveServiceOnWorker::ClearRefreshToken() {
NOTREACHED(); NOTREACHED();
} }
google_apis::CancelCallback DriveServiceOnWorker::GetAllResourceList( google_apis::CancelCallback DriveServiceOnWorker::GetAllFileList(
const google_apis::GetResourceListCallback& callback) { const google_apis::FileListCallback& callback) {
NOTREACHED(); NOTREACHED();
return google_apis::CancelCallback(); return google_apis::CancelCallback();
} }
google_apis::CancelCallback DriveServiceOnWorker::Search( google_apis::CancelCallback DriveServiceOnWorker::Search(
const std::string& search_query, const std::string& search_query,
const google_apis::GetResourceListCallback& callback) { const google_apis::FileListCallback& callback) {
NOTREACHED(); NOTREACHED();
return google_apis::CancelCallback(); return google_apis::CancelCallback();
} }
......
...@@ -64,15 +64,15 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface { ...@@ -64,15 +64,15 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface {
virtual google_apis::CancelCallback GetRemainingFileList( virtual google_apis::CancelCallback GetRemainingFileList(
const GURL& next_link, const GURL& next_link,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetResourceEntry( virtual google_apis::CancelCallback GetResourceEntry(
const std::string& resource_id, const std::string& resource_id,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE; const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetResourceListInDirectory( virtual google_apis::CancelCallback GetFileListInDirectory(
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback RemoveResourceFromDirectory( virtual google_apis::CancelCallback RemoveResourceFromDirectory(
const std::string& parent_resource_id, const std::string& parent_resource_id,
...@@ -82,7 +82,7 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface { ...@@ -82,7 +82,7 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface {
virtual google_apis::CancelCallback SearchByTitle( virtual google_apis::CancelCallback SearchByTitle(
const std::string& title, const std::string& title,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual bool HasRefreshToken() const OVERRIDE; virtual bool HasRefreshToken() const OVERRIDE;
...@@ -98,11 +98,11 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface { ...@@ -98,11 +98,11 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface {
const google_apis::AuthStatusCallback& callback) OVERRIDE; const google_apis::AuthStatusCallback& callback) OVERRIDE;
virtual void ClearAccessToken() OVERRIDE; virtual void ClearAccessToken() OVERRIDE;
virtual void ClearRefreshToken() OVERRIDE; virtual void ClearRefreshToken() OVERRIDE;
virtual google_apis::CancelCallback GetAllResourceList( virtual google_apis::CancelCallback GetAllFileList(
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback Search( virtual google_apis::CancelCallback Search(
const std::string& search_query, const std::string& search_query,
const google_apis::GetResourceListCallback& callback) OVERRIDE; const google_apis::FileListCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetShareUrl( virtual google_apis::CancelCallback GetShareUrl(
const std::string& resource_id, const std::string& resource_id,
const GURL& embed_origin, const GURL& embed_origin,
......
...@@ -70,7 +70,7 @@ void DriveServiceWrapper::GetRemainingChangeList( ...@@ -70,7 +70,7 @@ void DriveServiceWrapper::GetRemainingChangeList(
void DriveServiceWrapper::GetRemainingFileList( void DriveServiceWrapper::GetRemainingFileList(
const GURL& next_link, const GURL& next_link,
const google_apis::GetResourceListCallback& callback) { const google_apis::FileListCallback& callback) {
drive_service_->GetRemainingFileList(next_link, callback); drive_service_->GetRemainingFileList(next_link, callback);
} }
...@@ -80,11 +80,10 @@ void DriveServiceWrapper::GetResourceEntry( ...@@ -80,11 +80,10 @@ void DriveServiceWrapper::GetResourceEntry(
drive_service_->GetResourceEntry(resource_id, callback); drive_service_->GetResourceEntry(resource_id, callback);
} }
void DriveServiceWrapper::GetResourceListInDirectory( void DriveServiceWrapper::GetFileListInDirectory(
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) { const google_apis::FileListCallback& callback) {
drive_service_->GetResourceListInDirectory(directory_resource_id, drive_service_->GetFileListInDirectory(directory_resource_id, callback);
callback);
} }
bool DriveServiceWrapper::HasRefreshToken() const { bool DriveServiceWrapper::HasRefreshToken() const {
...@@ -102,7 +101,7 @@ void DriveServiceWrapper::RemoveResourceFromDirectory( ...@@ -102,7 +101,7 @@ void DriveServiceWrapper::RemoveResourceFromDirectory(
void DriveServiceWrapper::SearchByTitle( void DriveServiceWrapper::SearchByTitle(
const std::string& title, const std::string& title,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) { const google_apis::FileListCallback& callback) {
drive_service_->SearchByTitle( drive_service_->SearchByTitle(
title, directory_resource_id, callback); title, directory_resource_id, callback);
} }
......
...@@ -50,15 +50,15 @@ class DriveServiceWrapper : public base::SupportsWeakPtr<DriveServiceWrapper> { ...@@ -50,15 +50,15 @@ class DriveServiceWrapper : public base::SupportsWeakPtr<DriveServiceWrapper> {
void GetRemainingFileList( void GetRemainingFileList(
const GURL& next_link, const GURL& next_link,
const google_apis::GetResourceListCallback& callback); const google_apis::FileListCallback& callback);
void GetResourceEntry( void GetResourceEntry(
const std::string& resource_id, const std::string& resource_id,
const google_apis::GetResourceEntryCallback& callback); const google_apis::GetResourceEntryCallback& callback);
void GetResourceListInDirectory( void GetFileListInDirectory(
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback); const google_apis::FileListCallback& callback);
bool HasRefreshToken() const; bool HasRefreshToken() const;
...@@ -70,7 +70,7 @@ class DriveServiceWrapper : public base::SupportsWeakPtr<DriveServiceWrapper> { ...@@ -70,7 +70,7 @@ class DriveServiceWrapper : public base::SupportsWeakPtr<DriveServiceWrapper> {
void SearchByTitle( void SearchByTitle(
const std::string& title, const std::string& title,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback); const google_apis::FileListCallback& callback);
private: private:
drive::DriveServiceInterface* drive_service_; drive::DriveServiceInterface* drive_service_;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/threading/sequenced_worker_pool.h" #include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/drive/drive_api_util.h"
#include "chrome/browser/sync_file_system/sync_file_system_test_util.h" #include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
#include "chrome/browser/sync_file_system/sync_status_code.h" #include "chrome/browser/sync_file_system/sync_status_code.h"
#include "google_apis/drive/drive_api_parser.h" #include "google_apis/drive/drive_api_parser.h"
...@@ -19,9 +20,10 @@ ...@@ -19,9 +20,10 @@
#define FPL(path) FILE_PATH_LITERAL(path) #define FPL(path) FILE_PATH_LITERAL(path)
using google_apis::AboutResource; using google_apis::AboutResource;
using google_apis::FileList;
using google_apis::FileResource;
using google_apis::GDataErrorCode; using google_apis::GDataErrorCode;
using google_apis::ResourceEntry; using google_apis::ResourceEntry;
using google_apis::ResourceList;
namespace sync_file_system { namespace sync_file_system {
namespace drive_backend { namespace drive_backend {
...@@ -209,7 +211,7 @@ GDataErrorCode FakeDriveServiceHelper::RemoveResourceFromDirectory( ...@@ -209,7 +211,7 @@ GDataErrorCode FakeDriveServiceHelper::RemoveResourceFromDirectory(
GDataErrorCode FakeDriveServiceHelper::GetSyncRootFolderID( GDataErrorCode FakeDriveServiceHelper::GetSyncRootFolderID(
std::string* sync_root_folder_id) { std::string* sync_root_folder_id) {
GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
scoped_ptr<ResourceList> resource_list; scoped_ptr<FileList> resource_list;
fake_drive_service_->SearchByTitle( fake_drive_service_->SearchByTitle(
sync_root_folder_title_, std::string(), sync_root_folder_title_, std::string(),
CreateResultReceiver(&error, &resource_list)); CreateResultReceiver(&error, &resource_list));
...@@ -217,12 +219,12 @@ GDataErrorCode FakeDriveServiceHelper::GetSyncRootFolderID( ...@@ -217,12 +219,12 @@ GDataErrorCode FakeDriveServiceHelper::GetSyncRootFolderID(
if (error != google_apis::HTTP_SUCCESS) if (error != google_apis::HTTP_SUCCESS)
return error; return error;
const ScopedVector<ResourceEntry>& entries = resource_list->entries(); const ScopedVector<FileResource>& items = resource_list->items();
for (ScopedVector<ResourceEntry>::const_iterator itr = entries.begin(); for (ScopedVector<FileResource>::const_iterator itr = items.begin();
itr != entries.end(); ++itr) { itr != items.end(); ++itr) {
const ResourceEntry& entry = **itr; const FileResource& item = **itr;
if (!entry.GetLinkByType(google_apis::Link::LINK_PARENT)) { if (item.parents().empty()) {
*sync_root_folder_id = entry.resource_id(); *sync_root_folder_id = item.file_id();
return google_apis::HTTP_SUCCESS; return google_apis::HTTP_SUCCESS;
} }
} }
...@@ -233,8 +235,8 @@ GDataErrorCode FakeDriveServiceHelper::ListFilesInFolder( ...@@ -233,8 +235,8 @@ GDataErrorCode FakeDriveServiceHelper::ListFilesInFolder(
const std::string& folder_id, const std::string& folder_id,
ScopedVector<ResourceEntry>* entries) { ScopedVector<ResourceEntry>* entries) {
GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
scoped_ptr<ResourceList> list; scoped_ptr<FileList> list;
fake_drive_service_->GetResourceListInDirectory( fake_drive_service_->GetFileListInDirectory(
folder_id, folder_id,
CreateResultReceiver(&error, &list)); CreateResultReceiver(&error, &list));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
...@@ -249,7 +251,7 @@ GDataErrorCode FakeDriveServiceHelper::SearchByTitle( ...@@ -249,7 +251,7 @@ GDataErrorCode FakeDriveServiceHelper::SearchByTitle(
const std::string& title, const std::string& title,
ScopedVector<ResourceEntry>* entries) { ScopedVector<ResourceEntry>* entries) {
GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
scoped_ptr<ResourceList> list; scoped_ptr<FileList> list;
fake_drive_service_->SearchByTitle( fake_drive_service_->SearchByTitle(
title, folder_id, title, folder_id,
CreateResultReceiver(&error, &list)); CreateResultReceiver(&error, &list));
...@@ -307,19 +309,18 @@ GDataErrorCode FakeDriveServiceHelper::GetAboutResource( ...@@ -307,19 +309,18 @@ GDataErrorCode FakeDriveServiceHelper::GetAboutResource(
} }
GDataErrorCode FakeDriveServiceHelper::CompleteListing( GDataErrorCode FakeDriveServiceHelper::CompleteListing(
scoped_ptr<ResourceList> list, scoped_ptr<FileList> list,
ScopedVector<ResourceEntry>* entries) { ScopedVector<ResourceEntry>* entries) {
while (true) { while (true) {
entries->reserve(entries->size() + list->entries().size()); entries->reserve(entries->size() + list->items().size());
for (ScopedVector<ResourceEntry>::iterator itr = for (ScopedVector<FileResource>::const_iterator itr =
list->mutable_entries()->begin(); list->items().begin(); itr != list->items().end(); ++itr) {
itr != list->mutable_entries()->end(); ++itr) { entries->push_back(
entries->push_back(*itr); drive::util::ConvertFileResourceToResourceEntry(**itr).release());
*itr = NULL;
} }
GURL next_feed; GURL next_feed = list->next_link();
if (!list->GetNextFeedURL(&next_feed)) if (next_feed.is_empty())
return google_apis::HTTP_SUCCESS; return google_apis::HTTP_SUCCESS;
GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
......
...@@ -79,8 +79,8 @@ class FakeDriveServiceHelper { ...@@ -79,8 +79,8 @@ class FakeDriveServiceHelper {
private: private:
google_apis::GDataErrorCode CompleteListing( google_apis::GDataErrorCode CompleteListing(
scoped_ptr<google_apis::ResourceList> list, scoped_ptr<google_apis::FileList> list,
ScopedVector<google_apis::ResourceEntry> * entries); ScopedVector<google_apis::ResourceEntry>* entries);
void Initialize(); void Initialize();
......
...@@ -61,63 +61,62 @@ void FolderCreator::DidCreateFolder( ...@@ -61,63 +61,62 @@ void FolderCreator::DidCreateFolder(
title_, parent_folder_id_, title_, parent_folder_id_,
base::Bind(&FolderCreator::DidListFolders, base::Bind(&FolderCreator::DidListFolders,
weak_ptr_factory_.GetWeakPtr(), callback, weak_ptr_factory_.GetWeakPtr(), callback,
base::Passed(ScopedVector<google_apis::ResourceEntry>()))); base::Passed(ScopedVector<google_apis::FileResource>())));
} }
void FolderCreator::DidListFolders( void FolderCreator::DidListFolders(
const FileIDCallback& callback, const FileIDCallback& callback,
ScopedVector<google_apis::ResourceEntry> candidates, ScopedVector<google_apis::FileResource> candidates,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list) { scoped_ptr<google_apis::FileList> file_list) {
SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
if (status != SYNC_STATUS_OK) { if (status != SYNC_STATUS_OK) {
callback.Run(std::string(), status); callback.Run(std::string(), status);
return; return;
} }
if (!resource_list) { if (!file_list) {
NOTREACHED(); NOTREACHED();
callback.Run(std::string(), SYNC_STATUS_FAILED); callback.Run(std::string(), SYNC_STATUS_FAILED);
return; return;
} }
candidates.reserve(candidates.size() + resource_list->entries().size()); candidates.reserve(candidates.size() + file_list->items().size());
candidates.insert(candidates.end(), candidates.insert(candidates.end(),
resource_list->entries().begin(), file_list->items().begin(),
resource_list->entries().end()); file_list->items().end());
resource_list->mutable_entries()->weak_clear(); file_list->mutable_items()->weak_clear();
GURL next_feed; if (!file_list->next_link().is_empty()) {
if (resource_list->GetNextFeedURL(&next_feed)) {
drive_service_->GetRemainingFileList( drive_service_->GetRemainingFileList(
next_feed, file_list->next_link(),
base::Bind(&FolderCreator::DidListFolders, base::Bind(&FolderCreator::DidListFolders,
weak_ptr_factory_.GetWeakPtr(), callback, weak_ptr_factory_.GetWeakPtr(), callback,
base::Passed(&candidates))); base::Passed(&candidates)));
return; return;
} }
ScopedVector<google_apis::FileResource> files; const google_apis::FileResource* oldest = NULL;
files.reserve(candidates.size());
for (size_t i = 0; i < candidates.size(); ++i) { for (size_t i = 0; i < candidates.size(); ++i) {
files.push_back(drive::util::ConvertResourceEntryToFileResource( const google_apis::FileResource& entry = *candidates[i];
*candidates[i]).release()); if (!entry.IsDirectory() || entry.labels().is_trashed())
} continue;
scoped_ptr<google_apis::ResourceEntry> oldest = if (!oldest || oldest->created_date() > entry.created_date())
GetOldestCreatedFolderResource(candidates.Pass()); oldest = &entry;
}
if (!oldest) { if (!oldest) {
callback.Run(std::string(), SYNC_FILE_ERROR_NOT_FOUND); callback.Run(std::string(), SYNC_FILE_ERROR_NOT_FOUND);
return; return;
} }
std::string file_id = oldest->resource_id(); std::string file_id = oldest->file_id();
metadata_database_->UpdateByFileResourceList( metadata_database_->UpdateByFileResourceList(
files.Pass(), base::Bind(&FolderCreator::DidUpdateDatabase, candidates.Pass(), base::Bind(&FolderCreator::DidUpdateDatabase,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
file_id, callback)); file_id, callback));
} }
void FolderCreator::DidUpdateDatabase(const std::string& file_id, void FolderCreator::DidUpdateDatabase(const std::string& file_id,
......
...@@ -18,8 +18,9 @@ class DriveServiceInterface; ...@@ -18,8 +18,9 @@ class DriveServiceInterface;
} }
namespace google_apis { namespace google_apis {
class FileList;
class FileResource;
class ResourceEntry; class ResourceEntry;
class ResourceList;
} }
namespace sync_file_system { namespace sync_file_system {
...@@ -46,9 +47,9 @@ class FolderCreator { ...@@ -46,9 +47,9 @@ class FolderCreator {
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceEntry> entry); scoped_ptr<google_apis::ResourceEntry> entry);
void DidListFolders(const FileIDCallback& callback, void DidListFolders(const FileIDCallback& callback,
ScopedVector<google_apis::ResourceEntry> candidates, ScopedVector<google_apis::FileResource> candidates,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list); scoped_ptr<google_apis::FileList> file_list);
void DidUpdateDatabase(const std::string& file_id, void DidUpdateDatabase(const std::string& file_id,
const FileIDCallback& callback, const FileIDCallback& callback,
SyncStatusCode status); SyncStatusCode status);
......
...@@ -531,7 +531,7 @@ void RemoteToLocalSyncer::ListFolderContent( ...@@ -531,7 +531,7 @@ void RemoteToLocalSyncer::ListFolderContent(
DCHECK(!remote_metadata_->details().missing()); DCHECK(!remote_metadata_->details().missing());
// TODO(tzik): Replace this call with ChildList version. // TODO(tzik): Replace this call with ChildList version.
drive_service()->GetResourceListInDirectory( drive_service()->GetFileListInDirectory(
dirty_tracker_->file_id(), dirty_tracker_->file_id(),
base::Bind(&RemoteToLocalSyncer::DidListFolderContent, base::Bind(&RemoteToLocalSyncer::DidListFolderContent,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
...@@ -543,31 +543,30 @@ void RemoteToLocalSyncer::DidListFolderContent( ...@@ -543,31 +543,30 @@ void RemoteToLocalSyncer::DidListFolderContent(
const SyncStatusCallback& callback, const SyncStatusCallback& callback,
scoped_ptr<FileIDList> children, scoped_ptr<FileIDList> children,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list) { scoped_ptr<google_apis::FileList> file_list) {
SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
if (status != SYNC_STATUS_OK) { if (status != SYNC_STATUS_OK) {
callback.Run(status); callback.Run(status);
return; return;
} }
if (!resource_list) { if (!file_list) {
NOTREACHED(); NOTREACHED();
callback.Run(SYNC_STATUS_FAILED); callback.Run(SYNC_STATUS_FAILED);
return; return;
} }
children->reserve(children->size() + resource_list->entries().size()); children->reserve(children->size() + file_list->items().size());
for (ScopedVector<google_apis::ResourceEntry>::const_iterator itr = for (ScopedVector<google_apis::FileResource>::const_iterator itr =
resource_list->entries().begin(); file_list->items().begin();
itr != resource_list->entries().end(); itr != file_list->items().end();
++itr) { ++itr) {
children->push_back((*itr)->resource_id()); children->push_back((*itr)->file_id());
} }
GURL next_feed; if (!file_list->next_link().is_empty()) {
if (resource_list->GetNextFeedURL(&next_feed)) {
drive_service()->GetRemainingFileList( drive_service()->GetRemainingFileList(
next_feed, file_list->next_link(),
base::Bind(&RemoteToLocalSyncer::DidListFolderContent, base::Bind(&RemoteToLocalSyncer::DidListFolderContent,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
callback, base::Passed(&children))); callback, base::Passed(&children)));
......
...@@ -24,9 +24,9 @@ class DriveServiceInterface; ...@@ -24,9 +24,9 @@ class DriveServiceInterface;
} }
namespace google_apis { namespace google_apis {
class FileList;
class FileResource; class FileResource;
class ResourceEntry; class ResourceEntry;
class ResourceList;
} }
namespace webkit_blob { namespace webkit_blob {
...@@ -159,7 +159,7 @@ class RemoteToLocalSyncer : public ExclusiveTask { ...@@ -159,7 +159,7 @@ class RemoteToLocalSyncer : public ExclusiveTask {
const SyncStatusCallback& callback, const SyncStatusCallback& callback,
scoped_ptr<FileIDList> children, scoped_ptr<FileIDList> children,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list); scoped_ptr<google_apis::FileList> file_list);
void SyncCompleted(const SyncStatusCallback& callback, SyncStatusCode status); void SyncCompleted(const SyncStatusCallback& callback, SyncStatusCode status);
void FinalizeSync(const SyncStatusCallback& callback, SyncStatusCode status); void FinalizeSync(const SyncStatusCallback& callback, SyncStatusCode status);
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h" #include "base/message_loop/message_loop_proxy.h"
#include "chrome/browser/drive/drive_api_service.h" #include "chrome/browser/drive/drive_api_service.h"
#include "chrome/browser/drive/drive_api_util.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
...@@ -28,27 +27,22 @@ namespace { ...@@ -28,27 +27,22 @@ namespace {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Functions below are for wrapping the access to legacy GData WAPI classes. // Functions below are for wrapping the access to legacy GData WAPI classes.
bool HasNoParents(const google_apis::ResourceEntry& entry) { bool HasNoParents(const google_apis::FileResource& entry) {
return !entry.GetLinkByType(google_apis::Link::LINK_PARENT); return entry.parents().empty();
} }
bool HasFolderAsParent(const google_apis::ResourceEntry& entry, bool HasFolderAsParent(const google_apis::FileResource& entry,
const std::string& parent_id) { const std::string& parent_id) {
const ScopedVector<google_apis::Link>& links = entry.links(); for (size_t i = 0; i < entry.parents().size(); ++i) {
for (ScopedVector<google_apis::Link>::const_iterator itr = links.begin(); if (entry.parents()[i].file_id() == parent_id)
itr != links.end(); ++itr) {
const google_apis::Link& link = **itr;
if (link.type() != google_apis::Link::LINK_PARENT)
continue;
if (drive::util::ExtractResourceIdFromUrl(link.href()) == parent_id)
return true; return true;
} }
return false; return false;
} }
bool LessOnCreationTime(const google_apis::ResourceEntry& left, bool LessOnCreationTime(const google_apis::FileResource& left,
const google_apis::ResourceEntry& right) { const google_apis::FileResource& right) {
return left.published_time() < right.published_time(); return left.created_date() < right.created_date();
} }
typedef base::Callback<void(scoped_ptr<SyncTaskToken> token, typedef base::Callback<void(scoped_ptr<SyncTaskToken> token,
...@@ -56,20 +50,6 @@ typedef base::Callback<void(scoped_ptr<SyncTaskToken> token, ...@@ -56,20 +50,6 @@ typedef base::Callback<void(scoped_ptr<SyncTaskToken> token,
scoped_ptr<google_apis::ResourceList> resources)> scoped_ptr<google_apis::ResourceList> resources)>
TokenAndResourceListCallback; TokenAndResourceListCallback;
ScopedVector<google_apis::FileResource> ConvertResourceEntriesToFileResources(
const ScopedVector<google_apis::ResourceEntry>& entries) {
ScopedVector<google_apis::FileResource> resources;
for (ScopedVector<google_apis::ResourceEntry>::const_iterator itr =
entries.begin();
itr != entries.end();
++itr) {
resources.push_back(
drive::util::ConvertResourceEntryToFileResource(
**itr).release());
}
return resources.Pass();
}
// Functions above are for wrapping the access to legacy GData WAPI classes. // Functions above are for wrapping the access to legacy GData WAPI classes.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -192,7 +172,7 @@ void SyncEngineInitializer::FindSyncRoot(scoped_ptr<SyncTaskToken> token) { ...@@ -192,7 +172,7 @@ void SyncEngineInitializer::FindSyncRoot(scoped_ptr<SyncTaskToken> token) {
void SyncEngineInitializer::DidFindSyncRoot( void SyncEngineInitializer::DidFindSyncRoot(
scoped_ptr<SyncTaskToken> token, scoped_ptr<SyncTaskToken> token,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list) { scoped_ptr<google_apis::FileList> file_list) {
cancel_callback_.Reset(); cancel_callback_.Reset();
SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
...@@ -203,7 +183,7 @@ void SyncEngineInitializer::DidFindSyncRoot( ...@@ -203,7 +183,7 @@ void SyncEngineInitializer::DidFindSyncRoot(
return; return;
} }
if (!resource_list) { if (!file_list) {
NOTREACHED(); NOTREACHED();
util::Log(logging::LOG_VERBOSE, FROM_HERE, util::Log(logging::LOG_VERBOSE, FROM_HERE,
"[Initialize] Got invalid resource list."); "[Initialize] Got invalid resource list.");
...@@ -211,15 +191,13 @@ void SyncEngineInitializer::DidFindSyncRoot( ...@@ -211,15 +191,13 @@ void SyncEngineInitializer::DidFindSyncRoot(
return; return;
} }
ScopedVector<google_apis::ResourceEntry>* entries = ScopedVector<google_apis::FileResource>* items = file_list->mutable_items();
resource_list->mutable_entries(); for (ScopedVector<google_apis::FileResource>::iterator itr = items->begin();
for (ScopedVector<google_apis::ResourceEntry>::iterator itr = itr != items->end(); ++itr) {
entries->begin(); google_apis::FileResource* entry = *itr;
itr != entries->end(); ++itr) {
google_apis::ResourceEntry* entry = *itr;
// Ignore deleted folder. // Ignore deleted folder.
if (entry->deleted()) if (entry->labels().is_trashed())
continue; continue;
// Pick an orphaned folder or a direct child of the root folder and // Pick an orphaned folder or a direct child of the root folder and
...@@ -236,10 +214,9 @@ void SyncEngineInitializer::DidFindSyncRoot( ...@@ -236,10 +214,9 @@ void SyncEngineInitializer::DidFindSyncRoot(
set_used_network(true); set_used_network(true);
// If there are more results, retrieve them. // If there are more results, retrieve them.
GURL next_url; if (!file_list->next_link().is_empty()) {
if (resource_list->GetNextFeedURL(&next_url)) {
cancel_callback_ = sync_context_->GetDriveService()->GetRemainingFileList( cancel_callback_ = sync_context_->GetDriveService()->GetRemainingFileList(
next_url, file_list->next_link(),
base::Bind(&SyncEngineInitializer::DidFindSyncRoot, base::Bind(&SyncEngineInitializer::DidFindSyncRoot,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
base::Passed(&token))); base::Passed(&token)));
...@@ -294,7 +271,7 @@ void SyncEngineInitializer::DetachSyncRoot(scoped_ptr<SyncTaskToken> token) { ...@@ -294,7 +271,7 @@ void SyncEngineInitializer::DetachSyncRoot(scoped_ptr<SyncTaskToken> token) {
cancel_callback_ = cancel_callback_ =
sync_context_->GetDriveService()->RemoveResourceFromDirectory( sync_context_->GetDriveService()->RemoveResourceFromDirectory(
root_folder_id_, root_folder_id_,
sync_root_folder_->resource_id(), sync_root_folder_->file_id(),
base::Bind(&SyncEngineInitializer::DidDetachSyncRoot, base::Bind(&SyncEngineInitializer::DidDetachSyncRoot,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
base::Passed(&token))); base::Passed(&token)));
...@@ -321,8 +298,8 @@ void SyncEngineInitializer::ListAppRootFolders( ...@@ -321,8 +298,8 @@ void SyncEngineInitializer::ListAppRootFolders(
DCHECK(sync_root_folder_); DCHECK(sync_root_folder_);
set_used_network(true); set_used_network(true);
cancel_callback_ = cancel_callback_ =
sync_context_->GetDriveService()->GetResourceListInDirectory( sync_context_->GetDriveService()->GetFileListInDirectory(
sync_root_folder_->resource_id(), sync_root_folder_->file_id(),
base::Bind(&SyncEngineInitializer::DidListAppRootFolders, base::Bind(&SyncEngineInitializer::DidListAppRootFolders,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
base::Passed(&token))); base::Passed(&token)));
...@@ -331,7 +308,7 @@ void SyncEngineInitializer::ListAppRootFolders( ...@@ -331,7 +308,7 @@ void SyncEngineInitializer::ListAppRootFolders(
void SyncEngineInitializer::DidListAppRootFolders( void SyncEngineInitializer::DidListAppRootFolders(
scoped_ptr<SyncTaskToken> token, scoped_ptr<SyncTaskToken> token,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list) { scoped_ptr<google_apis::FileList> file_list) {
cancel_callback_.Reset(); cancel_callback_.Reset();
SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
...@@ -342,7 +319,7 @@ void SyncEngineInitializer::DidListAppRootFolders( ...@@ -342,7 +319,7 @@ void SyncEngineInitializer::DidListAppRootFolders(
return; return;
} }
if (!resource_list) { if (!file_list) {
NOTREACHED(); NOTREACHED();
util::Log(logging::LOG_VERBOSE, FROM_HERE, util::Log(logging::LOG_VERBOSE, FROM_HERE,
"[Initialize] Got invalid initial app-root list."); "[Initialize] Got invalid initial app-root list.");
...@@ -350,18 +327,17 @@ void SyncEngineInitializer::DidListAppRootFolders( ...@@ -350,18 +327,17 @@ void SyncEngineInitializer::DidListAppRootFolders(
return; return;
} }
ScopedVector<google_apis::ResourceEntry>* new_entries = ScopedVector<google_apis::FileResource>* new_entries =
resource_list->mutable_entries(); file_list->mutable_items();
app_root_folders_.insert(app_root_folders_.end(), app_root_folders_.insert(app_root_folders_.end(),
new_entries->begin(), new_entries->end()); new_entries->begin(), new_entries->end());
new_entries->weak_clear(); new_entries->weak_clear();
set_used_network(true); set_used_network(true);
GURL next_url; if (!file_list->next_link().is_empty()) {
if (resource_list->GetNextFeedURL(&next_url)) {
cancel_callback_ = cancel_callback_ =
sync_context_->GetDriveService()->GetRemainingFileList( sync_context_->GetDriveService()->GetRemainingFileList(
next_url, file_list->next_link(),
base::Bind(&SyncEngineInitializer::DidListAppRootFolders, base::Bind(&SyncEngineInitializer::DidListAppRootFolders,
weak_ptr_factory_.GetWeakPtr(), base::Passed(&token))); weak_ptr_factory_.GetWeakPtr(), base::Passed(&token)));
return; return;
...@@ -375,9 +351,8 @@ void SyncEngineInitializer::PopulateDatabase( ...@@ -375,9 +351,8 @@ void SyncEngineInitializer::PopulateDatabase(
DCHECK(sync_root_folder_); DCHECK(sync_root_folder_);
metadata_database_->PopulateInitialData( metadata_database_->PopulateInitialData(
largest_change_id_, largest_change_id_,
*drive::util::ConvertResourceEntryToFileResource( *sync_root_folder_,
*sync_root_folder_), app_root_folders_,
ConvertResourceEntriesToFileResources(app_root_folders_),
base::Bind(&SyncEngineInitializer::DidPopulateDatabase, base::Bind(&SyncEngineInitializer::DidPopulateDatabase,
weak_ptr_factory_.GetWeakPtr(), base::Passed(&token))); weak_ptr_factory_.GetWeakPtr(), base::Passed(&token)));
} }
......
...@@ -22,8 +22,9 @@ class DriveServiceInterface; ...@@ -22,8 +22,9 @@ class DriveServiceInterface;
namespace google_apis { namespace google_apis {
class AboutResource; class AboutResource;
class FileList;
class FileResource;
class ResourceEntry; class ResourceEntry;
class ResourceList;
} }
namespace leveldb { namespace leveldb {
...@@ -88,7 +89,7 @@ class SyncEngineInitializer : public SyncTask { ...@@ -88,7 +89,7 @@ class SyncEngineInitializer : public SyncTask {
void FindSyncRoot(scoped_ptr<SyncTaskToken> token); void FindSyncRoot(scoped_ptr<SyncTaskToken> token);
void DidFindSyncRoot(scoped_ptr<SyncTaskToken> token, void DidFindSyncRoot(scoped_ptr<SyncTaskToken> token,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list); scoped_ptr<google_apis::FileList> file_list);
void CreateSyncRoot(scoped_ptr<SyncTaskToken> token); void CreateSyncRoot(scoped_ptr<SyncTaskToken> token);
void DidCreateSyncRoot(scoped_ptr<SyncTaskToken> token, void DidCreateSyncRoot(scoped_ptr<SyncTaskToken> token,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
...@@ -100,7 +101,7 @@ class SyncEngineInitializer : public SyncTask { ...@@ -100,7 +101,7 @@ class SyncEngineInitializer : public SyncTask {
void DidListAppRootFolders( void DidListAppRootFolders(
scoped_ptr<SyncTaskToken> token, scoped_ptr<SyncTaskToken> token,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list); scoped_ptr<google_apis::FileList> file_list);
void PopulateDatabase(scoped_ptr<SyncTaskToken> token); void PopulateDatabase(scoped_ptr<SyncTaskToken> token);
void DidPopulateDatabase(scoped_ptr<SyncTaskToken> token, void DidPopulateDatabase(scoped_ptr<SyncTaskToken> token,
SyncStatusCode status); SyncStatusCode status);
...@@ -114,12 +115,12 @@ class SyncEngineInitializer : public SyncTask { ...@@ -114,12 +115,12 @@ class SyncEngineInitializer : public SyncTask {
int find_sync_root_retry_count_; int find_sync_root_retry_count_;
scoped_ptr<MetadataDatabase> metadata_database_; scoped_ptr<MetadataDatabase> metadata_database_;
ScopedVector<google_apis::ResourceEntry> app_root_folders_; ScopedVector<google_apis::FileResource> app_root_folders_;
int64 largest_change_id_; int64 largest_change_id_;
std::string root_folder_id_; std::string root_folder_id_;
scoped_ptr<google_apis::ResourceEntry> sync_root_folder_; scoped_ptr<google_apis::FileResource> sync_root_folder_;
base::WeakPtrFactory<SyncEngineInitializer> weak_ptr_factory_; base::WeakPtrFactory<SyncEngineInitializer> weak_ptr_factory_;
......
...@@ -461,7 +461,7 @@ void APIUtil::SearchByTitle(const std::string& title, ...@@ -461,7 +461,7 @@ void APIUtil::SearchByTitle(const std::string& title,
drive_service_->SearchByTitle( drive_service_->SearchByTitle(
title, title,
directory_resource_id, directory_resource_id,
base::Bind(&APIUtil::DidGetResourceList, AsWeakPtr(), callback)); base::Bind(&APIUtil::DidGetFileList, AsWeakPtr(), callback));
} }
void APIUtil::ListFiles(const std::string& directory_resource_id, void APIUtil::ListFiles(const std::string& directory_resource_id,
...@@ -470,7 +470,9 @@ void APIUtil::ListFiles(const std::string& directory_resource_id, ...@@ -470,7 +470,9 @@ void APIUtil::ListFiles(const std::string& directory_resource_id,
DVLOG(2) << "Listing resources in the directory [" << directory_resource_id DVLOG(2) << "Listing resources in the directory [" << directory_resource_id
<< "]"; << "]";
drive_service_->GetResourceListInDirectory(directory_resource_id, callback); drive_service_->GetFileListInDirectory(
directory_resource_id,
base::Bind(&APIUtil::DidGetFileList, AsWeakPtr(), callback));
} }
void APIUtil::ListChanges(int64 start_changestamp, void APIUtil::ListChanges(int64 start_changestamp,
...@@ -490,7 +492,7 @@ void APIUtil::ContinueListing(const GURL& next_link, ...@@ -490,7 +492,7 @@ void APIUtil::ContinueListing(const GURL& next_link,
drive_service_->GetRemainingFileList( drive_service_->GetRemainingFileList(
next_link, next_link,
base::Bind(&APIUtil::DidGetResourceList, AsWeakPtr(), callback)); base::Bind(&APIUtil::DidGetFileList, AsWeakPtr(), callback));
} }
void APIUtil::DownloadFile(const std::string& resource_id, void APIUtil::DownloadFile(const std::string& resource_id,
...@@ -675,39 +677,38 @@ void APIUtil::OnConnectionTypeChanged( ...@@ -675,39 +677,38 @@ void APIUtil::OnConnectionTypeChanged(
CancelAllUploads(google_apis::GDATA_NO_CONNECTION); CancelAllUploads(google_apis::GDATA_NO_CONNECTION);
} }
void APIUtil::DidGetChangeList( void APIUtil::DidGetFileList(const ResourceListCallback& callback,
const ResourceListCallback& callback, google_apis::GDataErrorCode error,
google_apis::GDataErrorCode error, scoped_ptr<google_apis::FileList> file_list) {
scoped_ptr<google_apis::ChangeList> change_list) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
if (error != google_apis::HTTP_SUCCESS) { if (error != google_apis::HTTP_SUCCESS) {
DVLOG(2) << "Error on listing changes: " << error; DVLOG(2) << "Error on listing files: " << error;
callback.Run(error, scoped_ptr<google_apis::ResourceList>()); callback.Run(error, scoped_ptr<google_apis::ResourceList>());
return; return;
} }
DVLOG(2) << "Got change list"; DVLOG(2) << "Got file list";
DCHECK(change_list); DCHECK(file_list);
callback.Run(error, callback.Run(error, drive::util::ConvertFileListToResourceList(*file_list));
drive::util::ConvertChangeListToResourceList(*change_list));
} }
void APIUtil::DidGetResourceList( void APIUtil::DidGetChangeList(
const ResourceListCallback& callback, const ResourceListCallback& callback,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list) { scoped_ptr<google_apis::ChangeList> change_list) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
if (error != google_apis::HTTP_SUCCESS) { if (error != google_apis::HTTP_SUCCESS) {
DVLOG(2) << "Error on listing resource: " << error; DVLOG(2) << "Error on listing changes: " << error;
callback.Run(error, scoped_ptr<google_apis::ResourceList>()); callback.Run(error, scoped_ptr<google_apis::ResourceList>());
return; return;
} }
DVLOG(2) << "Got resource list"; DVLOG(2) << "Got change list";
DCHECK(resource_list); DCHECK(change_list);
callback.Run(error, resource_list.Pass()); callback.Run(error,
drive::util::ConvertChangeListToResourceList(*change_list));
} }
void APIUtil::DidGetResourceEntry( void APIUtil::DidGetResourceEntry(
......
...@@ -158,14 +158,14 @@ class APIUtil : public APIUtilInterface, ...@@ -158,14 +158,14 @@ class APIUtil : public APIUtilInterface,
const std::string& sync_root_resource_id, const std::string& sync_root_resource_id,
google_apis::GDataErrorCode error); google_apis::GDataErrorCode error);
void DidGetFileList(const ResourceListCallback& callback,
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::FileList> file_list);
void DidGetChangeList(const ResourceListCallback& callback, void DidGetChangeList(const ResourceListCallback& callback,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ChangeList> change_list); scoped_ptr<google_apis::ChangeList> change_list);
void DidGetResourceList(const ResourceListCallback& callback,
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceList> resource_list);
void DidGetResourceEntry(const ResourceEntryCallback& callback, void DidGetResourceEntry(const ResourceEntryCallback& callback,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceEntry> entry); scoped_ptr<google_apis::ResourceEntry> entry);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment