#include "components/drive/service/drive_api_service.h"
#include <stddef.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/observer_list.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "components/drive/drive_api_util.h"
#include "google_apis/common/auth_service.h"
#include "google_apis/common/request_sender.h"
#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/drive_api_requests.h"
#include "google_apis/drive/drive_base_requests.h"
#include "google_apis/drive/files_list_request_runner.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
AboutResourceCallback;
ApiErrorCode;
AuthStatusCallback;
CancelCallbackOnce;
CancelCallbackRepeating;
ChangeList;
ChangeListCallback;
DownloadActionCallback;
EntryActionCallback;
FileList;
FileListCallback;
FileResource;
FileResourceCallback;
FilesListCorpora;
FilesListRequestRunner;
GetContentCallback;
HTTP_NOT_IMPLEMENTED;
HTTP_SUCCESS;
InitiateUploadCallback;
OTHER_ERROR;
PARSE_ERROR;
ProgressCallback;
RequestSender;
StartPageTokenCallback;
TeamDriveListCallback;
UploadRangeResponse;
AboutGetRequest;
ChangesListNextPageRequest;
ChangesListRequest;
ChildrenDeleteRequest;
ChildrenInsertRequest;
DownloadFileRequest;
FilesCopyRequest;
FilesDeleteRequest;
FilesGetRequest;
FilesInsertRequest;
FilesListNextPageRequest;
FilesListRequest;
FilesPatchRequest;
FilesTrashRequest;
GetUploadStatusRequest;
InitiateUploadExistingFileRequest;
InitiateUploadNewFileRequest;
ResumeUploadRequest;
StartPageTokenRequest;
TeamDriveListRequest;
UploadRangeCallback;
namespace drive {
namespace {
const char kDriveScope[] = …;
const char kDriveAppsReadonlyScope[] = …;
const char kDriveAppsScope[] = …;
const char kFolderMimeType[] = …;
const int kMaxNumTeamDriveResourcePerRequest = …;
const int kMaxNumFilesResourcePerRequest = …;
const int kMaxNumFilesResourcePerRequestForSearch = …;
const char kAboutResourceFields[] = …;
const char kFileResourceFields[] = …;
const char kFileListFields[] = …;
const char kChangeListFields[] = …;
const char kTeamDrivesListFields[] = …;
void EntryActionCallbackAdapter(EntryActionCallback callback,
ApiErrorCode error,
std::unique_ptr<FileResource> entry) { … }
const char kDriveApiRootDirectoryResourceId[] = …;
}
BatchRequestConfigurator::BatchRequestConfigurator(
const base::WeakPtr<google_apis::drive::BatchUploadRequest>& batch_request,
base::SequencedTaskRunner* task_runner,
const google_apis::DriveApiUrlGenerator& url_generator,
const google_apis::CancelCallbackRepeating& cancel_callback)
: … { … }
BatchRequestConfigurator::~BatchRequestConfigurator() { … }
google_apis::CancelCallbackOnce
BatchRequestConfigurator::MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
const std::string& title,
const base::FilePath& local_file_path,
const UploadNewFileOptions& options,
FileResourceCallback callback,
ProgressCallback progress_callback) { … }
google_apis::CancelCallbackOnce
BatchRequestConfigurator::MultipartUploadExistingFile(
const std::string& content_type,
int64_t content_length,
const std::string& resource_id,
const base::FilePath& local_file_path,
const UploadExistingFileOptions& options,
FileResourceCallback callback,
ProgressCallback progress_callback) { … }
void BatchRequestConfigurator::Commit() { … }
DriveAPIService::DriveAPIService(
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
base::SequencedTaskRunner* blocking_task_runner,
const GURL& base_url,
const GURL& base_thumbnail_url,
const std::string& custom_user_agent,
const net::NetworkTrafficAnnotationTag& traffic_annotation)
: … { … }
DriveAPIService::~DriveAPIService() { … }
void DriveAPIService::Initialize(const CoreAccountId& account_id) { … }
void DriveAPIService::AddObserver(DriveServiceObserver* observer) { … }
void DriveAPIService::RemoveObserver(DriveServiceObserver* observer) { … }
bool DriveAPIService::CanSendRequest() const { … }
std::string DriveAPIService::GetRootResourceId() const { … }
CancelCallbackOnce DriveAPIService::GetAllTeamDriveList(
TeamDriveListCallback callback) { … }
CancelCallbackOnce DriveAPIService::GetAllFileList(
const std::string& team_drive_id,
FileListCallback callback) { … }
CancelCallbackOnce DriveAPIService::GetFileListInDirectory(
const std::string& directory_resource_id,
FileListCallback callback) { … }
CancelCallbackOnce DriveAPIService::Search(const std::string& search_query,
FileListCallback callback) { … }
CancelCallbackOnce DriveAPIService::SearchByTitle(
const std::string& title,
const std::string& directory_resource_id,
FileListCallback callback) { … }
CancelCallbackOnce DriveAPIService::GetChangeList(int64_t start_changestamp,
ChangeListCallback callback) { … }
CancelCallbackOnce DriveAPIService::GetChangeListByToken(
const std::string& team_drive_id,
const std::string& start_page_token,
ChangeListCallback callback) { … }
CancelCallbackOnce DriveAPIService::GetRemainingChangeList(
const GURL& next_link,
ChangeListCallback callback) { … }
CancelCallbackOnce DriveAPIService::GetRemainingTeamDriveList(
const std::string& page_token,
TeamDriveListCallback callback) { … }
CancelCallbackOnce DriveAPIService::GetRemainingFileList(
const GURL& next_link,
FileListCallback callback) { … }
CancelCallbackOnce DriveAPIService::GetFileResource(
const std::string& resource_id,
FileResourceCallback callback) { … }
CancelCallbackOnce DriveAPIService::GetAboutResource(
AboutResourceCallback callback) { … }
CancelCallbackOnce DriveAPIService::GetStartPageToken(
const std::string& team_drive_id,
StartPageTokenCallback callback) { … }
CancelCallbackOnce DriveAPIService::DownloadFile(
const base::FilePath& local_cache_path,
const std::string& resource_id,
DownloadActionCallback download_action_callback,
const GetContentCallback& get_content_callback,
ProgressCallback progress_callback) { … }
CancelCallbackOnce DriveAPIService::DeleteResource(
const std::string& resource_id,
const std::string& etag,
EntryActionCallback callback) { … }
CancelCallbackOnce DriveAPIService::TrashResource(
const std::string& resource_id,
EntryActionCallback callback) { … }
CancelCallbackOnce DriveAPIService::AddNewDirectory(
const std::string& parent_resource_id,
const std::string& directory_title,
const AddNewDirectoryOptions& options,
FileResourceCallback callback) { … }
CancelCallbackOnce DriveAPIService::CopyResource(
const std::string& resource_id,
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
FileResourceCallback callback) { … }
CancelCallbackOnce DriveAPIService::UpdateResource(
const std::string& resource_id,
const std::string& parent_resource_id,
const std::string& new_title,
const base::Time& last_modified,
const base::Time& last_viewed_by_me,
const google_apis::drive::Properties& properties,
FileResourceCallback callback) { … }
CancelCallbackOnce DriveAPIService::AddResourceToDirectory(
const std::string& parent_resource_id,
const std::string& resource_id,
EntryActionCallback callback) { … }
CancelCallbackOnce DriveAPIService::RemoveResourceFromDirectory(
const std::string& parent_resource_id,
const std::string& resource_id,
EntryActionCallback callback) { … }
CancelCallbackOnce DriveAPIService::InitiateUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
const std::string& title,
const UploadNewFileOptions& options,
InitiateUploadCallback callback) { … }
CancelCallbackOnce DriveAPIService::InitiateUploadExistingFile(
const std::string& content_type,
int64_t content_length,
const std::string& resource_id,
const UploadExistingFileOptions& options,
InitiateUploadCallback callback) { … }
CancelCallbackOnce DriveAPIService::ResumeUpload(
const GURL& upload_url,
int64_t start_position,
int64_t end_position,
int64_t content_length,
const std::string& content_type,
const base::FilePath& local_file_path,
UploadRangeCallback callback,
ProgressCallback progress_callback) { … }
CancelCallbackOnce DriveAPIService::GetUploadStatus(
const GURL& upload_url,
int64_t content_length,
UploadRangeCallback callback) { … }
CancelCallbackOnce DriveAPIService::MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
const std::string& title,
const base::FilePath& local_file_path,
const drive::UploadNewFileOptions& options,
FileResourceCallback callback,
ProgressCallback progress_callback) { … }
CancelCallbackOnce DriveAPIService::MultipartUploadExistingFile(
const std::string& content_type,
int64_t content_length,
const std::string& resource_id,
const base::FilePath& local_file_path,
const drive::UploadExistingFileOptions& options,
FileResourceCallback callback,
ProgressCallback progress_callback) { … }
google_apis::CancelCallbackOnce DriveAPIService::AddPermission(
const std::string& resource_id,
const std::string& email,
google_apis::drive::PermissionRole role,
google_apis::EntryActionCallback callback) { … }
bool DriveAPIService::HasAccessToken() const { … }
void DriveAPIService::RequestAccessToken(AuthStatusCallback callback) { … }
bool DriveAPIService::HasRefreshToken() const { … }
void DriveAPIService::ClearAccessToken() { … }
void DriveAPIService::ClearRefreshToken() { … }
void DriveAPIService::OnOAuth2RefreshTokenChanged() { … }
std::unique_ptr<BatchRequestConfiguratorInterface>
DriveAPIService::StartBatchRequest() { … }
}