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

Side by Side Diff: chrome/browser/media_galleries/media_file_system_registry.cc

Issue 14556015: [Media Galleries] Lazily initialize the storage monitor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix merge Created 7 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 // 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 // MediaFileSystemRegistry implementation. 5 // MediaFileSystemRegistry implementation.
6 6
7 #include "chrome/browser/media_galleries/media_file_system_registry.h" 7 #include "chrome/browser/media_galleries/media_file_system_registry.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 MediaGalleriesPreferencesFactory::GetForProfile(profile); 458 MediaGalleriesPreferencesFactory::GetForProfile(profile);
459 if (ContainsKey(extension_hosts_map_, profile)) 459 if (ContainsKey(extension_hosts_map_, profile))
460 return preferences; 460 return preferences;
461 461
462 // Create an empty entry so the initialization code below only gets called 462 // Create an empty entry so the initialization code below only gets called
463 // once per profile. 463 // once per profile.
464 extension_hosts_map_[profile] = ExtensionHostMap(); 464 extension_hosts_map_[profile] = ExtensionHostMap();
465 465
466 // TODO(gbillock): Move this stanza to MediaGalleriesPreferences init code. 466 // TODO(gbillock): Move this stanza to MediaGalleriesPreferences init code.
467 StorageMonitor* monitor = StorageMonitor::GetInstance(); 467 StorageMonitor* monitor = StorageMonitor::GetInstance();
468 DCHECK(monitor->IsInitialized());
468 std::vector<StorageInfo> existing_devices = monitor->GetAttachedStorage(); 469 std::vector<StorageInfo> existing_devices = monitor->GetAttachedStorage();
469 for (size_t i = 0; i < existing_devices.size(); i++) { 470 for (size_t i = 0; i < existing_devices.size(); i++) {
470 if (!StorageInfo::IsMediaDevice(existing_devices[i].device_id())) 471 if (!StorageInfo::IsMediaDevice(existing_devices[i].device_id()))
471 continue; 472 continue;
472 if (!existing_devices[i].name().empty()) { 473 if (!existing_devices[i].name().empty()) {
473 preferences->AddGalleryWithName(existing_devices[i].device_id(), 474 preferences->AddGalleryWithName(existing_devices[i].device_id(),
474 existing_devices[i].name(), 475 existing_devices[i].name(),
475 base::FilePath(), 476 base::FilePath(),
476 false /*not user added*/); 477 false /*not user added*/);
477 } else { 478 } else {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 // previously used. 706 // previously used.
706 PrefChangeRegistrarMap::iterator pref_it = 707 PrefChangeRegistrarMap::iterator pref_it =
707 pref_change_registrar_map_.find(profile); 708 pref_change_registrar_map_.find(profile);
708 DCHECK(pref_it != pref_change_registrar_map_.end()); 709 DCHECK(pref_it != pref_change_registrar_map_.end());
709 delete pref_it->second; 710 delete pref_it->second;
710 pref_change_registrar_map_.erase(pref_it); 711 pref_change_registrar_map_.erase(pref_it);
711 } 712 }
712 } 713 }
713 714
714 } // namespace chrome 715 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698