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

Side by Side 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: Cleans up a few minor issues. 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 unified diff | Download patch
OLDNEW
(Empty)
1
2 // Copyright 2013 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5
6 #include "chrome/browser/extensions/api/image_writer_private/removable_storage_p rovider.h"
7 #include "content/public/browser/browser_thread.h"
8
9 namespace extensions {
10
11 // A device list to be returned when testing.
12 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
13
14 // TODO(haven): Udev code may be duplicated in the Chrome codebase.
15 // https://code.google.com/p/chromium/issues/detail?id=284898
16
17 void RemovableStorageProvider::GetAllDevices(DeviceListReadyCallback callback) {
18 if (g_test_device_list != NULL) {
19 content::BrowserThread::PostTask(
20 content::BrowserThread::FILE,
21 FROM_HERE,
22 base::Bind(callback, g_test_device_list, true));
23 return;
24 }
25
26 scoped_refptr<StorageDeviceList> device_list(new StorageDeviceList);
27
28 // We need to do some file i/o to get the device block size
29 content::BrowserThread::PostTaskAndReplyWithResult(
30 content::BrowserThread::FILE,
31 FROM_HERE,
32 base::Bind(PopulateDeviceList, device_list),
33 base::Bind(callback, device_list));
34 }
35
36 void RemovableStorageProvider::SetDeviceListForTesting(
37 scoped_refptr<StorageDeviceList> device_list) {
38 g_test_device_list = device_list;
39 }
40
41 void RemovableStorageProvider::ClearDeviceListForTesting() {
42 g_test_device_list = NULL;
43 }
44
45 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698