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

Unified Diff: chrome/browser/extensions/api/image_writer_private/removable_storage_provider.cc

Issue 266363006: Adds API tests for listRemovableStorageDevices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync. Created 6 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 side-by-side diff with in-line comments
Download patch
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..883bde8771abc99aa3bf8055c7793bf1e0b1ff19
--- /dev/null
+++ b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider.cc
@@ -0,0 +1,46 @@
+
+// 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 "base/lazy_instance.h"
+#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 base::LazyInstance<scoped_refptr<StorageDeviceList> > g_test_device_list;
+
+// 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.Get() != NULL) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(callback, g_test_device_list.Get(), 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.Get() = device_list;
+}
+
+void RemovableStorageProvider::ClearDeviceListForTesting() {
+ g_test_device_list.Get() = NULL;
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698