Chromium Code Reviews| Index: chrome/browser/storage_monitor/storage_monitor_linux.cc |
| =================================================================== |
| --- chrome/browser/storage_monitor/storage_monitor_linux.cc (revision 193326) |
| +++ chrome/browser/storage_monitor/storage_monitor_linux.cc (working copy) |
| @@ -230,14 +230,17 @@ |
| StorageMonitorLinux::StorageMonitorLinux(const base::FilePath& path) |
| : mtab_path_(path), |
| get_device_info_callback_(base::Bind(&GetDeviceInfo)), |
| + use_dummy_media_transfer_protocol_manager_(false), |
| ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { |
| + UseDummyMediaTransferProtocolManagerForTest(); |
| + } |
| } |
| StorageMonitorLinux::~StorageMonitorLinux() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) |
| - device::MediaTransferProtocolManager::Shutdown(); |
|
Greg Billock
2013/04/10 18:27:25
Still need to call this, right? Or does the destru
Lei Zhang
2013/04/11 06:54:04
The dtor does it now.
|
| } |
| void StorageMonitorLinux::Init() { |
| @@ -251,15 +254,14 @@ |
| base::Bind(&StorageMonitorLinux::OnMtabWatcherCreated, |
| weak_ptr_factory_.GetWeakPtr())); |
| - if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { |
| - scoped_refptr<base::MessageLoopProxy> loop_proxy; |
| - loop_proxy = content::BrowserThread::GetMessageLoopProxyForThread( |
| - content::BrowserThread::FILE); |
| - device::MediaTransferProtocolManager::Initialize(loop_proxy); |
| + scoped_refptr<base::MessageLoopProxy> loop_proxy = |
| + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); |
| + media_transfer_protocol_manager_.reset( |
| + device::MediaTransferProtocolManager::Initialize( |
| + loop_proxy, use_dummy_media_transfer_protocol_manager_)); |
| media_transfer_protocol_device_observer_.reset( |
| new MediaTransferProtocolDeviceObserverLinux(receiver())); |
| - } |
| } |
| bool StorageMonitorLinux::GetStorageInfoForPath( |
| @@ -290,11 +292,20 @@ |
| return true; |
| } |
| +device::MediaTransferProtocolManager* |
| +StorageMonitorLinux::media_transfer_protocol_manager() { |
| + return media_transfer_protocol_manager_.get(); |
| +} |
| + |
| void StorageMonitorLinux::SetGetDeviceInfoCallbackForTest( |
| const GetDeviceInfoCallback& get_device_info_callback) { |
| get_device_info_callback_ = get_device_info_callback; |
| } |
| +void StorageMonitorLinux::UseDummyMediaTransferProtocolManagerForTest() { |
| + use_dummy_media_transfer_protocol_manager_ = true; |
| +} |
| + |
| void StorageMonitorLinux::OnMtabWatcherCreated(MtabWatcherLinux* watcher) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| mtab_watcher_.reset(watcher); |