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

Unified Diff: chrome/browser/chromeos/cros/mount_library.cc

Issue 7583041: Adding a format device button to UI. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix Created 9 years, 4 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 | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/extension_file_browser_private_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros/mount_library.cc
diff --git a/chrome/browser/chromeos/cros/mount_library.cc b/chrome/browser/chromeos/cros/mount_library.cc
index 6b32eb25060e1c883079b625aa8a5f93cecf57b1..77a06a2c6c132cc04ce9ef88cfd8849ecdb7489a 100644
--- a/chrome/browser/chromeos/cros/mount_library.cc
+++ b/chrome/browser/chromeos/cros/mount_library.cc
@@ -180,9 +180,8 @@ class MountLibraryImpl : public MountLibrary {
break;
}
}
-
if (!disk) {
- OnFormatDevice(disk->device_path().c_str(),
+ OnFormatDevice(mount_path,
false,
MOUNT_METHOD_ERROR_LOCAL,
"Device with this mount path not found.");
@@ -190,7 +189,7 @@ class MountLibraryImpl : public MountLibrary {
}
if (formatting_pending_.find(disk->device_path()) !=
formatting_pending_.end()) {
- OnFormatDevice(disk->device_path().c_str(),
+ OnFormatDevice(mount_path,
false,
MOUNT_METHOD_ERROR_LOCAL,
"Formatting is already pending.");
@@ -297,12 +296,18 @@ class MountLibraryImpl : public MountLibrary {
// Callback for FormatRemovableDevice method.
static void FormatDeviceCallback(void* object,
- const char* device_path,
+ const char* file_path,
bool success,
MountMethodErrorType error,
const char* error_message) {
DCHECK(object);
MountLibraryImpl* self = static_cast<MountLibraryImpl*>(object);
+ const char* device_path = self->FilePathToDevicePath(file_path);
+ if (!device_path) {
+ LOG(ERROR) << "Error while handling disks metadata. Cannot find "
+ << "device that is being formatted.";
+ return;
+ }
self->OnFormatDevice(device_path, success, error, error_message);
}
@@ -615,6 +620,14 @@ class MountLibraryImpl : public MountLibrary {
break;
}
case FORMATTING_FINISHED: {
+ // FORMATTING_FINISHED actually returns file path instead of device
+ // path.
+ device_path = FilePathToDevicePath(device_path);
+ if (!device_path) {
+ LOG(ERROR) << "Error while handling disks metadata. Cannot find "
+ << "device that is being formatted.";
+ return;
+ }
type = MOUNT_FORMATTING_FINISHED;
break;
}
@@ -658,6 +671,15 @@ class MountLibraryImpl : public MountLibrary {
mount_info));
}
+ const char* FilePathToDevicePath(const char* file_path) {
+ for (MountLibrary::DiskMap::iterator it = disks_.begin();
+ it != disks_.end(); ++it) {
+ if (it->second->file_path().compare(file_path) == 0)
+ return it->second->device_path().c_str();
+ }
+ return NULL;
+ }
+
// Mount event change observers.
ObserverList<Observer> observers_;
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/extension_file_browser_private_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698