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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 const drive::DriveCacheEntry& cache_entry); | 228 const drive::DriveCacheEntry& cache_entry); |
229 | 229 |
230 // Called when GetFreeDiskSpace() is complete. | 230 // Called when GetFreeDiskSpace() is complete. |
231 void OnGetFreeDiskSpace(base::DictionaryValue* local_storage_summary); | 231 void OnGetFreeDiskSpace(base::DictionaryValue* local_storage_summary); |
232 | 232 |
233 // Called when GetAccountMetadata() call to DriveService is complete. | 233 // Called when GetAccountMetadata() call to DriveService is complete. |
234 void OnGetAccountMetadata( | 234 void OnGetAccountMetadata( |
235 google_apis::GDataErrorCode status, | 235 google_apis::GDataErrorCode status, |
236 scoped_ptr<google_apis::AccountMetadataFeed> account_metadata); | 236 scoped_ptr<google_apis::AccountMetadataFeed> account_metadata); |
237 | 237 |
| 238 // Callback for DriveFilesystem::GetMetadata for local update. |
| 239 void OnGetFilesystemMetadataForLocal( |
| 240 const drive::DriveFileSystemMetadata& metadata); |
| 241 |
| 242 // Callback for DriveFilesystem::GetMetadata for local update. |
| 243 void OnGetFilesystemMetadataForDeltaUpdate( |
| 244 const drive::DriveFileSystemMetadata& metadata); |
| 245 |
238 // Called when the page requests periodic update. | 246 // Called when the page requests periodic update. |
239 void OnPeriodicUpdate(const base::ListValue* args); | 247 void OnPeriodicUpdate(const base::ListValue* args); |
240 | 248 |
241 // The number of pending ReadDirectoryByPath() calls. | 249 // The number of pending ReadDirectoryByPath() calls. |
242 int num_pending_reads_; | 250 int num_pending_reads_; |
243 // The last event sent to the JavaScript side. | 251 // The last event sent to the JavaScript side. |
244 int last_sent_event_id_; | 252 int last_sent_event_id_; |
245 | 253 |
246 base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_; | 254 base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_; |
247 DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler); | 255 DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 google_apis::DriveServiceInterface* drive_service) { | 402 google_apis::DriveServiceInterface* drive_service) { |
395 DCHECK(drive_service); | 403 DCHECK(drive_service); |
396 | 404 |
397 drive_service->GetAccountMetadata( | 405 drive_service->GetAccountMetadata( |
398 base::Bind(&DriveInternalsWebUIHandler::OnGetAccountMetadata, | 406 base::Bind(&DriveInternalsWebUIHandler::OnGetAccountMetadata, |
399 weak_ptr_factory_.GetWeakPtr())); | 407 weak_ptr_factory_.GetWeakPtr())); |
400 } | 408 } |
401 | 409 |
402 void DriveInternalsWebUIHandler::UpdateLocalMetadataSection( | 410 void DriveInternalsWebUIHandler::UpdateLocalMetadataSection( |
403 google_apis::DriveServiceInterface* drive_service) { | 411 google_apis::DriveServiceInterface* drive_service) { |
404 DCHECK(drive_service); | 412 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 413 |
| 414 GetSystemService()->file_system()->GetMetadata( |
| 415 base::Bind(&DriveInternalsWebUIHandler::OnGetFilesystemMetadataForLocal, |
| 416 weak_ptr_factory_.GetWeakPtr())); |
| 417 } |
| 418 |
| 419 void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForLocal( |
| 420 const drive::DriveFileSystemMetadata& metadata) { |
| 421 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
405 | 422 |
406 base::DictionaryValue local_metadata; | 423 base::DictionaryValue local_metadata; |
407 const drive::DriveFileSystemMetadata metadata = | |
408 GetSystemService()->file_system()->GetMetadata(); | |
409 local_metadata.SetDouble("account-largest-changestamp-local", | 424 local_metadata.SetDouble("account-largest-changestamp-local", |
410 metadata.largest_changestamp); | 425 metadata.largest_changestamp); |
411 local_metadata.SetBoolean("account-metadata-loaded", metadata.loaded); | 426 local_metadata.SetBoolean("account-metadata-loaded", metadata.loaded); |
412 local_metadata.SetBoolean("account-metadata-refreshing", metadata.refreshing); | 427 local_metadata.SetBoolean("account-metadata-refreshing", metadata.refreshing); |
413 web_ui()->CallJavascriptFunction("updateLocalMetadata", local_metadata); | 428 web_ui()->CallJavascriptFunction("updateLocalMetadata", local_metadata); |
414 } | 429 } |
415 | 430 |
416 void DriveInternalsWebUIHandler::UpdateDeltaUpdateStatusSection() { | 431 void DriveInternalsWebUIHandler::UpdateDeltaUpdateStatusSection() { |
417 const drive::DriveFileSystemMetadata metadata = | 432 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
418 GetSystemService()->file_system()->GetMetadata(); | 433 |
| 434 GetSystemService()->file_system()->GetMetadata( |
| 435 base::Bind( |
| 436 &DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate, |
| 437 weak_ptr_factory_.GetWeakPtr())); |
| 438 } |
| 439 |
| 440 void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate( |
| 441 const drive::DriveFileSystemMetadata& metadata) { |
| 442 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
419 | 443 |
420 base::DictionaryValue delta_update_status; | 444 base::DictionaryValue delta_update_status; |
421 delta_update_status.SetBoolean("push-notification-enabled", | 445 delta_update_status.SetBoolean("push-notification-enabled", |
422 metadata.push_notification_enabled); | 446 metadata.push_notification_enabled); |
423 delta_update_status.SetInteger("polling-interval-sec", | 447 delta_update_status.SetInteger("polling-interval-sec", |
424 metadata.polling_interval_sec); | 448 metadata.polling_interval_sec); |
425 delta_update_status.SetString( | 449 delta_update_status.SetString( |
426 "last-update-check-time", | 450 "last-update-check-time", |
427 google_apis::util::FormatTimeAsStringLocaltime( | 451 google_apis::util::FormatTimeAsStringLocaltime( |
428 metadata.last_update_check_time)); | 452 metadata.last_update_check_time)); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); | 687 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); |
664 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); | 688 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); |
665 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); | 689 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); |
666 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); | 690 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); |
667 | 691 |
668 Profile* profile = Profile::FromWebUI(web_ui); | 692 Profile* profile = Profile::FromWebUI(web_ui); |
669 ChromeURLDataManager::AddDataSource(profile, source); | 693 ChromeURLDataManager::AddDataSource(profile, source); |
670 } | 694 } |
671 | 695 |
672 } // namespace chromeos | 696 } // namespace chromeos |
OLD | NEW |