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

Side by Side Diff: chrome/browser/extensions/api/image_writer_private/removable_storage_provider.cc

Issue 291333006: Adds removable-drive listing for OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removes unnecessary changes. Created 6 years, 6 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
1 1
2 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 #include "base/lazy_instance.h" 6 #include "base/lazy_instance.h"
7 #include "base/message_loop/message_loop.h"
7 #include "chrome/browser/extensions/api/image_writer_private/removable_storage_p rovider.h" 8 #include "chrome/browser/extensions/api/image_writer_private/removable_storage_p rovider.h"
8 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
9 10
10 namespace extensions { 11 namespace extensions {
11 12
12 // A device list to be returned when testing. 13 // A device list to be returned when testing.
13 static base::LazyInstance<scoped_refptr<StorageDeviceList> > g_test_device_list; 14 static base::LazyInstance<scoped_refptr<StorageDeviceList> > g_test_device_list;
14 15
15 // TODO(haven): Udev code may be duplicated in the Chrome codebase. 16 // TODO(haven): Udev code may be duplicated in the Chrome codebase.
16 // https://code.google.com/p/chromium/issues/detail?id=284898 17 // https://code.google.com/p/chromium/issues/detail?id=284898
17 18
18 void RemovableStorageProvider::GetAllDevices(DeviceListReadyCallback callback) { 19 void RemovableStorageProvider::GetAllDevices(
20 const DeviceListReadyCallback& callback) {
19 if (g_test_device_list.Get() != NULL) { 21 if (g_test_device_list.Get() != NULL) {
20 content::BrowserThread::PostTask( 22 base::MessageLoop::current()->PostTask(
21 content::BrowserThread::FILE, 23 FROM_HERE, base::Bind(callback, g_test_device_list.Get(), true));
22 FROM_HERE,
23 base::Bind(callback, g_test_device_list.Get(), true));
24 return; 24 return;
25 } 25 }
26 26
27 scoped_refptr<StorageDeviceList> device_list(new StorageDeviceList); 27 GetAllDevicesImpl(callback);
28
29 // We need to do some file i/o to get the device block size
30 content::BrowserThread::PostTaskAndReplyWithResult(
31 content::BrowserThread::FILE,
32 FROM_HERE,
33 base::Bind(PopulateDeviceList, device_list),
34 base::Bind(callback, device_list));
35 } 28 }
36 29
37 void RemovableStorageProvider::SetDeviceListForTesting( 30 void RemovableStorageProvider::SetDeviceListForTesting(
38 scoped_refptr<StorageDeviceList> device_list) { 31 scoped_refptr<StorageDeviceList> device_list) {
39 g_test_device_list.Get() = device_list; 32 g_test_device_list.Get() = device_list;
40 } 33 }
41 34
42 void RemovableStorageProvider::ClearDeviceListForTesting() { 35 void RemovableStorageProvider::ClearDeviceListForTesting() {
43 g_test_device_list.Get() = NULL; 36 g_test_device_list.Get() = NULL;
44 } 37 }
45 38
46 } // namespace extensions 39 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698