#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
-#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/logging.h"
#include "chrome/browser/chromeos/drive/drive.pb.h"
#include "chrome/browser/chromeos/drive/file_errors.h"
#include "chrome/browser/drive/drive_service_interface.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/drive/drive_api_parser.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
-#include "testing/gtest/include/gtest/gtest.h"
namespace drive {
namespace test_util {
const GetResourceEntryCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // Now, we only support files under my drive.
- DCHECK(!util::IsUnderDriveMountPoint(file_path));
-
if (file_path == util::GetDriveMyDriveRootPath()) {
// Specialized for the root entry.
drive_service_->GetAboutResource(
return;
}
+ // Now, we only support files under my drive.
+ DCHECK(util::GetDriveMyDriveRootPath().IsParent(file_path));
GetResourceEntry(
file_path.DirName(),
base::Bind(
void FakeFileSystem::ReadDirectory(
const base::FilePath& file_path,
- const ReadDirectoryCallback& callback) {
+ const ReadDirectoryEntriesCallback& entries_callback,
+ const FileOperationCallback& completion_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
-void FakeFileSystem::GetCacheEntry(
- const base::FilePath& drive_file_path,
- const GetCacheEntryCallback& callback) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-}
-
void FakeFileSystem::AddPermission(const base::FilePath& drive_file_path,
const std::string& email,
google_apis::drive::PermissionRole role,
return;
}
- // Fetch google_apis::ResourceEntry for its |download_url|.
- drive_service_->GetResourceEntry(
+ // Fetch google_apis::FileResource for its |download_url|.
+ drive_service_->GetFileResource(
entry->resource_id(),
base::Bind(
- &FakeFileSystem::GetFileContentAfterGetWapiResourceEntry,
+ &FakeFileSystem::GetFileContentAfterGetFileResource,
weak_ptr_factory_.GetWeakPtr(),
initialized_callback,
get_content_callback,
completion_callback));
}
-void FakeFileSystem::GetFileContentAfterGetWapiResourceEntry(
+void FakeFileSystem::GetFileContentAfterGetFileResource(
const GetFileContentInitializedCallback& initialized_callback,
const google_apis::GetContentCallback& get_content_callback,
const FileOperationCallback& completion_callback,
google_apis::GDataErrorCode gdata_error,
- scoped_ptr<google_apis::ResourceEntry> gdata_entry) {
+ scoped_ptr<google_apis::FileResource> gdata_entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
FileError error = GDataToFileError(gdata_error);
scoped_ptr<ResourceEntry> entry(new ResourceEntry);
std::string parent_resource_id;
- bool converted =
- ConvertToResourceEntry(*gdata_entry, entry.get(), &parent_resource_id);
+ bool converted = ConvertFileResourceToResourceEntry(
+ *gdata_entry, entry.get(), &parent_resource_id);
DCHECK(converted);
entry->set_parent_local_id(parent_resource_id);
base::FilePath cache_path =
cache_dir_.path().AppendASCII(entry->resource_id());
+ if (entry->file_specific_info().is_hosted_document()) {
+ // For hosted documents return a dummy cache without server request.
+ int result = base::WriteFile(cache_path, "", 0);
+ DCHECK_EQ(0, result);
+ }
if (base::PathExists(cache_path)) {
// Cache file is found.
initialized_callback.Run(FILE_ERROR_OK, cache_path, entry.Pass());
initialized_callback.Run(FILE_ERROR_OK, base::FilePath(), entry.Pass());
drive_service_->DownloadFile(
cache_path,
- gdata_entry->resource_id(),
+ gdata_entry->file_id(),
base::Bind(&FakeFileSystem::GetFileContentAfterDownloadFile,
weak_ptr_factory_.GetWeakPtr(),
completion_callback),
}
DCHECK(parent_entry);
- drive_service_->GetResourceListInDirectory(
+ drive_service_->GetFileListInDirectory(
parent_entry->resource_id(),
base::Bind(
- &FakeFileSystem::GetResourceEntryAfterGetResourceList,
+ &FakeFileSystem::GetResourceEntryAfterGetFileList,
weak_ptr_factory_.GetWeakPtr(), base_name, callback));
}
-void FakeFileSystem::GetResourceEntryAfterGetResourceList(
+void FakeFileSystem::GetResourceEntryAfterGetFileList(
const base::FilePath& base_name,
const GetResourceEntryCallback& callback,
google_apis::GDataErrorCode gdata_error,
- scoped_ptr<google_apis::ResourceList> resource_list) {
+ scoped_ptr<google_apis::FileList> file_list) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
FileError error = GDataToFileError(gdata_error);
return;
}
- DCHECK(resource_list);
- const ScopedVector<google_apis::ResourceEntry>& entries =
- resource_list->entries();
+ DCHECK(file_list);
+ const ScopedVector<google_apis::FileResource>& entries = file_list->items();
for (size_t i = 0; i < entries.size(); ++i) {
scoped_ptr<ResourceEntry> entry(new ResourceEntry);
std::string parent_resource_id;
- bool converted =
- ConvertToResourceEntry(*entries[i], entry.get(), &parent_resource_id);
+ bool converted = ConvertFileResourceToResourceEntry(
+ *entries[i], entry.get(), &parent_resource_id);
DCHECK(converted);
entry->set_parent_local_id(parent_resource_id);