| 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 "chromeos/dbus/cros_disks_client.h" | 5 #include "chromeos/dbus/cros_disks_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 const char* kDefaultMountOptions[] = { | 35 const char* kDefaultMountOptions[] = { |
| 36 "nodev", "noexec", "nosuid", | 36 "nodev", "noexec", "nosuid", |
| 37 }; | 37 }; |
| 38 const char kReadOnlyOption[] = "ro"; | 38 const char kReadOnlyOption[] = "ro"; |
| 39 const char kReadWriteOption[] = "rw"; | 39 const char kReadWriteOption[] = "rw"; |
| 40 const char kRemountOption[] = "remount"; | 40 const char kRemountOption[] = "remount"; |
| 41 const char kMountLabelOption[] = "mountlabel"; | 41 const char kMountLabelOption[] = "mountlabel"; |
| 42 | 42 |
| 43 const char* kDefaultUnmountOptions[] = { | |
| 44 "force", | |
| 45 }; | |
| 46 | |
| 47 const char kLazyUnmountOption[] = "lazy"; | 43 const char kLazyUnmountOption[] = "lazy"; |
| 48 | 44 |
| 49 // Checks if retrieved media type is in boundaries of DeviceMediaType. | 45 // Checks if retrieved media type is in boundaries of DeviceMediaType. |
| 50 bool IsValidMediaType(uint32_t type) { | 46 bool IsValidMediaType(uint32_t type) { |
| 51 return type < static_cast<uint32_t>(cros_disks::DEVICE_MEDIA_NUM_VALUES); | 47 return type < static_cast<uint32_t>(cros_disks::DEVICE_MEDIA_NUM_VALUES); |
| 52 } | 48 } |
| 53 | 49 |
| 54 // Translates enum used in cros-disks to enum used in Chrome. | 50 // Translates enum used in cros-disks to enum used in Chrome. |
| 55 // Note that we could just do static_cast, but this is less sensitive to | 51 // Note that we could just do static_cast, but this is less sensitive to |
| 56 // changes in cros-disks. | 52 // changes in cros-disks. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // CrosDisksClient override. | 122 // CrosDisksClient override. |
| 127 void Unmount(const std::string& device_path, | 123 void Unmount(const std::string& device_path, |
| 128 UnmountOptions options, | 124 UnmountOptions options, |
| 129 const base::Closure& callback, | 125 const base::Closure& callback, |
| 130 const base::Closure& error_callback) override { | 126 const base::Closure& error_callback) override { |
| 131 dbus::MethodCall method_call(cros_disks::kCrosDisksInterface, | 127 dbus::MethodCall method_call(cros_disks::kCrosDisksInterface, |
| 132 cros_disks::kUnmount); | 128 cros_disks::kUnmount); |
| 133 dbus::MessageWriter writer(&method_call); | 129 dbus::MessageWriter writer(&method_call); |
| 134 writer.AppendString(device_path); | 130 writer.AppendString(device_path); |
| 135 | 131 |
| 136 std::vector<std::string> unmount_options( | 132 std::vector<std::string> unmount_options; |
| 137 kDefaultUnmountOptions, | |
| 138 kDefaultUnmountOptions + arraysize(kDefaultUnmountOptions)); | |
| 139 if (options == UNMOUNT_OPTIONS_LAZY) | 133 if (options == UNMOUNT_OPTIONS_LAZY) |
| 140 unmount_options.push_back(kLazyUnmountOption); | 134 unmount_options.push_back(kLazyUnmountOption); |
| 141 | 135 |
| 142 writer.AppendArrayOfStrings(unmount_options); | 136 writer.AppendArrayOfStrings(unmount_options); |
| 143 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 137 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 144 base::Bind(&CrosDisksClientImpl::OnUnmount, | 138 base::Bind(&CrosDisksClientImpl::OnUnmount, |
| 145 weak_ptr_factory_.GetWeakPtr(), | 139 weak_ptr_factory_.GetWeakPtr(), |
| 146 callback, | 140 callback, |
| 147 error_callback)); | 141 error_callback)); |
| 148 } | 142 } |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 | 670 |
| 677 if (!mount_label.empty()) { | 671 if (!mount_label.empty()) { |
| 678 std::string mount_label_option = | 672 std::string mount_label_option = |
| 679 base::StringPrintf("%s=%s", kMountLabelOption, mount_label.c_str()); | 673 base::StringPrintf("%s=%s", kMountLabelOption, mount_label.c_str()); |
| 680 mount_options.push_back(mount_label_option); | 674 mount_options.push_back(mount_label_option); |
| 681 } | 675 } |
| 682 return mount_options; | 676 return mount_options; |
| 683 } | 677 } |
| 684 | 678 |
| 685 } // namespace chromeos | 679 } // namespace chromeos |
| OLD | NEW |