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 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 5 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 void ReferenceFromRVH(const content::RenderViewHost* rvh); | 79 void ReferenceFromRVH(const content::RenderViewHost* rvh); |
80 | 80 |
81 private: | 81 private: |
82 class RPHWebContentsObserver : public content::WebContentsObserver { | 82 class RPHWebContentsObserver : public content::WebContentsObserver { |
83 public: | 83 public: |
84 RPHWebContentsObserver(RPHReferenceManager* manager, | 84 RPHWebContentsObserver(RPHReferenceManager* manager, |
85 WebContents* web_contents); | 85 WebContents* web_contents); |
86 | 86 |
87 private: | 87 private: |
88 // content::WebContentsObserver | 88 // content::WebContentsObserver |
89 virtual void WebContentsDestroyed() OVERRIDE; | 89 virtual void WebContentsDestroyed() override; |
90 virtual void NavigationEntryCommitted( | 90 virtual void NavigationEntryCommitted( |
91 const content::LoadCommittedDetails& load_details) OVERRIDE; | 91 const content::LoadCommittedDetails& load_details) override; |
92 | 92 |
93 RPHReferenceManager* manager_; | 93 RPHReferenceManager* manager_; |
94 }; | 94 }; |
95 | 95 |
96 class RPHObserver : public content::RenderProcessHostObserver { | 96 class RPHObserver : public content::RenderProcessHostObserver { |
97 public: | 97 public: |
98 RPHObserver(RPHReferenceManager* manager, RenderProcessHost* host); | 98 RPHObserver(RPHReferenceManager* manager, RenderProcessHost* host); |
99 virtual ~RPHObserver(); | 99 virtual ~RPHObserver(); |
100 | 100 |
101 void AddWebContentsObserver(WebContents* web_contents); | 101 void AddWebContentsObserver(WebContents* web_contents); |
102 void RemoveWebContentsObserver(WebContents* web_contents); | 102 void RemoveWebContentsObserver(WebContents* web_contents); |
103 bool HasWebContentsObservers() { | 103 bool HasWebContentsObservers() { |
104 return observed_web_contentses_.size() > 0; | 104 return observed_web_contentses_.size() > 0; |
105 } | 105 } |
106 | 106 |
107 private: | 107 private: |
108 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) OVERRIDE; | 108 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) override; |
109 | 109 |
110 RPHReferenceManager* manager_; | 110 RPHReferenceManager* manager_; |
111 RenderProcessHost* host_; | 111 RenderProcessHost* host_; |
112 typedef std::map<WebContents*, RPHWebContentsObserver*> WCObserverMap; | 112 typedef std::map<WebContents*, RPHWebContentsObserver*> WCObserverMap; |
113 WCObserverMap observed_web_contentses_; | 113 WCObserverMap observed_web_contentses_; |
114 }; | 114 }; |
115 typedef std::map<const RenderProcessHost*, RPHObserver*> RPHObserverMap; | 115 typedef std::map<const RenderProcessHost*, RPHObserver*> RPHObserverMap; |
116 | 116 |
117 // Handlers for observed events. | 117 // Handlers for observed events. |
118 void OnRenderProcessHostDestroyed(RenderProcessHost* rph); | 118 void OnRenderProcessHostDestroyed(RenderProcessHost* rph); |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 ******************/ | 632 ******************/ |
633 | 633 |
634 class MediaFileSystemRegistry::MediaFileSystemContextImpl | 634 class MediaFileSystemRegistry::MediaFileSystemContextImpl |
635 : public MediaFileSystemContext { | 635 : public MediaFileSystemContext { |
636 public: | 636 public: |
637 MediaFileSystemContextImpl() {} | 637 MediaFileSystemContextImpl() {} |
638 virtual ~MediaFileSystemContextImpl() {} | 638 virtual ~MediaFileSystemContextImpl() {} |
639 | 639 |
640 virtual bool RegisterFileSystem(const std::string& device_id, | 640 virtual bool RegisterFileSystem(const std::string& device_id, |
641 const std::string& fs_name, | 641 const std::string& fs_name, |
642 const base::FilePath& path) OVERRIDE { | 642 const base::FilePath& path) override { |
643 if (StorageInfo::IsMassStorageDevice(device_id)) { | 643 if (StorageInfo::IsMassStorageDevice(device_id)) { |
644 return RegisterFileSystemForMassStorage(device_id, fs_name, path); | 644 return RegisterFileSystemForMassStorage(device_id, fs_name, path); |
645 } else { | 645 } else { |
646 return RegisterFileSystemForMTPDevice(device_id, fs_name, path); | 646 return RegisterFileSystemForMTPDevice(device_id, fs_name, path); |
647 } | 647 } |
648 } | 648 } |
649 | 649 |
650 virtual void RevokeFileSystem(const std::string& fs_name) OVERRIDE { | 650 virtual void RevokeFileSystem(const std::string& fs_name) override { |
651 ImportedMediaGalleryRegistry* imported_registry = | 651 ImportedMediaGalleryRegistry* imported_registry = |
652 ImportedMediaGalleryRegistry::GetInstance(); | 652 ImportedMediaGalleryRegistry::GetInstance(); |
653 if (imported_registry->RevokeImportedFilesystemOnUIThread(fs_name)) | 653 if (imported_registry->RevokeImportedFilesystemOnUIThread(fs_name)) |
654 return; | 654 return; |
655 | 655 |
656 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem(fs_name); | 656 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem(fs_name); |
657 | 657 |
658 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 658 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( |
659 &MTPDeviceMapService::RevokeMTPFileSystem, | 659 &MTPDeviceMapService::RevokeMTPFileSystem, |
660 base::Unretained(MTPDeviceMapService::GetInstance()), | 660 base::Unretained(MTPDeviceMapService::GetInstance()), |
661 fs_name)); | 661 fs_name)); |
662 } | 662 } |
663 | 663 |
664 virtual base::FilePath GetRegisteredPath( | 664 virtual base::FilePath GetRegisteredPath( |
665 const std::string& fs_name) const OVERRIDE { | 665 const std::string& fs_name) const override { |
666 base::FilePath result; | 666 base::FilePath result; |
667 if (!ExternalMountPoints::GetSystemInstance()->GetRegisteredPath(fs_name, | 667 if (!ExternalMountPoints::GetSystemInstance()->GetRegisteredPath(fs_name, |
668 &result)) { | 668 &result)) { |
669 return base::FilePath(); | 669 return base::FilePath(); |
670 } | 670 } |
671 return result; | 671 return result; |
672 } | 672 } |
673 | 673 |
674 private: | 674 private: |
675 // Registers and returns the file system id for the mass storage device | 675 // Registers and returns the file system id for the mass storage device |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 DCHECK_EQ(1U, erase_count); | 840 DCHECK_EQ(1U, erase_count); |
841 if (extension_hosts->second.empty()) { | 841 if (extension_hosts->second.empty()) { |
842 // When a profile has no ExtensionGalleriesHosts left, remove the | 842 // When a profile has no ExtensionGalleriesHosts left, remove the |
843 // matching gallery-change-watcher since it is no longer needed. Leave the | 843 // matching gallery-change-watcher since it is no longer needed. Leave the |
844 // |extension_hosts| entry alone, since it indicates the profile has been | 844 // |extension_hosts| entry alone, since it indicates the profile has been |
845 // previously used. | 845 // previously used. |
846 MediaGalleriesPreferences* preferences = GetPreferences(profile); | 846 MediaGalleriesPreferences* preferences = GetPreferences(profile); |
847 preferences->RemoveGalleryChangeObserver(this); | 847 preferences->RemoveGalleryChangeObserver(this); |
848 } | 848 } |
849 } | 849 } |
OLD | NEW |