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

Unified Diff: chrome/browser/chromeos/extensions/file_browser_event_router.cc

Issue 11365142: Small refactoring in DiskMountManager (event reporting; format method). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: few lint nits Created 8 years, 1 month 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
Index: chrome/browser/chromeos/extensions/file_browser_event_router.cc
diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc
index 7855ba1c233e2e70667cd738f4b2c28d9052253c..d6bf9775e88b01c06a762d70901bf81b3b2116b4 100644
--- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc
@@ -36,7 +36,6 @@
#include "webkit/fileapi/file_system_util.h"
using chromeos::disks::DiskMountManager;
-using chromeos::disks::DiskMountManagerEventType;
using content::BrowserThread;
using drive::DriveSystemService;
using drive::DriveSystemServiceFactory;
@@ -243,9 +242,9 @@ void FileBrowserEventRouter::MountDrive(
// Raise mount event.
// We can pass chromeos::MOUNT_ERROR_NONE even when authentication is failed
// or network is unreachable. These two errors will be handled later.
- MountCompleted(DiskMountManager::MOUNTING,
- chromeos::MOUNT_ERROR_NONE,
- mount_info);
+ OnMountEvent(DiskMountManager::MOUNTING,
+ chromeos::MOUNT_ERROR_NONE,
+ mount_info);
if (!callback.is_null())
callback.Run();
@@ -272,58 +271,45 @@ void FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(bool start) {
}
}
-void FileBrowserEventRouter::DiskChanged(
- DiskMountManagerEventType event,
+void FileBrowserEventRouter::OnDiskEvent(
+ DiskMountManager::DiskEvent event,
const DiskMountManager::Disk* disk) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Disregard hidden devices.
if (disk->is_hidden())
return;
- if (event == chromeos::disks::MOUNT_DISK_ADDED) {
+ if (event == DiskMountManager::DISK_ADDED) {
OnDiskAdded(disk);
- } else if (event == chromeos::disks::MOUNT_DISK_REMOVED) {
+ } else if (event == DiskMountManager::DISK_REMOVED) {
OnDiskRemoved(disk);
}
}
-void FileBrowserEventRouter::DeviceChanged(
- DiskMountManagerEventType event,
+void FileBrowserEventRouter::OnDeviceEvent(
+ DiskMountManager::DeviceEvent event,
const std::string& device_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (event == chromeos::disks::MOUNT_DEVICE_ADDED) {
+ if (event == DiskMountManager::DEVICE_ADDED) {
OnDeviceAdded(device_path);
- } else if (event == chromeos::disks::MOUNT_DEVICE_REMOVED) {
+ } else if (event == DiskMountManager::DEVICE_REMOVED) {
OnDeviceRemoved(device_path);
- } else if (event == chromeos::disks::MOUNT_DEVICE_SCANNED) {
+ } else if (event == DiskMountManager::DEVICE_SCANNED) {
OnDeviceScanned(device_path);
- } else if (event == chromeos::disks::MOUNT_FORMATTING_STARTED) {
- // TODO(tbarzic): get rid of '!'.
- if (device_path[0] == '!') {
- OnFormattingStarted(device_path.substr(1), false);
- } else {
- OnFormattingStarted(device_path, true);
- }
- } else if (event == chromeos::disks::MOUNT_FORMATTING_FINISHED) {
- if (device_path[0] == '!') {
- OnFormattingFinished(device_path.substr(1), false);
- } else {
- OnFormattingFinished(device_path, true);
- }
}
}
-void FileBrowserEventRouter::MountCompleted(
- DiskMountManager::MountEvent event_type,
+void FileBrowserEventRouter::OnMountEvent(
+ DiskMountManager::MountEvent event,
chromeos::MountError error_code,
const DiskMountManager::MountPointInfo& mount_info) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DispatchMountCompletedEvent(event_type, error_code, mount_info);
+ DispatchMountEvent(event, error_code, mount_info);
if (mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE &&
- event_type == DiskMountManager::MOUNTING) {
+ event == DiskMountManager::MOUNTING) {
DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance();
const DiskMountManager::Disk* disk =
disk_mount_manager->FindDiskBySourcePath(mount_info.source_path);
@@ -337,7 +323,7 @@ void FileBrowserEventRouter::MountCompleted(
} else if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) {
// Clear the "mounted" state for archive files in gdata cache
// when mounting failed or unmounting succeeded.
- if ((event_type == DiskMountManager::MOUNTING) !=
+ if ((event == DiskMountManager::MOUNTING) !=
(error_code == chromeos::MOUNT_ERROR_NONE)) {
FilePath source_path(mount_info.source_path);
DriveSystemService* system_service =
@@ -352,6 +338,17 @@ void FileBrowserEventRouter::MountCompleted(
}
}
+void FileBrowserEventRouter::OnFormatEvent(
+ DiskMountManager::FormatEvent event,
+ chromeos::FormatError error_code,
+ const std::string& device_path) {
+ if (event == DiskMountManager::FORMAT_STARTED) {
+ OnFormatStarted(device_path, error_code == chromeos::FORMAT_ERROR_NONE);
+ } else if (event == DiskMountManager::FORMAT_COMPLETED) {
+ OnFormatCompleted(device_path, error_code == chromeos::FORMAT_ERROR_NONE);
+ }
+}
+
void FileBrowserEventRouter::OnNetworkManagerChanged(
chromeos::NetworkLibrary* network_library) {
if (!profile_ ||
@@ -448,15 +445,15 @@ void FileBrowserEventRouter::OnFileSystemMounted() {
void FileBrowserEventRouter::OnFileSystemBeingUnmounted() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // Raise a MountCompleted event to notify the File Manager.
+ // Raise a mount event to notify the File Manager.
const std::string& gdata_path = drive::util::GetDriveMountPointPathAsString();
DiskMountManager::MountPointInfo mount_info(
gdata_path,
gdata_path,
chromeos::MOUNT_TYPE_GDATA,
chromeos::disks::MOUNT_CONDITION_NONE);
- MountCompleted(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE,
- mount_info);
+ OnMountEvent(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE,
+ mount_info);
}
void FileBrowserEventRouter::OnAuthenticationFailed(
@@ -466,15 +463,15 @@ void FileBrowserEventRouter::OnAuthenticationFailed(
if (error == google_apis::GDATA_NO_CONNECTION)
return;
- // Raise a MountCompleted event to notify the File Manager.
+ // Raise a mount event to notify the File Manager.
const std::string& gdata_path = drive::util::GetDriveMountPointPathAsString();
DiskMountManager::MountPointInfo mount_info(
gdata_path,
gdata_path,
chromeos::MOUNT_TYPE_GDATA,
chromeos::disks::MOUNT_CONDITION_NONE);
- MountCompleted(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE,
- mount_info);
+ OnMountEvent(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE,
+ mount_info);
}
void FileBrowserEventRouter::HandleFileWatchNotification(
@@ -547,7 +544,7 @@ void FileBrowserEventRouter::DispatchDiskEvent(
GURL());
}
-void FileBrowserEventRouter::DispatchMountCompletedEvent(
+void FileBrowserEventRouter::DispatchMountEvent(
DiskMountManager::MountEvent event,
chromeos::MountError error_code,
const DiskMountManager::MountPointInfo& mount_info) {
@@ -700,7 +697,7 @@ void FileBrowserEventRouter::OnDeviceScanned(
VLOG(1) << "Device scanned : " << device_path;
}
-void FileBrowserEventRouter::OnFormattingStarted(
+void FileBrowserEventRouter::OnFormatStarted(
const std::string& device_path, bool success) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -713,7 +710,7 @@ void FileBrowserEventRouter::OnFormattingStarted(
}
}
-void FileBrowserEventRouter::OnFormattingFinished(
+void FileBrowserEventRouter::OnFormatCompleted(
const std::string& device_path, bool success) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_event_router.h ('k') | chrome/browser/chromeos/imageburner/burn_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698