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

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

Issue 11442047: Media Galleries: Add more tests for media gallery names. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years 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 | Annotate | Revision Log
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_gallery/media_file_system_registry.h" 7 #include "chrome/browser/media_gallery/media_file_system_registry.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 326
327 // This should have been a StringValue, but it's a bit late to change it. 327 // This should have been a StringValue, but it's a bit late to change it.
328 dict_value.SetIntegerWithoutPathExpansion("galleryId", pref_id); 328 dict_value.SetIntegerWithoutPathExpansion("galleryId", pref_id);
329 329
330 // |device_id| can be empty, in which case, just omit it. 330 // |device_id| can be empty, in which case, just omit it.
331 std::string transient_device_id = 331 std::string transient_device_id =
332 GetTransientIdForRemovableDeviceId(device_id); 332 GetTransientIdForRemovableDeviceId(device_id);
333 if (!transient_device_id.empty()) 333 if (!transient_device_id.empty())
334 dict_value.SetStringWithoutPathExpansion("deviceId", transient_device_id); 334 dict_value.SetStringWithoutPathExpansion("deviceId", transient_device_id);
335 335
336 dict_value.SetBooleanWithoutPathExpansion(
337 "isRemovable", MediaStorageUtil::IsRemovableDevice(device_id));
kmadhusu 2012/12/12 17:45:02 I am not sure why we need a new key value pair to
Lei Zhang 2012/12/12 20:15:15 That's a good point. We can discuss this on the bu
338
336 std::string json_string; 339 std::string json_string;
337 base::JSONWriter::Write(&dict_value, &json_string); 340 base::JSONWriter::Write(&dict_value, &json_string);
338 return json_string; 341 return json_string;
339 } 342 }
340 343
341 void OnRendererProcessTerminated(const RenderProcessHost* rph) { 344 void OnRendererProcessTerminated(const RenderProcessHost* rph) {
342 RenderProcessHostRefCount::const_iterator rph_info = rph_refs_.find(rph); 345 RenderProcessHostRefCount::const_iterator rph_info = rph_refs_.find(rph);
343 DCHECK(rph_info != rph_refs_.end()); 346 DCHECK(rph_info != rph_refs_.end());
344 // We're going to remove everything from the set, so we make a copy 347 // We're going to remove everything from the set, so we make a copy
345 // before operating on it. 348 // before operating on it.
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 } 695 }
693 696
694 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) 697 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
695 ScopedMTPDeviceMapEntry* 698 ScopedMTPDeviceMapEntry*
696 MediaFileSystemRegistry::GetOrCreateScopedMTPDeviceMapEntry( 699 MediaFileSystemRegistry::GetOrCreateScopedMTPDeviceMapEntry(
697 const FilePath::StringType& device_location) { 700 const FilePath::StringType& device_location) {
698 MTPDeviceDelegateMap::iterator delegate_it = 701 MTPDeviceDelegateMap::iterator delegate_it =
699 mtp_device_delegate_map_.find(device_location); 702 mtp_device_delegate_map_.find(device_location);
700 if (delegate_it != mtp_device_delegate_map_.end()) 703 if (delegate_it != mtp_device_delegate_map_.end())
701 return delegate_it->second; 704 return delegate_it->second;
702 ScopedMTPDeviceMapEntry* mtp_device_host = new ScopedMTPDeviceMapEntry( 705 ScopedMTPDeviceMapEntry* mtp_device_host =
703 device_location, base::Bind( 706 new ScopedMTPDeviceMapEntry(
704 &MediaFileSystemRegistry::RemoveScopedMTPDeviceMapEntry, 707 device_location,
705 base::Unretained(this), device_location)); 708 base::Bind(
709 &MediaFileSystemRegistry::RemoveScopedMTPDeviceMapEntry,
710 base::Unretained(this),
711 device_location));
706 mtp_device_delegate_map_[device_location] = mtp_device_host; 712 mtp_device_delegate_map_[device_location] = mtp_device_host;
707 return mtp_device_host; 713 return mtp_device_host;
708 } 714 }
709 715
710 void MediaFileSystemRegistry::RemoveScopedMTPDeviceMapEntry( 716 void MediaFileSystemRegistry::RemoveScopedMTPDeviceMapEntry(
711 const FilePath::StringType& device_location) { 717 const FilePath::StringType& device_location) {
712 MTPDeviceDelegateMap::iterator delegate_it = 718 MTPDeviceDelegateMap::iterator delegate_it =
713 mtp_device_delegate_map_.find(device_location); 719 mtp_device_delegate_map_.find(device_location);
714 DCHECK(delegate_it != mtp_device_delegate_map_.end()); 720 DCHECK(delegate_it != mtp_device_delegate_map_.end());
715 mtp_device_delegate_map_.erase(delegate_it); 721 mtp_device_delegate_map_.erase(delegate_it);
(...skipping 15 matching lines...) Expand all
731 737
732 PrefChangeRegistrarMap::iterator pref_it = 738 PrefChangeRegistrarMap::iterator pref_it =
733 pref_change_registrar_map_.find(profile); 739 pref_change_registrar_map_.find(profile);
734 DCHECK(pref_it != pref_change_registrar_map_.end()); 740 DCHECK(pref_it != pref_change_registrar_map_.end());
735 delete pref_it->second; 741 delete pref_it->second;
736 pref_change_registrar_map_.erase(pref_it); 742 pref_change_registrar_map_.erase(pref_it);
737 } 743 }
738 } 744 }
739 745
740 } // namespace chrome 746 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698