OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/storage_monitor/media_transfer_protocol_device_observer _linux.h" | 5 #include "chrome/browser/storage_monitor/media_transfer_protocol_device_observer _linux.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 } // namespace | 121 } // namespace |
122 | 122 |
123 MediaTransferProtocolDeviceObserverLinux:: | 123 MediaTransferProtocolDeviceObserverLinux:: |
124 MediaTransferProtocolDeviceObserverLinux() | 124 MediaTransferProtocolDeviceObserverLinux() |
125 : get_storage_info_func_(&GetStorageInfo) { | 125 : get_storage_info_func_(&GetStorageInfo) { |
126 DCHECK(!g_mtp_device_observer); | 126 DCHECK(!g_mtp_device_observer); |
127 g_mtp_device_observer = this; | 127 g_mtp_device_observer = this; |
128 | 128 |
129 device::MediaTransferProtocolManager* mtp_manager = | 129 device::MediaTransferProtocolManager* mtp_manager = |
130 device::MediaTransferProtocolManager::GetInstance(); | 130 device::MediaTransferProtocolManager::GetInstance(); |
131 mtp_manager->AddObserver(this); | 131 // May be null in unit tests. |
132 EnumerateStorages(); | 132 if (mtp_manager) { |
Lei Zhang
2013/02/28 02:14:43
As is, |mtp_manager| is always true here, because
Greg Billock
2013/02/28 22:35:37
That sounds like a great option. I'll add that to
| |
133 mtp_manager->AddObserver(this); | |
134 EnumerateStorages(); | |
135 } | |
133 } | 136 } |
134 | 137 |
135 // This constructor is only used by unit tests. | 138 // This constructor is only used by unit tests. |
136 MediaTransferProtocolDeviceObserverLinux:: | 139 MediaTransferProtocolDeviceObserverLinux:: |
137 MediaTransferProtocolDeviceObserverLinux( | 140 MediaTransferProtocolDeviceObserverLinux( |
138 GetStorageInfoFunc get_storage_info_func) | 141 GetStorageInfoFunc get_storage_info_func) |
139 : get_storage_info_func_(get_storage_info_func), | 142 : get_storage_info_func_(get_storage_info_func), |
140 notifications_(NULL) { | 143 notifications_(NULL) { |
141 // In unit tests, we don't have a media transfer protocol manager. | 144 // In unit tests, we don't have a media transfer protocol manager. |
142 DCHECK(!device::MediaTransferProtocolManager::GetInstance()); | 145 DCHECK(!device::MediaTransferProtocolManager::GetInstance()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 device::MediaTransferProtocolManager* mtp_manager = | 235 device::MediaTransferProtocolManager* mtp_manager = |
233 device::MediaTransferProtocolManager::GetInstance(); | 236 device::MediaTransferProtocolManager::GetInstance(); |
234 StorageList storages = mtp_manager->GetStorages(); | 237 StorageList storages = mtp_manager->GetStorages(); |
235 for (StorageList::const_iterator storage_iter = storages.begin(); | 238 for (StorageList::const_iterator storage_iter = storages.begin(); |
236 storage_iter != storages.end(); ++storage_iter) { | 239 storage_iter != storages.end(); ++storage_iter) { |
237 StorageChanged(true, *storage_iter); | 240 StorageChanged(true, *storage_iter); |
238 } | 241 } |
239 } | 242 } |
240 | 243 |
241 } // namespace chrome | 244 } // namespace chrome |
OLD | NEW |