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 // 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 } | 141 } |
142 default: { | 142 default: { |
143 NOTREACHED(); | 143 NOTREACHED(); |
144 break; | 144 break; |
145 } | 145 } |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 void OnRendererProcessTerminated(const RenderProcessHost* rph) { | 149 void OnRendererProcessTerminated(const RenderProcessHost* rph) { |
150 RPHRefCount::iterator rph_info = refs_.find(rph); | 150 RPHRefCount::iterator rph_info = refs_.find(rph); |
151 // Will this crash if the RPH is navigated to a page on the same host | |
vandebo (ex-Chrome)
2014/01/06 18:45:03
This this a debug comment?
Greg Billock
2014/01/07 16:50:55
I think this is a real hole. Filling.
| |
152 // (triggering OWCDON()) and then the tab crashes? | |
151 DCHECK(rph_info != refs_.end()); | 153 DCHECK(rph_info != refs_.end()); |
152 delete rph_info->second; | 154 delete rph_info->second; |
153 refs_.erase(rph_info); | 155 refs_.erase(rph_info); |
154 if (refs_.empty()) | 156 if (refs_.empty()) |
155 no_references_callback_.Run(); | 157 no_references_callback_.Run(); |
156 } | 158 } |
157 | 159 |
158 void OnWebContentsDestroyedOrNavigated(const WebContents* contents) { | 160 void OnWebContentsDestroyedOrNavigated(const WebContents* contents) { |
159 RenderProcessHost* rph = contents->GetRenderProcessHost(); | 161 RenderProcessHost* rph = contents->GetRenderProcessHost(); |
160 RPHRefCount::iterator rph_info = refs_.find(rph); | 162 RPHRefCount::iterator rph_info = refs_.find(rph); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 | 282 |
281 private: | 283 private: |
282 typedef std::map<MediaGalleryPrefId, MediaFileSystemInfo> PrefIdFsInfoMap; | 284 typedef std::map<MediaGalleryPrefId, MediaFileSystemInfo> PrefIdFsInfoMap; |
283 | 285 |
284 // Private destructor and friend declaration for ref counted implementation. | 286 // Private destructor and friend declaration for ref counted implementation. |
285 friend class base::RefCountedThreadSafe<ExtensionGalleriesHost>; | 287 friend class base::RefCountedThreadSafe<ExtensionGalleriesHost>; |
286 | 288 |
287 virtual ~ExtensionGalleriesHost() { | 289 virtual ~ExtensionGalleriesHost() { |
288 DCHECK(rph_refs_.empty()); | 290 DCHECK(rph_refs_.empty()); |
289 DCHECK(pref_id_map_.empty()); | 291 DCHECK(pref_id_map_.empty()); |
290 | |
291 } | 292 } |
292 | 293 |
294 // It appears there's a shutdown race in some browser tests. If the RPHs shut | |
295 // down first, there may still be Filter... calls pending which will then | |
296 // invoke this method interleaved in the destruction callback sequence and | |
297 // re-populate pref_id_map_. | |
vandebo (ex-Chrome)
2014/01/06 18:45:03
So if rph_refs_ is empty, we know that we lost the
Greg Billock
2014/01/07 16:50:55
I also looked, and I agree this is a fine check. A
| |
293 void GetMediaFileSystemsForAttachedDevices( | 298 void GetMediaFileSystemsForAttachedDevices( |
294 const MediaStorageUtil::DeviceIdSet* attached_devices, | 299 const MediaStorageUtil::DeviceIdSet* attached_devices, |
295 const MediaGalleryPrefIdSet& galleries, | 300 const MediaGalleryPrefIdSet& galleries, |
296 const MediaGalleriesPrefInfoMap& galleries_info, | 301 const MediaGalleriesPrefInfoMap& galleries_info, |
297 const MediaFileSystemsCallback& callback) { | 302 const MediaFileSystemsCallback& callback) { |
298 std::vector<MediaFileSystemInfo> result; | 303 std::vector<MediaFileSystemInfo> result; |
299 MediaGalleryPrefIdSet new_galleries; | 304 MediaGalleryPrefIdSet new_galleries; |
300 for (std::set<MediaGalleryPrefId>::const_iterator pref_id_it = | 305 for (std::set<MediaGalleryPrefId>::const_iterator pref_id_it = |
301 galleries.begin(); | 306 galleries.begin(); |
302 pref_id_it != galleries.end(); | 307 pref_id_it != galleries.end(); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 virtual std::string RegisterFileSystem( | 508 virtual std::string RegisterFileSystem( |
504 const std::string& device_id, const base::FilePath& path) OVERRIDE { | 509 const std::string& device_id, const base::FilePath& path) OVERRIDE { |
505 if (StorageInfo::IsMassStorageDevice(device_id)) { | 510 if (StorageInfo::IsMassStorageDevice(device_id)) { |
506 return RegisterFileSystemForMassStorage(device_id, path); | 511 return RegisterFileSystemForMassStorage(device_id, path); |
507 } else { | 512 } else { |
508 return RegisterFileSystemForMTPDevice(device_id, path); | 513 return RegisterFileSystemForMTPDevice(device_id, path); |
509 } | 514 } |
510 } | 515 } |
511 | 516 |
512 virtual void RevokeFileSystem(const std::string& fsid) OVERRIDE { | 517 virtual void RevokeFileSystem(const std::string& fsid) OVERRIDE { |
518 // Does this need to do something about non-imported, non-MTP filesystems? | |
519 // It gets called during RPH shutdown, and may leave around local drive | |
520 // FS trash. | |
vandebo (ex-Chrome)
2014/01/06 18:45:03
What kind of trash do you mean?
Greg Billock
2014/01/07 16:50:55
Not exactly sure. Is there some cleanup that needs
| |
513 ImportedMediaGalleryRegistry* imported_registry = | 521 ImportedMediaGalleryRegistry* imported_registry = |
514 ImportedMediaGalleryRegistry::GetInstance(); | 522 ImportedMediaGalleryRegistry::GetInstance(); |
515 if (imported_registry->RevokeImportedFilesystemOnUIThread(fsid)) | 523 if (imported_registry->RevokeImportedFilesystemOnUIThread(fsid)) |
516 return; | 524 return; |
517 | 525 |
518 IsolatedContext::GetInstance()->RevokeFileSystem(fsid); | 526 IsolatedContext::GetInstance()->RevokeFileSystem(fsid); |
519 | 527 |
520 content::BrowserThread::PostTask( | 528 content::BrowserThread::PostTask( |
521 content::BrowserThread::IO, FROM_HERE, base::Bind( | 529 content::BrowserThread::IO, FROM_HERE, base::Bind( |
522 &MTPDeviceMapService::RevokeMTPFileSystem, | 530 &MTPDeviceMapService::RevokeMTPFileSystem, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 DCHECK_EQ(1U, erase_count); | 674 DCHECK_EQ(1U, erase_count); |
667 if (extension_hosts->second.empty()) { | 675 if (extension_hosts->second.empty()) { |
668 // When a profile has no ExtensionGalleriesHosts left, remove the | 676 // When a profile has no ExtensionGalleriesHosts left, remove the |
669 // matching gallery-change-watcher since it is no longer needed. Leave the | 677 // matching gallery-change-watcher since it is no longer needed. Leave the |
670 // |extension_hosts| entry alone, since it indicates the profile has been | 678 // |extension_hosts| entry alone, since it indicates the profile has been |
671 // previously used. | 679 // previously used. |
672 MediaGalleriesPreferences* preferences = GetPreferences(profile); | 680 MediaGalleriesPreferences* preferences = GetPreferences(profile); |
673 preferences->RemoveGalleryChangeObserver(this); | 681 preferences->RemoveGalleryChangeObserver(this); |
674 } | 682 } |
675 } | 683 } |
OLD | NEW |