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

Side by Side Diff: chrome/browser/storage_monitor/test_volume_mount_watcher_win.cc

Issue 16056002: Cleanup Various bits of Windows StorageMonitor classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 // TestVolumeMountWatcherWin implementation. 5 // TestVolumeMountWatcherWin implementation.
6 6
7 #include "chrome/browser/storage_monitor/test_volume_mount_watcher_win.h" 7 #include "chrome/browser/storage_monitor/test_volume_mount_watcher_win.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 StorageInfo::Type type = StorageInfo::FIXED_MASS_STORAGE; 52 StorageInfo::Type type = StorageInfo::FIXED_MASS_STORAGE;
53 if (path.value() != ASCIIToUTF16("N:\\") && 53 if (path.value() != ASCIIToUTF16("N:\\") &&
54 path.value() != ASCIIToUTF16("C:\\")) { 54 path.value() != ASCIIToUTF16("C:\\")) {
55 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM; 55 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM;
56 } 56 }
57 std::string unique_id = 57 std::string unique_id =
58 "\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\"; 58 "\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\";
59 unique_id[11] = device_path.value()[0]; 59 unique_id[11] = device_path.value()[0];
60 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id); 60 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id);
61 string16 storage_label = path.Append(L" Drive").LossyDisplayName(); 61 base::string16 storage_label = path.Append(L" Drive").LossyDisplayName();
62 *info = StorageInfo(device_id, string16(), path.value(), storage_label, 62 *info = StorageInfo(device_id, base::string16(), path.value(), storage_label,
63 string16(), string16(), 1000000); 63 base::string16(), base::string16(), 1000000);
64 64
65 return true; 65 return true;
66 } 66 }
67 67
68 } // namespace 68 } // namespace
69 69
70 // TestVolumeMountWatcherWin --------------------------------------------------- 70 // TestVolumeMountWatcherWin ---------------------------------------------------
71 71
72 TestVolumeMountWatcherWin::TestVolumeMountWatcherWin() 72 TestVolumeMountWatcherWin::TestVolumeMountWatcherWin()
73 : attached_devices_fake_(false) {} 73 : attached_devices_fake_(false) {}
74 74
75 TestVolumeMountWatcherWin::~TestVolumeMountWatcherWin() { 75 TestVolumeMountWatcherWin::~TestVolumeMountWatcherWin() {
76 } 76 }
77 77
78 void TestVolumeMountWatcherWin::AddDeviceForTesting( 78 void TestVolumeMountWatcherWin::AddDeviceForTesting(
79 const base::FilePath& device_path, 79 const base::FilePath& device_path,
80 const std::string& device_id, 80 const std::string& device_id,
81 const string16& device_name, 81 const base::string16& device_name,
82 uint64 total_size_in_bytes) { 82 uint64 total_size_in_bytes) {
83 StorageInfo info(device_id, device_name, device_path.value(), 83 StorageInfo info(device_id, device_name, device_path.value(),
84 string16(), string16(), string16(), total_size_in_bytes); 84 base::string16(), base::string16(), base::string16(),
85 total_size_in_bytes);
85 HandleDeviceAttachEventOnUIThread(device_path, info); 86 HandleDeviceAttachEventOnUIThread(device_path, info);
86 } 87 }
87 88
88 void TestVolumeMountWatcherWin::SetAttachedDevicesFake() { 89 void TestVolumeMountWatcherWin::SetAttachedDevicesFake() {
89 attached_devices_fake_ = true; 90 attached_devices_fake_ = true;
90 } 91 }
91 92
92 void TestVolumeMountWatcherWin::FlushWorkerPoolForTesting() { 93 void TestVolumeMountWatcherWin::FlushWorkerPoolForTesting() {
93 device_info_worker_pool_->FlushForTesting(); 94 device_info_worker_pool_->FlushForTesting();
94 } 95 }
95 96
96 void TestVolumeMountWatcherWin::DeviceCheckComplete( 97 void TestVolumeMountWatcherWin::DeviceCheckComplete(
97 const base::FilePath& device_path) { 98 const base::FilePath& device_path) {
98 devices_checked_.push_back(device_path); 99 devices_checked_.push_back(device_path);
99 if (device_check_complete_event_.get()) 100 if (device_check_complete_event_.get())
100 device_check_complete_event_->Wait(); 101 device_check_complete_event_->Wait();
101 VolumeMountWatcherWin::DeviceCheckComplete(device_path); 102 VolumeMountWatcherWin::DeviceCheckComplete(device_path);
102 } 103 }
103 104
104 void TestVolumeMountWatcherWin::BlockDeviceCheckForTesting() { 105 void TestVolumeMountWatcherWin::BlockDeviceCheckForTesting() {
105 device_check_complete_event_.reset(new base::WaitableEvent(false, false)); 106 device_check_complete_event_.reset(new base::WaitableEvent(false, false));
106 devices_checked_.clear(); 107 devices_checked_.clear();
107 } 108 }
108 109
109 void TestVolumeMountWatcherWin::ReleaseDeviceCheck() { 110 void TestVolumeMountWatcherWin::ReleaseDeviceCheck() {
110 device_check_complete_event_->Signal(); 111 device_check_complete_event_->Signal();
111 } 112 }
112 113
114 // static
113 bool TestVolumeMountWatcherWin::GetDeviceRemovable( 115 bool TestVolumeMountWatcherWin::GetDeviceRemovable(
114 const base::FilePath& device_path, 116 const base::FilePath& device_path,
115 bool* removable) const { 117 bool* removable) {
116 StorageInfo info; 118 StorageInfo info;
117 bool success = GetMassStorageDeviceDetails(device_path, &info); 119 bool success = GetMassStorageDeviceDetails(device_path, &info);
118 *removable = StorageInfo::IsRemovableDevice(info.device_id()); 120 *removable = StorageInfo::IsRemovableDevice(info.device_id());
119 return success; 121 return success;
120 } 122 }
121 123
122 VolumeMountWatcherWin::GetDeviceDetailsCallbackType 124 VolumeMountWatcherWin::GetDeviceDetailsCallbackType
123 TestVolumeMountWatcherWin::GetDeviceDetailsCallback() const { 125 TestVolumeMountWatcherWin::GetDeviceDetailsCallback() const {
124 return base::Bind(&GetMassStorageDeviceDetails); 126 return base::Bind(&GetMassStorageDeviceDetails);
125 } 127 }
126 128
127 VolumeMountWatcherWin::GetAttachedDevicesCallbackType 129 VolumeMountWatcherWin::GetAttachedDevicesCallbackType
128 TestVolumeMountWatcherWin::GetAttachedDevicesCallback() const { 130 TestVolumeMountWatcherWin::GetAttachedDevicesCallback() const {
129 if (attached_devices_fake_) 131 if (attached_devices_fake_)
130 return base::Bind(&FakeGetAttachedDevices); 132 return base::Bind(&FakeGetAttachedDevices);
131
132 return base::Bind(&FakeGetSingleAttachedDevice); 133 return base::Bind(&FakeGetSingleAttachedDevice);
133 } 134 }
134 135
135 void TestVolumeMountWatcherWin::ShutdownWorkerPool() { 136 void TestVolumeMountWatcherWin::ShutdownWorkerPool() {
136 device_info_worker_pool_->Shutdown(); 137 device_info_worker_pool_->Shutdown();
137 } 138 }
138 139
139 } // namespace test 140 } // namespace test
140 } // namespace chrome 141 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698