Index: chrome/browser/extensions/api/image_writer_private/removable_storage_provider.cc |
diff --git a/chrome/browser/extensions/api/image_writer_private/removable_storage_provider.cc b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b6b0d235b4bf5d083b084ec80d76e26d0d4cf193 |
--- /dev/null |
+++ b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider.cc |
@@ -0,0 +1,45 @@ |
+ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/extensions/api/image_writer_private/removable_storage_provider.h" |
+#include "content/public/browser/browser_thread.h" |
+ |
+namespace extensions { |
+ |
+// A device list to be returned when testing. |
+static scoped_refptr<StorageDeviceList> g_test_device_list; |
asargent_no_longer_on_chrome
2014/05/07 21:31:40
Hmm, I'm not sure that scoped_refptr is static ini
Drew Haven
2014/05/08 00:14:34
Shouldn't hurt in any case. Good catch. Sometime
|
+ |
+// TODO(haven): Udev code may be duplicated in the Chrome codebase. |
+// https://code.google.com/p/chromium/issues/detail?id=284898 |
+ |
+void RemovableStorageProvider::GetAllDevices(DeviceListReadyCallback callback) { |
+ if (g_test_device_list != NULL) { |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::FILE, |
+ FROM_HERE, |
+ base::Bind(callback, g_test_device_list, true)); |
+ return; |
+ } |
+ |
+ scoped_refptr<StorageDeviceList> device_list(new StorageDeviceList); |
+ |
+ // We need to do some file i/o to get the device block size |
+ content::BrowserThread::PostTaskAndReplyWithResult( |
+ content::BrowserThread::FILE, |
+ FROM_HERE, |
+ base::Bind(PopulateDeviceList, device_list), |
+ base::Bind(callback, device_list)); |
+} |
+ |
+void RemovableStorageProvider::SetDeviceListForTesting( |
+ scoped_refptr<StorageDeviceList> device_list) { |
+ g_test_device_list = device_list; |
+} |
+ |
+void RemovableStorageProvider::ClearDeviceListForTesting() { |
+ g_test_device_list = NULL; |
+} |
+ |
+} // namespace extensions |