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

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

Issue 15294020: StorageMonitor: Make StorageInfo a real class. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address nits Created 7 years, 7 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) 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 "chrome/browser/storage_monitor/storage_monitor_win.h" 5 #include "chrome/browser/storage_monitor/storage_monitor_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <dbt.h> 8 #include <dbt.h>
9 #include <fileapi.h> 9 #include <fileapi.h>
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 DCHECK(device_info); 79 DCHECK(device_info);
80 80
81 // TODO(gbillock): Move this logic up to StorageMonitor. 81 // TODO(gbillock): Move this logic up to StorageMonitor.
82 // If we already know the StorageInfo for the path, just return it. 82 // If we already know the StorageInfo for the path, just return it.
83 // This will account for portable devices as well. 83 // This will account for portable devices as well.
84 std::vector<StorageInfo> attached_devices = GetAttachedStorage(); 84 std::vector<StorageInfo> attached_devices = GetAttachedStorage();
85 size_t best_parent = attached_devices.size(); 85 size_t best_parent = attached_devices.size();
86 size_t best_length = 0; 86 size_t best_length = 0;
87 for (size_t i = 0; i < attached_devices.size(); i++) { 87 for (size_t i = 0; i < attached_devices.size(); i++) {
88 base::FilePath relative; 88 base::FilePath relative;
89 if (base::FilePath(attached_devices[i].location).AppendRelativePath( 89 if (base::FilePath(attached_devices[i].location()).AppendRelativePath(
90 path, &relative)) { 90 path, &relative)) {
91 // Note: the relative path is longer for shorter shared path between 91 // Note: the relative path is longer for shorter shared path between
92 // the path and the device mount point, so we want the shortest 92 // the path and the device mount point, so we want the shortest
93 // relative path. 93 // relative path.
94 if (relative.value().size() < best_length) { 94 if (relative.value().size() < best_length) {
95 best_parent = i; 95 best_parent = i;
96 best_length = relative.value().size(); 96 best_length = relative.value().size();
97 } 97 }
98 } 98 }
99 } 99 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // portable device as a media gallery. 164 // portable device as a media gallery.
165 return volume_mount_watcher_->GetDeviceInfo(device_path, info); 165 return volume_mount_watcher_->GetDeviceInfo(device_path, info);
166 } 166 }
167 167
168 void StorageMonitorWin::OnDeviceChange(UINT event_type, LPARAM data) { 168 void StorageMonitorWin::OnDeviceChange(UINT event_type, LPARAM data) {
169 volume_mount_watcher_->OnWindowMessage(event_type, data); 169 volume_mount_watcher_->OnWindowMessage(event_type, data);
170 portable_device_watcher_->OnWindowMessage(event_type, data); 170 portable_device_watcher_->OnWindowMessage(event_type, data);
171 } 171 }
172 172
173 } // namespace chrome 173 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698