| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 base::DictionaryValue* local_storage_summary) { | 98 base::DictionaryValue* local_storage_summary) { |
| 99 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 99 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 100 DCHECK(local_storage_summary); | 100 DCHECK(local_storage_summary); |
| 101 | 101 |
| 102 const int64 free_space = base::SysInfo::AmountOfFreeDiskSpace(home_path); | 102 const int64 free_space = base::SysInfo::AmountOfFreeDiskSpace(home_path); |
| 103 local_storage_summary->SetDouble("free_space", free_space); | 103 local_storage_summary->SetDouble("free_space", free_space); |
| 104 } | 104 } |
| 105 | 105 |
| 106 // Formats |entry| into text. | 106 // Formats |entry| into text. |
| 107 std::string FormatEntry(const FilePath& path, | 107 std::string FormatEntry(const FilePath& path, |
| 108 const gdata::DriveEntryProto& entry) { | 108 const drive::DriveEntryProto& entry) { |
| 109 using base::StringAppendF; | 109 using base::StringAppendF; |
| 110 using gdata::util::FormatTimeAsString; | 110 using gdata::util::FormatTimeAsString; |
| 111 | 111 |
| 112 std::string out; | 112 std::string out; |
| 113 StringAppendF(&out, "%s\n", path.AsUTF8Unsafe().c_str()); | 113 StringAppendF(&out, "%s\n", path.AsUTF8Unsafe().c_str()); |
| 114 StringAppendF(&out, " title: %s\n", entry.title().c_str()); | 114 StringAppendF(&out, " title: %s\n", entry.title().c_str()); |
| 115 StringAppendF(&out, " resource_id: %s\n", entry.resource_id().c_str()); | 115 StringAppendF(&out, " resource_id: %s\n", entry.resource_id().c_str()); |
| 116 StringAppendF(&out, " edit_url: %s\n", entry.edit_url().c_str()); | 116 StringAppendF(&out, " edit_url: %s\n", entry.edit_url().c_str()); |
| 117 StringAppendF(&out, " content_url: %s\n", entry.content_url().c_str()); | 117 StringAppendF(&out, " content_url: %s\n", entry.content_url().c_str()); |
| 118 StringAppendF(&out, " parent_resource_id: %s\n", | 118 StringAppendF(&out, " parent_resource_id: %s\n", |
| 119 entry.parent_resource_id().c_str()); | 119 entry.parent_resource_id().c_str()); |
| 120 StringAppendF(&out, " upload_url: %s\n", entry.upload_url().c_str()); | 120 StringAppendF(&out, " upload_url: %s\n", entry.upload_url().c_str()); |
| 121 | 121 |
| 122 const gdata::PlatformFileInfoProto& file_info = entry.file_info(); | 122 const drive::PlatformFileInfoProto& file_info = entry.file_info(); |
| 123 StringAppendF(&out, " file_info\n"); | 123 StringAppendF(&out, " file_info\n"); |
| 124 StringAppendF(&out, " size: %"PRId64"\n", file_info.size()); | 124 StringAppendF(&out, " size: %"PRId64"\n", file_info.size()); |
| 125 StringAppendF(&out, " is_directory: %d\n", file_info.is_directory()); | 125 StringAppendF(&out, " is_directory: %d\n", file_info.is_directory()); |
| 126 StringAppendF(&out, " is_symbolic_link: %d\n", | 126 StringAppendF(&out, " is_symbolic_link: %d\n", |
| 127 file_info.is_symbolic_link()); | 127 file_info.is_symbolic_link()); |
| 128 | 128 |
| 129 const base::Time last_modified = base::Time::FromInternalValue( | 129 const base::Time last_modified = base::Time::FromInternalValue( |
| 130 file_info.last_modified()); | 130 file_info.last_modified()); |
| 131 const base::Time last_accessed = base::Time::FromInternalValue( | 131 const base::Time last_accessed = base::Time::FromInternalValue( |
| 132 file_info.last_accessed()); | 132 file_info.last_accessed()); |
| 133 const base::Time creation_time = base::Time::FromInternalValue( | 133 const base::Time creation_time = base::Time::FromInternalValue( |
| 134 file_info.creation_time()); | 134 file_info.creation_time()); |
| 135 StringAppendF(&out, " last_modified: %s\n", | 135 StringAppendF(&out, " last_modified: %s\n", |
| 136 FormatTimeAsString(last_modified).c_str()); | 136 FormatTimeAsString(last_modified).c_str()); |
| 137 StringAppendF(&out, " last_accessed: %s\n", | 137 StringAppendF(&out, " last_accessed: %s\n", |
| 138 FormatTimeAsString(last_accessed).c_str()); | 138 FormatTimeAsString(last_accessed).c_str()); |
| 139 StringAppendF(&out, " creation_time: %s\n", | 139 StringAppendF(&out, " creation_time: %s\n", |
| 140 FormatTimeAsString(creation_time).c_str()); | 140 FormatTimeAsString(creation_time).c_str()); |
| 141 | 141 |
| 142 if (entry.has_file_specific_info()) { | 142 if (entry.has_file_specific_info()) { |
| 143 const gdata::DriveFileSpecificInfo& file_specific_info = | 143 const drive::DriveFileSpecificInfo& file_specific_info = |
| 144 entry.file_specific_info(); | 144 entry.file_specific_info(); |
| 145 StringAppendF(&out, " thumbnail_url: %s\n", | 145 StringAppendF(&out, " thumbnail_url: %s\n", |
| 146 file_specific_info.thumbnail_url().c_str()); | 146 file_specific_info.thumbnail_url().c_str()); |
| 147 StringAppendF(&out, " alternate_url: %s\n", | 147 StringAppendF(&out, " alternate_url: %s\n", |
| 148 file_specific_info.alternate_url().c_str()); | 148 file_specific_info.alternate_url().c_str()); |
| 149 StringAppendF(&out, " content_mime_type: %s\n", | 149 StringAppendF(&out, " content_mime_type: %s\n", |
| 150 file_specific_info.content_mime_type().c_str()); | 150 file_specific_info.content_mime_type().c_str()); |
| 151 StringAppendF(&out, " file_md5: %s\n", | 151 StringAppendF(&out, " file_md5: %s\n", |
| 152 file_specific_info.file_md5().c_str()); | 152 file_specific_info.file_md5().c_str()); |
| 153 StringAppendF(&out, " document_extension: %s\n", | 153 StringAppendF(&out, " document_extension: %s\n", |
| (...skipping 14 matching lines...) Expand all Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 virtual ~DriveInternalsWebUIHandler() { | 170 virtual ~DriveInternalsWebUIHandler() { |
| 171 } | 171 } |
| 172 | 172 |
| 173 private: | 173 private: |
| 174 // WebUIMessageHandler override. | 174 // WebUIMessageHandler override. |
| 175 virtual void RegisterMessages() OVERRIDE; | 175 virtual void RegisterMessages() OVERRIDE; |
| 176 | 176 |
| 177 // Returns a DriveSystemService. | 177 // Returns a DriveSystemService. |
| 178 gdata::DriveSystemService* GetSystemService(); | 178 drive::DriveSystemService* GetSystemService(); |
| 179 | 179 |
| 180 // Called when the page is first loaded. | 180 // Called when the page is first loaded. |
| 181 void OnPageLoaded(const base::ListValue* args); | 181 void OnPageLoaded(const base::ListValue* args); |
| 182 | 182 |
| 183 // Called when GetGCacheContents() is complete. | 183 // Called when GetGCacheContents() is complete. |
| 184 void OnGetGCacheContents(base::ListValue* gcache_contents, | 184 void OnGetGCacheContents(base::ListValue* gcache_contents, |
| 185 base::DictionaryValue* cache_summary); | 185 base::DictionaryValue* cache_summary); |
| 186 | 186 |
| 187 // Called when ReadDirectoryByPath() is complete. | 187 // Called when ReadDirectoryByPath() is complete. |
| 188 void OnReadDirectoryByPath(const FilePath& parent_path, | 188 void OnReadDirectoryByPath(const FilePath& parent_path, |
| 189 gdata::DriveFileError error, | 189 drive::DriveFileError error, |
| 190 bool hide_hosted_documents, | 190 bool hide_hosted_documents, |
| 191 scoped_ptr<gdata::DriveEntryProtoVector> entries); | 191 scoped_ptr<drive::DriveEntryProtoVector> entries); |
| 192 | 192 |
| 193 // Called when GetResourceIdsOfAllFilesOnUIThread() is complete. | 193 // Called when GetResourceIdsOfAllFilesOnUIThread() is complete. |
| 194 void OnGetResourceIdsOfAllFiles( | 194 void OnGetResourceIdsOfAllFiles( |
| 195 const std::vector<std::string>& resource_ids); | 195 const std::vector<std::string>& resource_ids); |
| 196 | 196 |
| 197 // Called when GetCacheEntryOnUIThread() is complete. | 197 // Called when GetCacheEntryOnUIThread() is complete. |
| 198 void OnGetCacheEntry(const std::string& resource_id, | 198 void OnGetCacheEntry(const std::string& resource_id, |
| 199 bool success, | 199 bool success, |
| 200 const gdata::DriveCacheEntry& cache_entry); | 200 const drive::DriveCacheEntry& cache_entry); |
| 201 | 201 |
| 202 // Called when GetFreeDiskSpace() is complete. | 202 // Called when GetFreeDiskSpace() is complete. |
| 203 void OnGetFreeDiskSpace(base::DictionaryValue* local_storage_summary); | 203 void OnGetFreeDiskSpace(base::DictionaryValue* local_storage_summary); |
| 204 | 204 |
| 205 // Called when GetAccountMetadata() call to DriveService is complete. | 205 // Called when GetAccountMetadata() call to DriveService is complete. |
| 206 void OnGetAccountMetadata(gdata::GDataErrorCode status, | 206 void OnGetAccountMetadata(gdata::GDataErrorCode status, |
| 207 scoped_ptr<base::Value> data); | 207 scoped_ptr<base::Value> data); |
| 208 | 208 |
| 209 // Called when the page requests periodic update. | 209 // Called when the page requests periodic update. |
| 210 void OnPeriodicUpdate(const base::ListValue* args); | 210 void OnPeriodicUpdate(const base::ListValue* args); |
| 211 | 211 |
| 212 // Updates the summary about in-flight operations. | 212 // Updates the summary about in-flight operations. |
| 213 void UpdateInFlightOperations( | 213 void UpdateInFlightOperations( |
| 214 const gdata::DriveServiceInterface* drive_service); | 214 const drive::DriveServiceInterface* drive_service); |
| 215 | 215 |
| 216 // The number of pending ReadDirectoryByPath() calls. | 216 // The number of pending ReadDirectoryByPath() calls. |
| 217 int num_pending_reads_; | 217 int num_pending_reads_; |
| 218 base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_; | 218 base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_; |
| 219 DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler); | 219 DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler); |
| 220 }; | 220 }; |
| 221 | 221 |
| 222 void DriveInternalsWebUIHandler::OnGetAccountMetadata( | 222 void DriveInternalsWebUIHandler::OnGetAccountMetadata( |
| 223 gdata::GDataErrorCode status, scoped_ptr<base::Value> data) { | 223 gdata::GDataErrorCode status, scoped_ptr<base::Value> data) { |
| 224 if (status != gdata::HTTP_SUCCESS) { | 224 if (status != gdata::HTTP_SUCCESS) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 web_ui()->RegisterMessageCallback( | 276 web_ui()->RegisterMessageCallback( |
| 277 "pageLoaded", | 277 "pageLoaded", |
| 278 base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded, | 278 base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded, |
| 279 weak_ptr_factory_.GetWeakPtr())); | 279 weak_ptr_factory_.GetWeakPtr())); |
| 280 web_ui()->RegisterMessageCallback( | 280 web_ui()->RegisterMessageCallback( |
| 281 "periodicUpdate", | 281 "periodicUpdate", |
| 282 base::Bind(&DriveInternalsWebUIHandler::OnPeriodicUpdate, | 282 base::Bind(&DriveInternalsWebUIHandler::OnPeriodicUpdate, |
| 283 weak_ptr_factory_.GetWeakPtr())); | 283 weak_ptr_factory_.GetWeakPtr())); |
| 284 } | 284 } |
| 285 | 285 |
| 286 gdata::DriveSystemService* DriveInternalsWebUIHandler::GetSystemService() { | 286 drive::DriveSystemService* DriveInternalsWebUIHandler::GetSystemService() { |
| 287 Profile* profile = Profile::FromWebUI(web_ui()); | 287 Profile* profile = Profile::FromWebUI(web_ui()); |
| 288 return gdata::DriveSystemServiceFactory::GetForProfile(profile); | 288 return drive::DriveSystemServiceFactory::GetForProfile(profile); |
| 289 } | 289 } |
| 290 | 290 |
| 291 void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) { | 291 void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) { |
| 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 293 | 293 |
| 294 gdata::DriveSystemService* system_service = GetSystemService(); | 294 drive::DriveSystemService* system_service = GetSystemService(); |
| 295 // |system_service| may be NULL in the guest/incognito mode. | 295 // |system_service| may be NULL in the guest/incognito mode. |
| 296 if (!system_service) | 296 if (!system_service) |
| 297 return; | 297 return; |
| 298 | 298 |
| 299 gdata::DriveServiceInterface* drive_service = system_service->drive_service(); | 299 drive::DriveServiceInterface* drive_service = system_service->drive_service(); |
| 300 DCHECK(drive_service); | 300 DCHECK(drive_service); |
| 301 | 301 |
| 302 // Update the auth status section. | 302 // Update the auth status section. |
| 303 base::DictionaryValue auth_status; | 303 base::DictionaryValue auth_status; |
| 304 auth_status.SetBoolean("has-refresh-token", | 304 auth_status.SetBoolean("has-refresh-token", |
| 305 drive_service->HasRefreshToken()); | 305 drive_service->HasRefreshToken()); |
| 306 auth_status.SetBoolean("has-access-token", | 306 auth_status.SetBoolean("has-access-token", |
| 307 drive_service->HasAccessToken()); | 307 drive_service->HasAccessToken()); |
| 308 web_ui()->CallJavascriptFunction("updateAuthStatus", auth_status); | 308 web_ui()->CallJavascriptFunction("updateAuthStatus", auth_status); |
| 309 | 309 |
| 310 // Update account metadata section. | 310 // Update account metadata section. |
| 311 drive_service->GetAccountMetadata( | 311 drive_service->GetAccountMetadata( |
| 312 base::Bind(&DriveInternalsWebUIHandler::OnGetAccountMetadata, | 312 base::Bind(&DriveInternalsWebUIHandler::OnGetAccountMetadata, |
| 313 weak_ptr_factory_.GetWeakPtr())); | 313 weak_ptr_factory_.GetWeakPtr())); |
| 314 | 314 |
| 315 // Start updating the GCache contents section. | 315 // Start updating the GCache contents section. |
| 316 Profile* profile = Profile::FromWebUI(web_ui()); | 316 Profile* profile = Profile::FromWebUI(web_ui()); |
| 317 const FilePath root_path = | 317 const FilePath root_path = |
| 318 gdata::DriveCache::GetCacheRootPath(profile); | 318 drive::DriveCache::GetCacheRootPath(profile); |
| 319 base::ListValue* gcache_contents = new ListValue; | 319 base::ListValue* gcache_contents = new ListValue; |
| 320 base::DictionaryValue* gcache_summary = new DictionaryValue; | 320 base::DictionaryValue* gcache_summary = new DictionaryValue; |
| 321 BrowserThread::PostBlockingPoolTaskAndReply( | 321 BrowserThread::PostBlockingPoolTaskAndReply( |
| 322 FROM_HERE, | 322 FROM_HERE, |
| 323 base::Bind(&GetGCacheContents, | 323 base::Bind(&GetGCacheContents, |
| 324 root_path, | 324 root_path, |
| 325 gcache_contents, | 325 gcache_contents, |
| 326 gcache_summary), | 326 gcache_summary), |
| 327 base::Bind(&DriveInternalsWebUIHandler::OnGetGCacheContents, | 327 base::Bind(&DriveInternalsWebUIHandler::OnGetGCacheContents, |
| 328 weak_ptr_factory_.GetWeakPtr(), | 328 weak_ptr_factory_.GetWeakPtr(), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 347 void DriveInternalsWebUIHandler::OnGetGCacheContents( | 347 void DriveInternalsWebUIHandler::OnGetGCacheContents( |
| 348 base::ListValue* gcache_contents, | 348 base::ListValue* gcache_contents, |
| 349 base::DictionaryValue* gcache_summary) { | 349 base::DictionaryValue* gcache_summary) { |
| 350 DCHECK(gcache_contents); | 350 DCHECK(gcache_contents); |
| 351 DCHECK(gcache_summary); | 351 DCHECK(gcache_summary); |
| 352 web_ui()->CallJavascriptFunction("updateGCacheContents", | 352 web_ui()->CallJavascriptFunction("updateGCacheContents", |
| 353 *gcache_contents, | 353 *gcache_contents, |
| 354 *gcache_summary); | 354 *gcache_summary); |
| 355 | 355 |
| 356 // Start updating the file system tree section, if we have access token. | 356 // Start updating the file system tree section, if we have access token. |
| 357 gdata::DriveSystemService* system_service = GetSystemService(); | 357 drive::DriveSystemService* system_service = GetSystemService(); |
| 358 if (!system_service->drive_service()->HasAccessToken()) | 358 if (!system_service->drive_service()->HasAccessToken()) |
| 359 return; | 359 return; |
| 360 | 360 |
| 361 // Start rendering the file system tree as text. | 361 // Start rendering the file system tree as text. |
| 362 const FilePath root_path = FilePath(gdata::kDriveRootDirectory); | 362 const FilePath root_path = FilePath(drive::kDriveRootDirectory); |
| 363 ++num_pending_reads_; | 363 ++num_pending_reads_; |
| 364 system_service->file_system()->ReadDirectoryByPath( | 364 system_service->file_system()->ReadDirectoryByPath( |
| 365 root_path, | 365 root_path, |
| 366 base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath, | 366 base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath, |
| 367 weak_ptr_factory_.GetWeakPtr(), | 367 weak_ptr_factory_.GetWeakPtr(), |
| 368 root_path)); | 368 root_path)); |
| 369 } | 369 } |
| 370 | 370 |
| 371 void DriveInternalsWebUIHandler::OnReadDirectoryByPath( | 371 void DriveInternalsWebUIHandler::OnReadDirectoryByPath( |
| 372 const FilePath& parent_path, | 372 const FilePath& parent_path, |
| 373 gdata::DriveFileError error, | 373 drive::DriveFileError error, |
| 374 bool hide_hosted_documents, | 374 bool hide_hosted_documents, |
| 375 scoped_ptr<gdata::DriveEntryProtoVector> entries) { | 375 scoped_ptr<drive::DriveEntryProtoVector> entries) { |
| 376 --num_pending_reads_; | 376 --num_pending_reads_; |
| 377 if (error == gdata::DRIVE_FILE_OK) { | 377 if (error == drive::DRIVE_FILE_OK) { |
| 378 DCHECK(entries.get()); | 378 DCHECK(entries.get()); |
| 379 | 379 |
| 380 std::string file_system_as_text; | 380 std::string file_system_as_text; |
| 381 for (size_t i = 0; i < entries->size(); ++i) { | 381 for (size_t i = 0; i < entries->size(); ++i) { |
| 382 const gdata::DriveEntryProto& entry = (*entries)[i]; | 382 const drive::DriveEntryProto& entry = (*entries)[i]; |
| 383 const FilePath current_path = parent_path.Append( | 383 const FilePath current_path = parent_path.Append( |
| 384 FilePath::FromUTF8Unsafe(entry.base_name())); | 384 FilePath::FromUTF8Unsafe(entry.base_name())); |
| 385 | 385 |
| 386 file_system_as_text.append(FormatEntry(current_path, entry) + "\n"); | 386 file_system_as_text.append(FormatEntry(current_path, entry) + "\n"); |
| 387 | 387 |
| 388 if (entry.file_info().is_directory()) { | 388 if (entry.file_info().is_directory()) { |
| 389 ++num_pending_reads_; | 389 ++num_pending_reads_; |
| 390 GetSystemService()->file_system()->ReadDirectoryByPath( | 390 GetSystemService()->file_system()->ReadDirectoryByPath( |
| 391 current_path, | 391 current_path, |
| 392 base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath, | 392 base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 420 "", // Don't check MD5. | 420 "", // Don't check MD5. |
| 421 base::Bind(&DriveInternalsWebUIHandler::OnGetCacheEntry, | 421 base::Bind(&DriveInternalsWebUIHandler::OnGetCacheEntry, |
| 422 weak_ptr_factory_.GetWeakPtr(), | 422 weak_ptr_factory_.GetWeakPtr(), |
| 423 resource_id)); | 423 resource_id)); |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 | 426 |
| 427 void DriveInternalsWebUIHandler::OnGetCacheEntry( | 427 void DriveInternalsWebUIHandler::OnGetCacheEntry( |
| 428 const std::string& resource_id, | 428 const std::string& resource_id, |
| 429 bool success, | 429 bool success, |
| 430 const gdata::DriveCacheEntry& cache_entry) { | 430 const drive::DriveCacheEntry& cache_entry) { |
| 431 if (!success) { | 431 if (!success) { |
| 432 LOG(ERROR) << "Failed to get cache entry: " << resource_id; | 432 LOG(ERROR) << "Failed to get cache entry: " << resource_id; |
| 433 return; | 433 return; |
| 434 } | 434 } |
| 435 | 435 |
| 436 // Convert |cache_entry| into a dictionary. | 436 // Convert |cache_entry| into a dictionary. |
| 437 base::DictionaryValue value; | 437 base::DictionaryValue value; |
| 438 value.SetString("resource_id", resource_id); | 438 value.SetString("resource_id", resource_id); |
| 439 value.SetString("md5", cache_entry.md5()); | 439 value.SetString("md5", cache_entry.md5()); |
| 440 value.SetBoolean("is_present", cache_entry.is_present()); | 440 value.SetBoolean("is_present", cache_entry.is_present()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 451 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 451 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 452 DCHECK(local_storage_summary); | 452 DCHECK(local_storage_summary); |
| 453 | 453 |
| 454 web_ui()->CallJavascriptFunction( | 454 web_ui()->CallJavascriptFunction( |
| 455 "updateLocalStorageUsage", *local_storage_summary); | 455 "updateLocalStorageUsage", *local_storage_summary); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void DriveInternalsWebUIHandler::OnPeriodicUpdate(const base::ListValue* args) { | 458 void DriveInternalsWebUIHandler::OnPeriodicUpdate(const base::ListValue* args) { |
| 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 460 | 460 |
| 461 gdata::DriveSystemService* system_service = GetSystemService(); | 461 drive::DriveSystemService* system_service = GetSystemService(); |
| 462 // |system_service| may be NULL in the guest/incognito mode. | 462 // |system_service| may be NULL in the guest/incognito mode. |
| 463 if (!system_service) | 463 if (!system_service) |
| 464 return; | 464 return; |
| 465 | 465 |
| 466 gdata::DriveServiceInterface* drive_service = system_service->drive_service(); | 466 drive::DriveServiceInterface* drive_service = system_service->drive_service(); |
| 467 DCHECK(drive_service); | 467 DCHECK(drive_service); |
| 468 | 468 |
| 469 UpdateInFlightOperations(drive_service); | 469 UpdateInFlightOperations(drive_service); |
| 470 } | 470 } |
| 471 | 471 |
| 472 void DriveInternalsWebUIHandler::UpdateInFlightOperations( | 472 void DriveInternalsWebUIHandler::UpdateInFlightOperations( |
| 473 const gdata::DriveServiceInterface* drive_service) { | 473 const drive::DriveServiceInterface* drive_service) { |
| 474 gdata::OperationProgressStatusList | 474 gdata::OperationProgressStatusList |
| 475 progress_status_list = drive_service->GetProgressStatusList(); | 475 progress_status_list = drive_service->GetProgressStatusList(); |
| 476 | 476 |
| 477 base::ListValue in_flight_operations; | 477 base::ListValue in_flight_operations; |
| 478 for (size_t i = 0; i < progress_status_list.size(); ++i) { | 478 for (size_t i = 0; i < progress_status_list.size(); ++i) { |
| 479 const gdata::OperationProgressStatus& status = progress_status_list[i]; | 479 const gdata::OperationProgressStatus& status = progress_status_list[i]; |
| 480 | 480 |
| 481 base::DictionaryValue* dict = new DictionaryValue; | 481 base::DictionaryValue* dict = new DictionaryValue; |
| 482 dict->SetInteger("operation_id", status.operation_id); | 482 dict->SetInteger("operation_id", status.operation_id); |
| 483 dict->SetString( | 483 dict->SetString( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 508 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); | 508 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); |
| 509 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); | 509 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); |
| 510 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); | 510 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); |
| 511 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); | 511 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); |
| 512 | 512 |
| 513 Profile* profile = Profile::FromWebUI(web_ui); | 513 Profile* profile = Profile::FromWebUI(web_ui); |
| 514 ChromeURLDataManager::AddDataSource(profile, source); | 514 ChromeURLDataManager::AddDataSource(profile, source); |
| 515 } | 515 } |
| 516 | 516 |
| 517 } // namespace chromeos | 517 } // namespace chromeos |
| OLD | NEW |