| 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 // chrome::MediaStorageUtil implementation. | 5 // chrome::MediaStorageUtil implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/system_monitor/media_storage_util.h" | 7 #include "chrome/browser/system_monitor/media_storage_util.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 262 } |
| 263 | 263 |
| 264 // TODO(kmadhusu) Write unit tests for GetDeviceInfoFromPath(). | 264 // TODO(kmadhusu) Write unit tests for GetDeviceInfoFromPath(). |
| 265 bool MediaStorageUtil::GetDeviceInfoFromPath(const base::FilePath& path, | 265 bool MediaStorageUtil::GetDeviceInfoFromPath(const base::FilePath& path, |
| 266 std::string* device_id, | 266 std::string* device_id, |
| 267 string16* device_name, | 267 string16* device_name, |
| 268 base::FilePath* relative_path) { | 268 base::FilePath* relative_path) { |
| 269 if (!path.IsAbsolute()) | 269 if (!path.IsAbsolute()) |
| 270 return false; | 270 return false; |
| 271 | 271 |
| 272 // TODO(gbillock): Eliminate this in favor of a mock storage notifications. |
| 272 if (g_test_get_device_info_from_path_function) { | 273 if (g_test_get_device_info_from_path_function) { |
| 273 return g_test_get_device_info_from_path_function(path, device_id, | 274 return g_test_get_device_info_from_path_function(path, device_id, |
| 274 device_name, | 275 device_name, |
| 275 relative_path); | 276 relative_path); |
| 276 } | 277 } |
| 277 | 278 |
| 279 // TODO(gbillock): rationalize this sequence into call(s) to |
| 280 // RemovableStorageNotifications and uniform use/loading of |
| 281 // the display name into StorageInfo, or else delegate name |
| 282 // construction as well. |
| 283 |
| 278 bool found_device = false; | 284 bool found_device = false; |
| 279 RemovableStorageNotifications::StorageInfo device_info; | 285 RemovableStorageNotifications::StorageInfo device_info; |
| 280 #if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) | 286 #if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) |
| 281 RemovableStorageNotifications* notifier = | 287 RemovableStorageNotifications* notifier = |
| 282 RemovableStorageNotifications::GetInstance(); | 288 RemovableStorageNotifications::GetInstance(); |
| 283 found_device = notifier->GetDeviceInfoForPath(path, &device_info); | 289 found_device = notifier->GetDeviceInfoForPath(path, &device_info); |
| 284 #endif | 290 #endif |
| 285 | 291 |
| 286 #if defined(OS_LINUX) | 292 #if defined(OS_LINUX) |
| 287 if (!found_device) { | 293 if (!found_device) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 DEVICE_INFO_BUCKET_BOUNDARY); | 389 DEVICE_INFO_BUCKET_BOUNDARY); |
| 384 } | 390 } |
| 385 | 391 |
| 386 // static | 392 // static |
| 387 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( | 393 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( |
| 388 GetDeviceInfoFromPathFunction function) { | 394 GetDeviceInfoFromPathFunction function) { |
| 389 g_test_get_device_info_from_path_function = function; | 395 g_test_get_device_info_from_path_function = function; |
| 390 } | 396 } |
| 391 | 397 |
| 392 } // namespace chrome | 398 } // namespace chrome |
| OLD | NEW |