Commit 048048dd authored by thestig@chromium.org's avatar thestig@chromium.org

Cleanup Various bits of Windows StorageMonitor classes.

Review URL: https://chromiumcodereview.appspot.com/16056002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203114 0039d316-1c4b-4281-b951-d872f2087c98
parent db88c700
......@@ -16,13 +16,6 @@
namespace chrome {
namespace {
const char16 kWindowClassName[] = L"Chrome_StorageMonitorWindow";
} // namespace
// StorageMonitorWin -------------------------------------------------------
// static
......@@ -59,7 +52,7 @@ StorageMonitorWin::~StorageMonitorWin() {
void StorageMonitorWin::Init() {
WNDCLASSEX window_class;
base::win::InitializeWindowClass(
kWindowClassName,
L"Chrome_StorageMonitorWindow",
&base::win::WrappedWindowProc<StorageMonitorWin::WndProcThunk>,
0, 0, 0, NULL, NULL, NULL, NULL, NULL,
&window_class);
......@@ -125,8 +118,8 @@ void StorageMonitorWin::EjectDevice(
bool StorageMonitorWin::GetMTPStorageInfoFromDeviceId(
const std::string& storage_device_id,
string16* device_location,
string16* storage_object_id) const {
base::string16* device_location,
base::string16* storage_object_id) const {
StorageInfo::Type type;
StorageInfo::CrackDeviceId(storage_device_id, &type, NULL);
return ((type == StorageInfo::MTP_OR_PTP) &&
......@@ -159,6 +152,8 @@ LRESULT CALLBACK StorageMonitorWin::WndProc(HWND hwnd, UINT message,
bool StorageMonitorWin::GetDeviceInfo(const base::FilePath& device_path,
StorageInfo* info) const {
DCHECK(info);
// TODO(kmadhusu) Implement PortableDeviceWatcherWin::GetDeviceInfo()
// function when we have the functionality to add a sub directory of
// portable device as a media gallery.
......
......@@ -39,8 +39,8 @@ class StorageMonitorWin : public StorageMonitor {
StorageInfo* device_info) const OVERRIDE;
virtual bool GetMTPStorageInfoFromDeviceId(
const std::string& storage_device_id,
string16* device_location,
string16* storage_object_id) const OVERRIDE;
base::string16* device_location,
base::string16* storage_object_id) const OVERRIDE;
virtual void EjectDevice(
const std::string& device_id,
......@@ -57,8 +57,7 @@ class StorageMonitorWin : public StorageMonitor {
PortableDeviceWatcherWin* portable_device_watcher);
// Gets the removable storage information given a |device_path|. On success,
// returns true and fills in |device_location|, |unique_id|, |name| and
// |removable|, and |total_size_in_bytes|.
// returns true and fills in |info|.
bool GetDeviceInfo(const base::FilePath& device_path,
StorageInfo* info) const;
......
......@@ -54,14 +54,14 @@ class StorageMonitorWinTest : public testing::Test {
// Injects a device attach or detach change (depending on the value of
// |test_attach|) and tests that the appropriate handler is called.
void DoMTPDeviceTest(const string16& pnp_device_id, bool test_attach);
void DoMTPDeviceTest(const base::string16& pnp_device_id, bool test_attach);
// Gets the MTP details of the storage specified by the |storage_device_id|.
// On success, returns true and fills in |pnp_device_id| and
// |storage_object_id|.
bool GetMTPStorageInfo(const std::string& storage_device_id,
string16* pnp_device_id,
string16* storage_object_id);
base::string16* pnp_device_id,
base::string16* storage_object_id);
scoped_ptr<TestStorageMonitorWin> monitor_;
......@@ -198,7 +198,7 @@ void StorageMonitorWinTest::DoMassStorageDevicesDetachedTest(
EXPECT_EQ(expect_detach_calls, observer_.detach_calls());
}
void StorageMonitorWinTest::DoMTPDeviceTest(const string16& pnp_device_id,
void StorageMonitorWinTest::DoMTPDeviceTest(const base::string16& pnp_device_id,
bool test_attach) {
GUID guidDevInterface = GUID_NULL;
HRESULT hr = CLSIDFromString(kWPDDevInterfaceGUID, &guidDevInterface);
......@@ -224,8 +224,8 @@ void StorageMonitorWinTest::DoMTPDeviceTest(const string16& pnp_device_id,
for (PortableDeviceWatcherWin::StorageObjectIDs::const_iterator it =
storage_object_ids.begin(); it != storage_object_ids.end(); ++it) {
std::string unique_id;
string16 name;
string16 location;
base::string16 name;
base::string16 location;
TestPortableDeviceWatcherWin::GetMTPStorageDetails(pnp_device_id, *it,
&location, &unique_id,
&name);
......@@ -246,8 +246,8 @@ void StorageMonitorWinTest::DoMTPDeviceTest(const string16& pnp_device_id,
bool StorageMonitorWinTest::GetMTPStorageInfo(
const std::string& storage_device_id,
string16* pnp_device_id,
string16* storage_object_id) {
base::string16* pnp_device_id,
base::string16* storage_object_id) {
return monitor_->GetMTPStorageInfoFromDeviceId(storage_device_id,
pnp_device_id,
storage_object_id);
......@@ -433,7 +433,7 @@ TEST_F(StorageMonitorWinTest, DuplicateAttachCheckSuppressed) {
volume_mount_watcher_->FlushWorkerPoolForTesting();
RunUntilIdle();
std::vector<base::FilePath> checked_devices =
const std::vector<base::FilePath>& checked_devices =
volume_mount_watcher_->devices_checked();
ASSERT_EQ(1u, checked_devices.size());
EXPECT_EQ(kAttachedDevicePath, checked_devices[0]);
......@@ -445,7 +445,6 @@ TEST_F(StorageMonitorWinTest, DuplicateAttachCheckSuppressed) {
volume_mount_watcher_->ReleaseDeviceCheck();
RunUntilIdle();
checked_devices = volume_mount_watcher_->devices_checked();
ASSERT_EQ(2u, checked_devices.size());
EXPECT_EQ(kAttachedDevicePath, checked_devices[0]);
EXPECT_EQ(kAttachedDevicePath, checked_devices[1]);
......@@ -529,12 +528,13 @@ TEST_F(StorageMonitorWinTest, GetMTPStorageInfoFromDeviceId) {
for (PortableDeviceWatcherWin::StorageObjects::const_iterator it =
storage_objects.begin();
it != storage_objects.end(); ++it) {
string16 pnp_device_id;
string16 storage_object_id;
base::string16 pnp_device_id;
base::string16 storage_object_id;
ASSERT_TRUE(GetMTPStorageInfo(it->object_persistent_id, &pnp_device_id,
&storage_object_id));
EXPECT_EQ(string16(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo),
pnp_device_id);
base::string16 expected(
TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo);
EXPECT_EQ(expected, pnp_device_id);
EXPECT_EQ(it->object_persistent_id,
TestPortableDeviceWatcherWin::GetMTPStorageUniqueId(
pnp_device_id, storage_object_id));
......
......@@ -76,9 +76,9 @@ bool GetMassStorageDeviceDetails(const base::FilePath& device_path,
"\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\";
unique_id[11] = device_path.value()[0];
std::string device_id = StorageInfo::MakeDeviceId(type, unique_id);
string16 storage_label = path.Append(L" Drive").LossyDisplayName();
*info = StorageInfo(device_id, string16(), path.value(), storage_label,
string16(), string16(), 1000000);
base::string16 storage_label = path.Append(L" Drive").LossyDisplayName();
*info = StorageInfo(device_id, base::string16(), path.value(), storage_label,
base::string16(), base::string16(), 1000000);
return true;
}
......@@ -96,10 +96,11 @@ TestVolumeMountWatcherWin::~TestVolumeMountWatcherWin() {
void TestVolumeMountWatcherWin::AddDeviceForTesting(
const base::FilePath& device_path,
const std::string& device_id,
const string16& device_name,
const base::string16& device_name,
uint64 total_size_in_bytes) {
StorageInfo info(device_id, device_name, device_path.value(),
string16(), string16(), string16(), total_size_in_bytes);
base::string16(), base::string16(), base::string16(),
total_size_in_bytes);
HandleDeviceAttachEventOnUIThread(device_path, info);
}
......@@ -128,9 +129,10 @@ void TestVolumeMountWatcherWin::ReleaseDeviceCheck() {
device_check_complete_event_->Signal();
}
// static
bool TestVolumeMountWatcherWin::GetDeviceRemovable(
const base::FilePath& device_path,
bool* removable) const {
bool* removable) {
StorageInfo info;
bool success = GetMassStorageDeviceDetails(device_path, &info);
*removable = StorageInfo::IsRemovableDevice(info.device_id());
......@@ -146,7 +148,6 @@ VolumeMountWatcherWin::GetAttachedDevicesCallbackType
TestVolumeMountWatcherWin::GetAttachedDevicesCallback() const {
if (attached_devices_fake_)
return base::Bind(&FakeGetAttachedDevices);
return base::Bind(&FakeGetSingleAttachedDevice);
}
......
......@@ -27,9 +27,12 @@ class TestVolumeMountWatcherWin : public VolumeMountWatcherWin {
TestVolumeMountWatcherWin();
virtual ~TestVolumeMountWatcherWin();
static bool GetDeviceRemovable(const base::FilePath& device_path,
bool* removable);
void AddDeviceForTesting(const base::FilePath& device_path,
const std::string& device_id,
const string16& device_name,
const base::string16& device_name,
uint64 total_size_in_bytes);
void SetAttachedDevicesFake();
......@@ -38,7 +41,7 @@ class TestVolumeMountWatcherWin : public VolumeMountWatcherWin {
virtual void DeviceCheckComplete(const base::FilePath& device_path);
std::vector<base::FilePath> devices_checked() const {
const std::vector<base::FilePath>& devices_checked() const {
return devices_checked_;
}
......@@ -46,11 +49,7 @@ class TestVolumeMountWatcherWin : public VolumeMountWatcherWin {
void ReleaseDeviceCheck();
bool GetDeviceRemovable(const base::FilePath& device_path,
bool* removable) const;
// VolumeMountWatcherWin:
virtual GetAttachedDevicesCallbackType
GetAttachedDevicesCallback() const OVERRIDE;
virtual GetDeviceDetailsCallbackType
......
......@@ -27,6 +27,8 @@
using content::BrowserThread;
namespace chrome {
namespace {
const DWORD kMaxPathBufLen = MAX_PATH + 1;
......@@ -53,7 +55,7 @@ enum EjectWinLockOutcomes {
// on either floppy or removable volumes. The DRIVE_CDROM type is handled
// as a floppy, as are DRIVE_UNKNOWN and DRIVE_NO_ROOT_DIR, as there are
// reports that some floppy drives don't report as DRIVE_REMOVABLE.
DeviceType GetDeviceType(const string16& mount_point) {
DeviceType GetDeviceType(const base::string16& mount_point) {
UINT drive_type = GetDriveType(mount_point.c_str());
if (drive_type == DRIVE_FIXED || drive_type == DRIVE_REMOTE ||
drive_type == DRIVE_RAMDISK) {
......@@ -64,22 +66,22 @@ DeviceType GetDeviceType(const string16& mount_point) {
// Check device strings of the form "X:" and "\\.\X:"
// For floppy drives, these will return strings like "/Device/Floppy0"
string16 device = mount_point;
base::string16 device = mount_point;
if (EndsWith(mount_point, L"\\", false))
device = mount_point.substr(0, mount_point.length() - 1);
string16 device_path;
string16 device_path_slash;
base::string16 device_path;
base::string16 device_path_slash;
DWORD dos_device = QueryDosDevice(
device.c_str(), WriteInto(&device_path, kMaxPathBufLen), kMaxPathBufLen);
string16 device_slash = string16(L"\\\\.\\");
base::string16 device_slash = base::string16(L"\\\\.\\");
device_slash += device;
DWORD dos_device_slash = QueryDosDevice(
device_slash.c_str(), WriteInto(&device_path_slash, kMaxPathBufLen),
kMaxPathBufLen);
if (dos_device == 0 && dos_device_slash == 0)
return FLOPPY;
if (device_path.find(L"Floppy") != string16::npos ||
device_path_slash.find(L"Floppy") != string16::npos) {
if (device_path.find(L"Floppy") != base::string16::npos ||
device_path_slash.find(L"Floppy") != base::string16::npos) {
return FLOPPY;
}
......@@ -104,7 +106,7 @@ bool IsLogicalVolumeStructure(LPARAM data) {
}
// Gets the total volume of the |mount_point| in bytes.
uint64 GetVolumeSize(const string16& mount_point) {
uint64 GetVolumeSize(const base::string16& mount_point) {
ULARGE_INTEGER total;
if (!GetDiskFreeSpaceExW(mount_point.c_str(), NULL, &total, NULL))
return 0;
......@@ -116,11 +118,10 @@ uint64 GetVolumeSize(const string16& mount_point) {
// The following msdn blog entry is helpful for understanding disk volumes
// and how they are treated in Windows:
// http://blogs.msdn.com/b/adioltean/archive/2005/04/16/408947.aspx.
bool GetDeviceDetails(const base::FilePath& device_path,
chrome::StorageInfo* info) {
bool GetDeviceDetails(const base::FilePath& device_path, StorageInfo* info) {
DCHECK(info);
string16 mount_point;
base::string16 mount_point;
if (!GetVolumePathName(device_path.value().c_str(),
WriteInto(&mount_point, kMaxPathBufLen),
kMaxPathBufLen)) {
......@@ -130,7 +131,7 @@ bool GetDeviceDetails(const base::FilePath& device_path,
// Note: experimentally this code does not spin a floppy drive. It
// returns a GUID associated with the device, not the volume.
string16 guid;
base::string16 guid;
if (!GetVolumeNameForVolumeMountPoint(mount_point.c_str(),
WriteInto(&guid, kMaxPathBufLen),
kMaxPathBufLen)) {
......@@ -148,33 +149,32 @@ bool GetDeviceDetails(const base::FilePath& device_path,
// Note: treats FLOPPY as FIXED_MASS_STORAGE. This is intentional.
DeviceType device_type = GetDeviceType(mount_point);
if (device_type == FLOPPY) {
info->set_device_id(chrome::StorageInfo::MakeDeviceId(
chrome::StorageInfo::FIXED_MASS_STORAGE, UTF16ToUTF8(guid)));
info->set_device_id(StorageInfo::MakeDeviceId(
StorageInfo::FIXED_MASS_STORAGE, UTF16ToUTF8(guid)));
return true;
}
chrome::StorageInfo::Type type = chrome::StorageInfo::FIXED_MASS_STORAGE;
StorageInfo::Type type = StorageInfo::FIXED_MASS_STORAGE;
if (device_type == REMOVABLE) {
type = chrome::StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM;
if (chrome::MediaStorageUtil::HasDcim(base::FilePath(mount_point)))
type = chrome::StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM;
type = StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM;
if (MediaStorageUtil::HasDcim(base::FilePath(mount_point)))
type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM;
}
// NOTE: experimentally, this function returns false if there is no volume
// name set.
string16 volume_label;
base::string16 volume_label;
GetVolumeInformationW(device_path.value().c_str(),
WriteInto(&volume_label, kMaxPathBufLen),
kMaxPathBufLen, NULL, NULL, NULL, NULL, 0);
uint64 total_size_in_bytes = GetVolumeSize(mount_point);
std::string device_id =
chrome::StorageInfo::MakeDeviceId(type, UTF16ToUTF8(guid));
std::string device_id = StorageInfo::MakeDeviceId(type, UTF16ToUTF8(guid));
// TODO(gbillock): if volume_label.empty(), get the vendor/model information
// for the volume.
*info = chrome::StorageInfo(device_id, string16(), mount_point,
volume_label, string16(), string16(),
*info = StorageInfo(device_id, base::string16(), mount_point,
volume_label, base::string16(), base::string16(),
total_size_in_bytes);
return true;
}
......@@ -183,14 +183,14 @@ bool GetDeviceDetails(const base::FilePath& device_path,
// connected.
std::vector<base::FilePath> GetAttachedDevices() {
std::vector<base::FilePath> result;
string16 volume_name;
base::string16 volume_name;
HANDLE find_handle = FindFirstVolume(WriteInto(&volume_name, kMaxPathBufLen),
kMaxPathBufLen);
if (find_handle == INVALID_HANDLE_VALUE)
return result;
while (true) {
string16 volume_path;
base::string16 volume_path;
DWORD return_count;
if (GetVolumePathNamesForVolumeName(volume_name.c_str(),
WriteInto(&volume_path, kMaxPathBufLen),
......@@ -217,7 +217,7 @@ std::vector<base::FilePath> GetAttachedDevices() {
// See http://support.microsoft.com/kb/165721
void EjectDeviceInThreadPool(
const base::FilePath& device,
base::Callback<void(chrome::StorageMonitor::EjectStatus)> callback,
base::Callback<void(StorageMonitor::EjectStatus)> callback,
scoped_refptr<base::SequencedTaskRunner> task_runner,
int iteration) {
base::FilePath::StringType volume_name;
......@@ -227,9 +227,9 @@ void EjectDeviceInThreadPool(
// at not-just-drive-letter paths.
if (drive_letter < L'A' || drive_letter > L'Z' ||
device != device.DirName()) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(callback, chrome::StorageMonitor::EJECT_FAILURE));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(callback, StorageMonitor::EJECT_FAILURE));
return;
}
base::SStringPrintf(&volume_name, L"\\\\.\\%lc:", drive_letter);
......@@ -240,9 +240,9 @@ void EjectDeviceInThreadPool(
NULL, OPEN_EXISTING, 0, NULL));
if (!volume_handle.IsValid()) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(callback, chrome::StorageMonitor::EJECT_FAILURE));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(callback, StorageMonitor::EJECT_FAILURE));
return;
}
......@@ -267,16 +267,16 @@ void EjectDeviceInThreadPool(
// Try again -- the lock may have been a transient one. This happens on
// things like AV disk lock for some reason, or another process
// transient disk lock.
task_runner->PostDelayedTask(FROM_HERE,
task_runner->PostDelayedTask(
FROM_HERE,
base::Bind(&EjectDeviceInThreadPool,
device, callback, task_runner, iteration + 1),
kLockRetryInterval);
return;
}
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(callback, chrome::StorageMonitor::EJECT_IN_USE));
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(callback, StorageMonitor::EJECT_IN_USE));
return;
}
......@@ -291,9 +291,8 @@ void EjectDeviceInThreadPool(
if (!dismounted) {
DeviceIoControl(volume_handle, FSCTL_UNLOCK_VOLUME,
NULL, 0, NULL, 0, &bytes_returned, NULL);
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(callback, chrome::StorageMonitor::EJECT_OK));
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(callback, StorageMonitor::EJECT_OK));
return;
}
......@@ -303,30 +302,27 @@ void EjectDeviceInThreadPool(
if (!DeviceIoControl(volume_handle, IOCTL_STORAGE_MEDIA_REMOVAL,
&pmr_buffer, sizeof(PREVENT_MEDIA_REMOVAL),
NULL, 0, &bytes_returned, NULL)) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(callback, chrome::StorageMonitor::EJECT_FAILURE));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(callback, StorageMonitor::EJECT_FAILURE));
return;
}
// Physically eject or soft-eject the device.
if (!DeviceIoControl(volume_handle, IOCTL_STORAGE_EJECT_MEDIA,
NULL, 0, NULL, 0, &bytes_returned, NULL)) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(callback, chrome::StorageMonitor::EJECT_FAILURE));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(callback, StorageMonitor::EJECT_FAILURE));
return;
}
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(callback, chrome::StorageMonitor::EJECT_OK));
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(callback, StorageMonitor::EJECT_OK));
}
} // namespace
namespace chrome {
const int kWorkerPoolNumThreads = 3;
const char* kWorkerPoolNamePrefix = "DeviceInfoPool";
......@@ -345,7 +341,7 @@ VolumeMountWatcherWin::VolumeMountWatcherWin()
base::FilePath VolumeMountWatcherWin::DriveNumberToFilePath(int drive_number) {
if (drive_number < 0 || drive_number > 25)
return base::FilePath();
string16 path(L"_:\\");
base::string16 path(L"_:\\");
path[0] = L'A' + drive_number;
return base::FilePath(path);
}
......@@ -377,8 +373,9 @@ void VolumeMountWatcherWin::AddDevicesOnUIThread(
if (ContainsKey(pending_device_checks_, removable_devices[i]))
continue;
pending_device_checks_.insert(removable_devices[i]);
task_runner_->PostTask(FROM_HERE, base::Bind(
&VolumeMountWatcherWin::RetrieveInfoForDeviceAndAdd,
task_runner_->PostTask(
FROM_HERE,
base::Bind(&VolumeMountWatcherWin::RetrieveInfoForDeviceAndAdd,
removable_devices[i], GetDeviceDetailsCallback(),
weak_factory_.GetWeakPtr()));
}
......@@ -388,17 +385,19 @@ void VolumeMountWatcherWin::AddDevicesOnUIThread(
void VolumeMountWatcherWin::RetrieveInfoForDeviceAndAdd(
const base::FilePath& device_path,
const GetDeviceDetailsCallbackType& get_device_details_callback,
base::WeakPtr<chrome::VolumeMountWatcherWin> volume_watcher) {
base::WeakPtr<VolumeMountWatcherWin> volume_watcher) {
StorageInfo info;
if (!get_device_details_callback.Run(device_path, &info)) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
&chrome::VolumeMountWatcherWin::DeviceCheckComplete,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&VolumeMountWatcherWin::DeviceCheckComplete,
volume_watcher, device_path));
return;
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
&chrome::VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread,
volume_watcher, device_path, info));
}
......@@ -426,6 +425,7 @@ VolumeMountWatcherWin::GetDeviceDetailsCallbackType
bool VolumeMountWatcherWin::GetDeviceInfo(const base::FilePath& device_path,
StorageInfo* info) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(info);
base::FilePath path(device_path);
MountPointDeviceMetadataMap::const_iterator iter =
device_metadata_.find(path.value());
......@@ -437,9 +437,7 @@ bool VolumeMountWatcherWin::GetDeviceInfo(const base::FilePath& device_path,
if (iter == device_metadata_.end())
return false;
if (info)
*info = iter->second;
return true;
}
......@@ -501,7 +499,7 @@ void VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread(
}
void VolumeMountWatcherWin::HandleDeviceDetachEventOnUIThread(
const string16& device_location) {
const base::string16& device_location) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
MountPointDeviceMetadataMap::const_iterator device_info =
......@@ -519,8 +517,7 @@ void VolumeMountWatcherWin::EjectDevice(
const std::string& device_id,
base::Callback<void(StorageMonitor::EjectStatus)> callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::FilePath device =
chrome::MediaStorageUtil::FindDevicePathById(device_id);
base::FilePath device = MediaStorageUtil::FindDevicePathById(device_id);
if (device.empty()) {
callback.Run(StorageMonitor::EJECT_FAILURE);
return;
......@@ -530,7 +527,8 @@ void VolumeMountWatcherWin::EjectDevice(
return;
}
task_runner_->PostTask(FROM_HERE,
task_runner_->PostTask(
FROM_HERE,
base::Bind(&EjectDeviceInThreadPool, device, callback, task_runner_, 0));
}
......
......@@ -44,7 +44,7 @@ class VolumeMountWatcherWin {
// Gets the information about the device mounted at |device_path|. On success,
// returns true and fills in |info|.
// Can block during startup while device info is still loading.
virtual bool GetDeviceInfo(const base::FilePath& device_path,
bool GetDeviceInfo(const base::FilePath& device_path,
StorageInfo* info) const;
// Processes DEV_BROADCAST_VOLUME messages and triggers a
......@@ -71,7 +71,7 @@ class VolumeMountWatcherWin {
const StorageInfo& info);
// Handles mass storage device detach event on UI thread.
void HandleDeviceDetachEventOnUIThread(const string16& device_location);
void HandleDeviceDetachEventOnUIThread(const base::string16& device_location);
// UI thread delegate to set up adding storage devices.
void AddDevicesOnUIThread(std::vector<base::FilePath> removable_devices);
......@@ -81,7 +81,7 @@ class VolumeMountWatcherWin {
static void RetrieveInfoForDeviceAndAdd(
const base::FilePath& device_path,
const GetDeviceDetailsCallbackType& get_device_details_callback,
base::WeakPtr<chrome::VolumeMountWatcherWin> volume_watcher);
base::WeakPtr<VolumeMountWatcherWin> volume_watcher);
// Mark that a device we started a metadata check for has completed.
virtual void DeviceCheckComplete(const base::FilePath& device_path);
......@@ -100,7 +100,7 @@ class VolumeMountWatcherWin {
// Key: Mass storage device mount point.
// Value: Mass storage device metadata.
typedef std::map<string16, StorageInfo> MountPointDeviceMetadataMap;
typedef std::map<base::string16, StorageInfo> MountPointDeviceMetadataMap;
// Maintain a set of device attribute check calls in-flight. Only accessed
// on the UI thread. This is to try and prevent the same device from
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment