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

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: Fixed UI refresing. 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..6ede3d7347e6ff2e930ccbb48adb2194558073f3 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,25 @@ 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 = NULL;
+ for (MountLibrary::DiskMap::iterator it = self->disks_.begin();
+ it != self->disks_.end(); ++it) {
tbarzic 2011/08/12 18:29:35 You should encapsulate path conversion into separa
sidor.dev 2011/08/12 19:14:20 Done.
+ if (it->second->file_path().compare(file_path) == 0) {
+ device_path = it->second->device_path().c_str();
+ break;
+ }
+ }
+ 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);
}
@@ -447,6 +459,7 @@ class MountLibraryImpl : public MountLibrary {
MountMethodErrorType error,
const char* error_message) {
DCHECK(device_path);
+ // In mount library we use device path to identify device.
tbarzic 2011/08/12 18:29:35 I don't think this comment is needed
sidor.dev 2011/08/12 19:14:20 Sorry, forgot to delete it.
if (error == MOUNT_METHOD_ERROR_NONE && device_path && success) {
FireDeviceStatusUpdate(MOUNT_FORMATTING_STARTED, device_path);
} else {
@@ -615,6 +628,22 @@ class MountLibraryImpl : public MountLibrary {
break;
}
case FORMATTING_FINISHED: {
+ // FORMATTING_FINISHED actually returns file path instead of device
+ // path.
+ const char* path = NULL;
+ for (MountLibrary::DiskMap::iterator it = disks_.begin();
+ it != disks_.end(); ++it) {
tbarzic 2011/08/12 18:29:35 use 5 space indent here
sidor.dev 2011/08/12 19:14:20 Done.
+ if (it->second->file_path().compare(device_path) == 0) {
+ path = it->second->device_path().c_str();
tbarzic 2011/08/12 18:29:35 Why don't you loose path and use device_path direc
sidor.dev 2011/08/12 19:14:20 Done.
+ break;
+ }
+ }
+ if (!path) {
+ LOG(ERROR) << "Error while handling disks metadata. Cannot find "
+ << "device that is being formatted.";
tbarzic 2011/08/12 18:29:35 align << with << in the previous row.
sidor.dev 2011/08/12 19:14:20 Done.
+ return;
+ }
+ device_path = path;
type = MOUNT_FORMATTING_FINISHED;
break;
}
« 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