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

Unified Diff: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc

Issue 23531027: Replace directly use of DriveIntegrationService to drive::util::GetXxxByProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
index e173cdbb5b038f3dba3381e25cbfc7658901b9b8..8f6841d4747759b1075d5880b22882417d7433f3 100644
--- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
@@ -215,6 +215,12 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
// Returns a DriveIntegrationService.
drive::DriveIntegrationService* GetIntegrationService();
+ // Returns a DriveService instance.
+ drive::DriveServiceInterface* GetDriveService();
+
+ // Returns a FileSystem instance.
+ drive::FileSystemInterface* GetFileSystem();
+
// Called when the page is first loaded.
void OnPageLoaded(const base::ListValue* args);
@@ -374,10 +380,26 @@ drive::DriveIntegrationService*
DriveInternalsWebUIHandler::GetIntegrationService() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ // TODO(hidehiko): GetForProfile will return the instance always even if it
+ // is disabled. Needs to check the mounting state then. crbug.com/284972.
Profile* profile = Profile::FromWebUI(web_ui());
return drive::DriveIntegrationServiceFactory::GetForProfile(profile);
}
+drive::DriveServiceInterface* DriveInternalsWebUIHandler::GetDriveService() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ Profile* profile = Profile::FromWebUI(web_ui());
+ return drive::util::GetDriveServiceByProfile(profile);
+}
+
+drive::FileSystemInterface* DriveInternalsWebUIHandler::GetFileSystem() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ Profile* profile = Profile::FromWebUI(web_ui());
+ return drive::util::GetFileSystemByProfile(profile);
+}
+
void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -522,22 +544,18 @@ void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForLocal(
void DriveInternalsWebUIHandler::ClearAccessToken(const base::ListValue* args) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- drive::DriveIntegrationService* integration_service =
- GetIntegrationService();
- if (!integration_service)
- return;
- integration_service->drive_service()->ClearAccessToken();
+ drive::DriveServiceInterface* drive_service = GetDriveService();
+ if (drive_service)
+ drive_service->ClearAccessToken();
}
void DriveInternalsWebUIHandler::ClearRefreshToken(
const base::ListValue* args) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- drive::DriveIntegrationService* integration_service =
- GetIntegrationService();
- if (!integration_service)
- return;
- integration_service->drive_service()->ClearRefreshToken();
+ drive::DriveServiceInterface* drive_service = GetDriveService();
+ if (drive_service)
+ drive_service->ClearRefreshToken();
}
void DriveInternalsWebUIHandler::ListFileEntries(const base::ListValue* args) {
@@ -630,24 +648,25 @@ void DriveInternalsWebUIHandler::UpdateGCacheContentsSection() {
void DriveInternalsWebUIHandler::UpdateFileSystemContentsSection() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- drive::DriveIntegrationService* integration_service =
- GetIntegrationService();
- if (!integration_service)
+ drive::DriveServiceInterface* drive_service = GetDriveService();
+ drive::FileSystemInterface* file_system = GetFileSystem();
+ if (!drive_service || !file_system)
return;
+
// Start updating the file system tree section, if we have access token.
- if (!integration_service->drive_service()->HasAccessToken())
+ if (!drive_service->HasAccessToken())
return;
// Start rendering the file system tree as text.
const base::FilePath root_path = drive::util::GetDriveGrandRootPath();
- integration_service->file_system()->GetResourceEntryByPath(
+ file_system->GetResourceEntryByPath(
root_path,
base::Bind(&DriveInternalsWebUIHandler::OnGetResourceEntryByPath,
weak_ptr_factory_.GetWeakPtr(),
root_path));
- integration_service->file_system()->ReadDirectoryByPath(
+ file_system->ReadDirectoryByPath(
root_path,
base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath,
weak_ptr_factory_.GetWeakPtr(),
@@ -743,6 +762,7 @@ void DriveInternalsWebUIHandler::OnReadDirectoryByPath(
if (error == drive::FILE_ERROR_OK) {
DCHECK(entries.get());
+ drive::FileSystemInterface* file_system = GetFileSystem();
std::string file_system_as_text;
for (size_t i = 0; i < entries->size(); ++i) {
const drive::ResourceEntry& entry = (*entries)[i];
@@ -752,7 +772,7 @@ void DriveInternalsWebUIHandler::OnReadDirectoryByPath(
file_system_as_text.append(FormatEntry(current_path, entry) + "\n");
if (entry.file_info().is_directory()) {
- GetIntegrationService()->file_system()->ReadDirectoryByPath(
+ file_system->ReadDirectoryByPath(
current_path,
base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath,
weak_ptr_factory_.GetWeakPtr(),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698