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

Side by Side Diff: components/storage_monitor/test_volume_mount_watcher_win.cc

Issue 120303003: [StorageMonitor] Move gallery name generation to StorageInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 6 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/storage_monitor/test_volume_mount_watcher_win.h" 7 #include "components/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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (path.value() != base::ASCIIToUTF16("N:\\") && 69 if (path.value() != base::ASCIIToUTF16("N:\\") &&
70 path.value() != base::ASCIIToUTF16("C:\\") && 70 path.value() != base::ASCIIToUTF16("C:\\") &&
71 path.value() != GetTempRoot().value()) { 71 path.value() != GetTempRoot().value()) {
72 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM; 72 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM;
73 } 73 }
74 std::string unique_id = 74 std::string unique_id =
75 "\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\"; 75 "\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\";
76 unique_id[11] = device_path.value()[0]; 76 unique_id[11] = device_path.value()[0];
77 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id); 77 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id);
78 base::string16 storage_label = path.Append(L" Drive").LossyDisplayName(); 78 base::string16 storage_label = path.Append(L" Drive").LossyDisplayName();
79 *info = StorageInfo(device_id, base::string16(), path.value(), storage_label, 79 *info = StorageInfo(device_id, path.value(), storage_label, base::string16(),
80 base::string16(), base::string16(), 1000000); 80 base::string16(), 1000000);
81 81
82 return true; 82 return true;
83 } 83 }
84 84
85 } // namespace 85 } // namespace
86 86
87 // TestVolumeMountWatcherWin --------------------------------------------------- 87 // TestVolumeMountWatcherWin ---------------------------------------------------
88 88
89 TestVolumeMountWatcherWin::TestVolumeMountWatcherWin() 89 TestVolumeMountWatcherWin::TestVolumeMountWatcherWin()
90 : attached_devices_fake_(false) {} 90 : attached_devices_fake_(false) {}
91 91
92 TestVolumeMountWatcherWin::~TestVolumeMountWatcherWin() { 92 TestVolumeMountWatcherWin::~TestVolumeMountWatcherWin() {
93 } 93 }
94 94
95 void TestVolumeMountWatcherWin::AddDeviceForTesting( 95 void TestVolumeMountWatcherWin::AddDeviceForTesting(
96 const base::FilePath& device_path, 96 const base::FilePath& device_path,
97 const std::string& device_id, 97 const std::string& device_id,
98 const base::string16& device_name, 98 const base::string16& device_name,
vandebo (ex-Chrome) 2014/03/03 19:58:31 nit: device_label ?
Haojian Wu 2014/03/04 05:00:12 Done.
99 uint64 total_size_in_bytes) { 99 uint64 total_size_in_bytes) {
100 StorageInfo info(device_id, device_name, device_path.value(), 100 StorageInfo info(device_id, device_path.value(), device_name,
101 base::string16(), base::string16(), base::string16(), 101 base::string16(), base::string16(), total_size_in_bytes);
102 total_size_in_bytes);
103 HandleDeviceAttachEventOnUIThread(device_path, info); 102 HandleDeviceAttachEventOnUIThread(device_path, info);
104 } 103 }
105 104
106 void TestVolumeMountWatcherWin::SetAttachedDevicesFake() { 105 void TestVolumeMountWatcherWin::SetAttachedDevicesFake() {
107 attached_devices_fake_ = true; 106 attached_devices_fake_ = true;
108 } 107 }
109 108
110 void TestVolumeMountWatcherWin::FlushWorkerPoolForTesting() { 109 void TestVolumeMountWatcherWin::FlushWorkerPoolForTesting() {
111 device_info_worker_pool_->FlushForTesting(); 110 device_info_worker_pool_->FlushForTesting();
112 } 111 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (attached_devices_fake_) 147 if (attached_devices_fake_)
149 return base::Bind(&FakeGetAttachedDevices); 148 return base::Bind(&FakeGetAttachedDevices);
150 return base::Bind(&FakeGetSingleAttachedDevice); 149 return base::Bind(&FakeGetSingleAttachedDevice);
151 } 150 }
152 151
153 void TestVolumeMountWatcherWin::ShutdownWorkerPool() { 152 void TestVolumeMountWatcherWin::ShutdownWorkerPool() {
154 device_info_worker_pool_->Shutdown(); 153 device_info_worker_pool_->Shutdown();
155 } 154 }
156 155
157 } // namespace storage_monitor 156 } // namespace storage_monitor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698