Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: components/drive/service/drive_api_service.cc

Issue 2894513003: Fetch files shared in Team Drives by specifying allTeamDrives corpora. (Closed)
Patch Set: Make comment style consistent with existing one Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | google_apis/drive/drive_api_requests.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/drive/service/drive_api_service.cc
diff --git a/components/drive/service/drive_api_service.cc b/components/drive/service/drive_api_service.cc
index 89672e6c0c491e595d97ebeb54b43f31c986971a..34e8792c800bfb65ccf44a7263ad5dca6e85b363 100644
--- a/components/drive/service/drive_api_service.cc
+++ b/components/drive/service/drive_api_service.cc
@@ -17,6 +17,7 @@
#include "google_apis/drive/base_requests.h"
#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/drive_api_requests.h"
+#include "google_apis/drive/drive_switches.h"
#include "google_apis/drive/files_list_request_runner.h"
#include "google_apis/drive/request_sender.h"
#include "google_apis/google_api_keys.h"
@@ -39,6 +40,7 @@ using google_apis::FileList;
using google_apis::FileListCallback;
using google_apis::FileResource;
using google_apis::FileResourceCallback;
+using google_apis::FilesListCorpora;
using google_apis::FilesListRequestRunner;
using google_apis::GetContentCallback;
using google_apis::GetShareUrlCallback;
@@ -346,6 +348,10 @@ CancelCallback DriveAPIService::GetAllFileList(
request->set_max_results(kMaxNumFilesResourcePerRequest);
request->set_q("trashed = false"); // Exclude trashed files.
request->set_fields(kFileListFields);
+ if (google_apis::GetTeamDrivesIntegrationSwitch() ==
+ google_apis::TEAM_DRIVES_INTEGRATION_ENABLED) {
+ request->set_corpora(google_apis::FilesListCorpora::ALL_TEAM_DRIVES);
+ }
return sender_->StartRequestWithAuthRetry(std::move(request));
}
@@ -356,6 +362,15 @@ CancelCallback DriveAPIService::GetFileListInDirectory(
DCHECK(!directory_resource_id.empty());
DCHECK(!callback.is_null());
+ // TODO(yamaguchi): Use FileListScope::CreateForTeamDrive instead of
+ // kAllTeamDrives for efficiency. It'll require to add a new parameter to tell
+ // which team drive the directory resource belongs to.
+ FilesListCorpora corpora =
+ (google_apis::GetTeamDrivesIntegrationSwitch() ==
+ google_apis::TEAM_DRIVES_INTEGRATION_ENABLED)
+ ? google_apis::FilesListCorpora::ALL_TEAM_DRIVES
+ : google_apis::FilesListCorpora::DEFAULT;
+
// Because children.list method on Drive API v2 returns only the list of
// children's references, but we need all file resource list.
// So, here we use files.list method instead, with setting parents query.
@@ -364,7 +379,7 @@ CancelCallback DriveAPIService::GetFileListInDirectory(
// to client side.
// We aren't interested in files in trash in this context, neither.
return files_list_request_runner_->CreateAndStartWithSizeBackoff(
- kMaxNumFilesResourcePerRequest,
+ kMaxNumFilesResourcePerRequest, corpora, std::string(),
base::StringPrintf(
"'%s' in parents and trashed = false",
util::EscapeQueryStringValue(directory_resource_id).c_str()),
@@ -378,8 +393,14 @@ CancelCallback DriveAPIService::Search(
DCHECK(!search_query.empty());
DCHECK(!callback.is_null());
+ FilesListCorpora corpora =
+ (google_apis::GetTeamDrivesIntegrationSwitch() ==
+ google_apis::TEAM_DRIVES_INTEGRATION_ENABLED)
+ ? google_apis::FilesListCorpora::ALL_TEAM_DRIVES
+ : google_apis::FilesListCorpora::DEFAULT;
+
return files_list_request_runner_->CreateAndStartWithSizeBackoff(
- kMaxNumFilesResourcePerRequestForSearch,
+ kMaxNumFilesResourcePerRequestForSearch, corpora, std::string(),
util::TranslateQuery(search_query), kFileListFields, callback);
}
« no previous file with comments | « no previous file | google_apis/drive/drive_api_requests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698