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

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: Harden async boundary in WebUI 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 if (ContainsKey(extension_hosts_map_, profile)) 464 if (ContainsKey(extension_hosts_map_, profile))
465 return preferences; 465 return preferences;
466 466
467 // Create an empty entry so the initialization code below only gets called 467 // Create an empty entry so the initialization code below only gets called
468 // once per profile. 468 // once per profile.
469 extension_hosts_map_[profile] = ExtensionHostMap(); 469 extension_hosts_map_[profile] = ExtensionHostMap();
470 470
471 // TODO(gbillock): Move this stanza to MediaGalleriesPreferences init code. 471 // TODO(gbillock): Move this stanza to MediaGalleriesPreferences init code.
472 // StorageMonitor may be NULL in unit tests. 472 // StorageMonitor may be NULL in unit tests.
473 StorageMonitor* monitor = StorageMonitor::GetInstance(); 473 StorageMonitor* monitor = StorageMonitor::GetInstance();
474 if (!monitor) 474 DCHECK(monitor->IsInitialized());
475 return preferences;
476 std::vector<StorageInfo> existing_devices = monitor->GetAttachedStorage(); 475 std::vector<StorageInfo> existing_devices = monitor->GetAttachedStorage();
477 for (size_t i = 0; i < existing_devices.size(); i++) { 476 for (size_t i = 0; i < existing_devices.size(); i++) {
478 if (!StorageInfo::IsMediaDevice(existing_devices[i].device_id())) 477 if (!StorageInfo::IsMediaDevice(existing_devices[i].device_id()))
479 continue; 478 continue;
480 if (!existing_devices[i].name().empty()) { 479 if (!existing_devices[i].name().empty()) {
481 preferences->AddGalleryWithName(existing_devices[i].device_id(), 480 preferences->AddGalleryWithName(existing_devices[i].device_id(),
482 existing_devices[i].name(), 481 existing_devices[i].name(),
483 base::FilePath(), 482 base::FilePath(),
484 false /*not user added*/); 483 false /*not user added*/);
485 } else { 484 } else {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 // previously used. 729 // previously used.
731 PrefChangeRegistrarMap::iterator pref_it = 730 PrefChangeRegistrarMap::iterator pref_it =
732 pref_change_registrar_map_.find(profile); 731 pref_change_registrar_map_.find(profile);
733 DCHECK(pref_it != pref_change_registrar_map_.end()); 732 DCHECK(pref_it != pref_change_registrar_map_.end());
734 delete pref_it->second; 733 delete pref_it->second;
735 pref_change_registrar_map_.erase(pref_it); 734 pref_change_registrar_map_.erase(pref_it);
736 } 735 }
737 } 736 }
738 737
739 } // namespace chrome 738 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698