Chromium Code Reviews| 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..ae0be2d31b1a9c4c09e50738a65feee6c5d17809 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."); |
| @@ -273,6 +272,15 @@ class MountLibraryImpl : public MountLibrary { |
| const MountPointMap& mount_points() const OVERRIDE { return mount_points_; } |
| private: |
|
tbarzic
2011/08/12 19:31:13
add comment // static.
sidor.dev
2011/08/12 20:27:09
no.
|
| + virtual std::string FilePathToDevicePath(std::string file_path) OVERRIDE { |
| + 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(); |
| + } |
| + return NULL; |
| + } |
| + |
| // Callback for MountComplete signal and MountSourcePath method. |
| static void MountCompletedHandler(void* object, |
| MountError error_code, |
| @@ -297,12 +305,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).c_str(); |
| + 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 +629,14 @@ class MountLibraryImpl : public MountLibrary { |
| break; |
| } |
| case FORMATTING_FINISHED: { |
| + // FORMATTING_FINISHED actually returns file path instead of device |
| + // path. |
| + device_path = FilePathToDevicePath(device_path).c_str(); |
| + if (!device_path) { |
| + LOG(ERROR) << "Error while handling disks metadata. Cannot find " << |
| + "device that is being formatted."; |
| + return; |
| + } |
| type = MOUNT_FORMATTING_FINISHED; |
| break; |
| } |
| @@ -700,6 +722,9 @@ class MountLibraryStubImpl : public MountLibrary { |
| OVERRIDE {} |
| private: |
| + virtual std::string FilePathToDevicePath(std::string file_path) OVERRIDE { |
| + return ""; |
| + } |
| // The list of disks found. |
| DiskMap disks_; |
| MountPointMap mount_points_; |