Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / chromeos / drive_internals_ui.cc
index eec636c..1a303de 100644 (file)
@@ -5,9 +5,8 @@
 #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h"
 
 #include "base/bind.h"
-#include "base/command_line.h"
-#include "base/file_util.h"
 #include "base/files/file_enumerator.h"
+#include "base/files/file_util.h"
 #include "base/format_macros.h"
 #include "base/memory/scoped_vector.h"
 #include "base/memory/weak_ptr.h"
@@ -36,7 +35,6 @@
 #include "google_apis/drive/auth_service.h"
 #include "google_apis/drive/drive_api_parser.h"
 #include "google_apis/drive/gdata_errorcode.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
 #include "google_apis/drive/time_util.h"
 #include "grit/browser_resources.h"
 
@@ -120,7 +118,7 @@ void GetFreeDiskSpace(const base::FilePath& home_path,
 // Formats |entry| into text.
 std::string FormatEntry(const base::FilePath& path,
                         const drive::ResourceEntry& entry) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   using base::StringAppendF;
 
@@ -313,7 +311,7 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
 void DriveInternalsWebUIHandler::OnGetAboutResource(
     google_apis::GDataErrorCode status,
     scoped_ptr<google_apis::AboutResource> parsed_about_resource) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   if (status != google_apis::HTTP_SUCCESS) {
     LOG(ERROR) << "Failed to get about resource";
@@ -337,7 +335,7 @@ void DriveInternalsWebUIHandler::OnGetAboutResource(
 void DriveInternalsWebUIHandler::OnGetAppList(
     google_apis::GDataErrorCode status,
     scoped_ptr<google_apis::AppList> parsed_app_list) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   if (status != google_apis::HTTP_SUCCESS) {
     LOG(ERROR) << "Failed to get app list";
@@ -393,7 +391,7 @@ void DriveInternalsWebUIHandler::RegisterMessages() {
 
 drive::DriveIntegrationService*
 DriveInternalsWebUIHandler::GetIntegrationService() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   Profile* profile = Profile::FromWebUI(web_ui());
   drive::DriveIntegrationService* service =
@@ -404,14 +402,14 @@ DriveInternalsWebUIHandler::GetIntegrationService() {
 }
 
 drive::DriveServiceInterface* DriveInternalsWebUIHandler::GetDriveService() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   Profile* profile = Profile::FromWebUI(web_ui());
   return drive::util::GetDriveServiceByProfile(profile);
 }
 
 drive::DebugInfoCollector* DriveInternalsWebUIHandler::GetDebugInfoCollector() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   drive::DriveIntegrationService* integration_service = GetIntegrationService();
   return integration_service ?
@@ -419,7 +417,7 @@ drive::DebugInfoCollector* DriveInternalsWebUIHandler::GetDebugInfoCollector() {
 }
 
 void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   drive::DriveIntegrationService* integration_service =
       GetIntegrationService();
@@ -455,7 +453,7 @@ void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
 }
 
 void DriveInternalsWebUIHandler::UpdateDriveRelatedPreferencesSection() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   const char* kDriveRelatedPreferences[] = {
     prefs::kDisableDrive,
@@ -481,7 +479,7 @@ void DriveInternalsWebUIHandler::UpdateDriveRelatedPreferencesSection() {
 
 void DriveInternalsWebUIHandler::UpdateConnectionStatusSection(
     drive::DriveServiceInterface* drive_service) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(drive_service);
 
   std::string status;
@@ -514,7 +512,7 @@ void DriveInternalsWebUIHandler::UpdateConnectionStatusSection(
 
 void DriveInternalsWebUIHandler::UpdateAboutResourceSection(
     drive::DriveServiceInterface* drive_service) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(drive_service);
 
   drive_service->GetAboutResource(
@@ -524,7 +522,7 @@ void DriveInternalsWebUIHandler::UpdateAboutResourceSection(
 
 void DriveInternalsWebUIHandler::UpdateAppListSection(
     drive::DriveServiceInterface* drive_service) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(drive_service);
 
   drive_service->GetAppList(
@@ -534,7 +532,7 @@ void DriveInternalsWebUIHandler::UpdateAppListSection(
 
 void DriveInternalsWebUIHandler::UpdateLocalMetadataSection(
     drive::DebugInfoCollector* debug_info_collector) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(debug_info_collector);
 
   debug_info_collector->GetMetadata(
@@ -544,7 +542,7 @@ void DriveInternalsWebUIHandler::UpdateLocalMetadataSection(
 
 void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForLocal(
     const drive::FileSystemMetadata& metadata) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   base::DictionaryValue local_metadata;
   local_metadata.SetDouble("account-largest-changestamp-local",
@@ -554,7 +552,7 @@ void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForLocal(
 }
 
 void DriveInternalsWebUIHandler::ClearAccessToken(const base::ListValue* args) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   drive::DriveServiceInterface* drive_service = GetDriveService();
   if (drive_service)
@@ -563,7 +561,7 @@ void DriveInternalsWebUIHandler::ClearAccessToken(const base::ListValue* args) {
 
 void DriveInternalsWebUIHandler::ClearRefreshToken(
     const base::ListValue* args) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   drive::DriveServiceInterface* drive_service = GetDriveService();
   if (drive_service)
@@ -572,7 +570,7 @@ void DriveInternalsWebUIHandler::ClearRefreshToken(
 
 void DriveInternalsWebUIHandler::ResetDriveFileSystem(
     const base::ListValue* args) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   drive::DriveIntegrationService* integration_service =
       GetIntegrationService();
@@ -584,21 +582,21 @@ void DriveInternalsWebUIHandler::ResetDriveFileSystem(
 }
 
 void DriveInternalsWebUIHandler::ResetFinished(bool success) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   web_ui()->CallJavascriptFunction("updateResetStatus",
                                    base::FundamentalValue(success));
 }
 
 void DriveInternalsWebUIHandler::ListFileEntries(const base::ListValue* args) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   UpdateFileSystemContentsSection();
 }
 
 void DriveInternalsWebUIHandler::UpdateDeltaUpdateStatusSection(
     drive::DebugInfoCollector* debug_info_collector) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(debug_info_collector);
 
   debug_info_collector->GetMetadata(
@@ -609,11 +607,11 @@ void DriveInternalsWebUIHandler::UpdateDeltaUpdateStatusSection(
 
 void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate(
     const drive::FileSystemMetadata& metadata) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   Profile* profile = Profile::FromWebUI(web_ui());
   drive::DriveNotificationManager* drive_notification_manager =
-      drive::DriveNotificationManagerFactory::GetForBrowserContext(profile);
+      drive::DriveNotificationManagerFactory::FindForBrowserContext(profile);
   if (!drive_notification_manager)
     return;
 
@@ -635,7 +633,7 @@ void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate(
 
 void DriveInternalsWebUIHandler::UpdateInFlightOperationsSection(
     drive::JobListInterface* job_list) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(job_list);
 
   std::vector<drive::JobInfo> info_list = job_list->GetJobInfoList();
@@ -658,7 +656,7 @@ void DriveInternalsWebUIHandler::UpdateInFlightOperationsSection(
 }
 
 void DriveInternalsWebUIHandler::UpdateGCacheContentsSection() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   // Start updating the GCache contents section.
   Profile* profile = Profile::FromWebUI(web_ui());
@@ -678,7 +676,7 @@ void DriveInternalsWebUIHandler::UpdateGCacheContentsSection() {
 }
 
 void DriveInternalsWebUIHandler::UpdateFileSystemContentsSection() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   drive::DebugInfoCollector* debug_info_collector = GetDebugInfoCollector();
   if (!debug_info_collector)
@@ -701,7 +699,7 @@ void DriveInternalsWebUIHandler::UpdateFileSystemContentsSection() {
 }
 
 void DriveInternalsWebUIHandler::UpdateLocalStorageUsageSection() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   // Propagate the amount of local free space in bytes.
   base::FilePath home_path;
@@ -720,7 +718,7 @@ void DriveInternalsWebUIHandler::UpdateLocalStorageUsageSection() {
 
 void DriveInternalsWebUIHandler::UpdateCacheContentsSection(
     drive::DebugInfoCollector* debug_info_collector) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(debug_info_collector);
 
   debug_info_collector->IterateFileCache(
@@ -730,7 +728,7 @@ void DriveInternalsWebUIHandler::UpdateCacheContentsSection(
 }
 
 void DriveInternalsWebUIHandler::UpdateEventLogSection() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   drive::DriveIntegrationService* integration_service =
       GetIntegrationService();
@@ -761,7 +759,7 @@ void DriveInternalsWebUIHandler::UpdateEventLogSection() {
 }
 
 void DriveInternalsWebUIHandler::UpdatePathConfigurationsSection() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   Profile* const profile = Profile::FromWebUI(web_ui());
 
@@ -791,7 +789,7 @@ void DriveInternalsWebUIHandler::UpdatePathConfigurationsSection() {
 void DriveInternalsWebUIHandler::OnGetGCacheContents(
     base::ListValue* gcache_contents,
     base::DictionaryValue* gcache_summary) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(gcache_contents);
   DCHECK(gcache_summary);
 
@@ -804,7 +802,7 @@ void DriveInternalsWebUIHandler::OnGetResourceEntryByPath(
     const base::FilePath& path,
     drive::FileError error,
     scoped_ptr<drive::ResourceEntry> entry) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   if (error == drive::FILE_ERROR_OK) {
     DCHECK(entry.get());
@@ -817,7 +815,7 @@ void DriveInternalsWebUIHandler::OnReadDirectoryByPath(
     const base::FilePath& parent_path,
     drive::FileError error,
     scoped_ptr<drive::ResourceEntryVector> entries) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   if (error == drive::FILE_ERROR_OK) {
     DCHECK(entries.get());
@@ -851,7 +849,7 @@ void DriveInternalsWebUIHandler::OnReadDirectoryByPath(
 void DriveInternalsWebUIHandler::UpdateCacheEntry(
     const std::string& local_id,
     const drive::FileCacheEntry& cache_entry) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   // Convert |cache_entry| into a dictionary.
   base::DictionaryValue value;
@@ -866,7 +864,7 @@ void DriveInternalsWebUIHandler::UpdateCacheEntry(
 
 void DriveInternalsWebUIHandler::OnGetFreeDiskSpace(
     base::DictionaryValue* local_storage_summary) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(local_storage_summary);
 
   web_ui()->CallJavascriptFunction(
@@ -874,7 +872,7 @@ void DriveInternalsWebUIHandler::OnGetFreeDiskSpace(
 }
 
 void DriveInternalsWebUIHandler::OnPeriodicUpdate(const base::ListValue* args) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
 
   drive::DriveIntegrationService* integration_service =
       GetIntegrationService();