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

Side by Side Diff: chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc

Issue 12334096: Regularize ownerships and lifecycle for storage monitor platform classes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comment name Created 7 years, 9 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 // 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/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } // namespace 120 } // namespace
121 121
122 MediaTransferProtocolDeviceObserverLinux:: 122 MediaTransferProtocolDeviceObserverLinux::
123 MediaTransferProtocolDeviceObserverLinux() 123 MediaTransferProtocolDeviceObserverLinux()
124 : get_storage_info_func_(&GetStorageInfo) { 124 : get_storage_info_func_(&GetStorageInfo) {
125 DCHECK(!g_mtp_device_observer); 125 DCHECK(!g_mtp_device_observer);
126 g_mtp_device_observer = this; 126 g_mtp_device_observer = this;
127 127
128 device::MediaTransferProtocolManager* mtp_manager = 128 device::MediaTransferProtocolManager* mtp_manager =
129 device::MediaTransferProtocolManager::GetInstance(); 129 device::MediaTransferProtocolManager::GetInstance();
130 DCHECK(mtp_manager);
130 mtp_manager->AddObserver(this); 131 mtp_manager->AddObserver(this);
131 EnumerateStorages(); 132 EnumerateStorages();
132 } 133 }
133 134
134 // This constructor is only used by unit tests. 135 // This constructor is only used by unit tests.
135 MediaTransferProtocolDeviceObserverLinux:: 136 MediaTransferProtocolDeviceObserverLinux::
136 MediaTransferProtocolDeviceObserverLinux( 137 MediaTransferProtocolDeviceObserverLinux(
137 GetStorageInfoFunc get_storage_info_func) 138 GetStorageInfoFunc get_storage_info_func)
138 : get_storage_info_func_(get_storage_info_func), 139 : get_storage_info_func_(get_storage_info_func),
139 notifications_(NULL) { 140 notifications_(NULL) {
140 // In unit tests, we don't have a media transfer protocol manager.
141 DCHECK(!device::MediaTransferProtocolManager::GetInstance());
142 DCHECK(!g_mtp_device_observer); 141 DCHECK(!g_mtp_device_observer);
143 g_mtp_device_observer = this; 142 g_mtp_device_observer = this;
144 } 143 }
145 144
146 MediaTransferProtocolDeviceObserverLinux:: 145 MediaTransferProtocolDeviceObserverLinux::
147 ~MediaTransferProtocolDeviceObserverLinux() { 146 ~MediaTransferProtocolDeviceObserverLinux() {
148 DCHECK_EQ(this, g_mtp_device_observer); 147 DCHECK_EQ(this, g_mtp_device_observer);
149 g_mtp_device_observer = NULL; 148 g_mtp_device_observer = NULL;
150 149
151 device::MediaTransferProtocolManager* mtp_manager = 150 device::MediaTransferProtocolManager* mtp_manager =
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 device::MediaTransferProtocolManager* mtp_manager = 230 device::MediaTransferProtocolManager* mtp_manager =
232 device::MediaTransferProtocolManager::GetInstance(); 231 device::MediaTransferProtocolManager::GetInstance();
233 StorageList storages = mtp_manager->GetStorages(); 232 StorageList storages = mtp_manager->GetStorages();
234 for (StorageList::const_iterator storage_iter = storages.begin(); 233 for (StorageList::const_iterator storage_iter = storages.begin();
235 storage_iter != storages.end(); ++storage_iter) { 234 storage_iter != storages.end(); ++storage_iter) {
236 StorageChanged(true, *storage_iter); 235 StorageChanged(true, *storage_iter);
237 } 236 }
238 } 237 }
239 238
240 } // namespace chrome 239 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/chrome_browser_main_chromeos.cc ('k') | chrome/browser/storage_monitor/storage_monitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698