| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_SCAN_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_SCAN_MANAGER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_SCAN_MANAGER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_SCAN_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class ExtensionRegistry; | 27 class ExtensionRegistry; |
| 28 } | 28 } |
| 29 | 29 |
| 30 // The MediaScanManager is owned by MediaFileSystemRegistry, which is global. | 30 // The MediaScanManager is owned by MediaFileSystemRegistry, which is global. |
| 31 // This class manages multiple 'virtual' media scans, up to one per extension | 31 // This class manages multiple 'virtual' media scans, up to one per extension |
| 32 // per profile, and also manages the one physical scan backing them. | 32 // per profile, and also manages the one physical scan backing them. |
| 33 // This class lives and is called on the UI thread. | 33 // This class lives and is called on the UI thread. |
| 34 class MediaScanManager : public extensions::ExtensionRegistryObserver { | 34 class MediaScanManager : public extensions::ExtensionRegistryObserver { |
| 35 public: | 35 public: |
| 36 MediaScanManager(); | 36 MediaScanManager(); |
| 37 virtual ~MediaScanManager(); | 37 ~MediaScanManager() override; |
| 38 | 38 |
| 39 // There can only be ever one observer registered per profile. Does not take | 39 // There can only be ever one observer registered per profile. Does not take |
| 40 // ownership of |observer|. An observer must be registered before scanning. | 40 // ownership of |observer|. An observer must be registered before scanning. |
| 41 void AddObserver(Profile* profile, MediaScanManagerObserver* observer); | 41 void AddObserver(Profile* profile, MediaScanManagerObserver* observer); |
| 42 void RemoveObserver(Profile* profile); | 42 void RemoveObserver(Profile* profile); |
| 43 | 43 |
| 44 // Must be called when |profile| is shut down. | 44 // Must be called when |profile| is shut down. |
| 45 void CancelScansForProfile(Profile* profile); | 45 void CancelScansForProfile(Profile* profile); |
| 46 | 46 |
| 47 // The results of the scan are reported to the registered | 47 // The results of the scan are reported to the registered |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 private: | 69 private: |
| 70 struct ScanObservers { | 70 struct ScanObservers { |
| 71 ScanObservers(); | 71 ScanObservers(); |
| 72 ~ScanObservers(); | 72 ~ScanObservers(); |
| 73 MediaScanManagerObserver* observer; | 73 MediaScanManagerObserver* observer; |
| 74 std::set<std::string /*extension id*/> scanning_extensions; | 74 std::set<std::string /*extension id*/> scanning_extensions; |
| 75 }; | 75 }; |
| 76 typedef std::map<Profile*, ScanObservers> ScanObserverMap; | 76 typedef std::map<Profile*, ScanObservers> ScanObserverMap; |
| 77 | 77 |
| 78 // extensions::ExtensionRegistryObserver implementation. | 78 // extensions::ExtensionRegistryObserver implementation. |
| 79 virtual void OnExtensionUnloaded( | 79 void OnExtensionUnloaded( |
| 80 content::BrowserContext* browser_context, | 80 content::BrowserContext* browser_context, |
| 81 const extensions::Extension* extension, | 81 const extensions::Extension* extension, |
| 82 extensions::UnloadedExtensionInfo::Reason reason) override; | 82 extensions::UnloadedExtensionInfo::Reason reason) override; |
| 83 | 83 |
| 84 bool ScanInProgress() const; | 84 bool ScanInProgress() const; |
| 85 | 85 |
| 86 void OnScanCompleted( | 86 void OnScanCompleted( |
| 87 bool success, | 87 bool success, |
| 88 const MediaFolderFinder::MediaFolderFinderResults& found_folders); | 88 const MediaFolderFinder::MediaFolderFinderResults& found_folders); |
| 89 | 89 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 104 ScopedObserver<extensions::ExtensionRegistry, | 104 ScopedObserver<extensions::ExtensionRegistry, |
| 105 extensions::ExtensionRegistryObserver> | 105 extensions::ExtensionRegistryObserver> |
| 106 scoped_extension_registry_observer_; | 106 scoped_extension_registry_observer_; |
| 107 | 107 |
| 108 base::WeakPtrFactory<MediaScanManager> weak_factory_; | 108 base::WeakPtrFactory<MediaScanManager> weak_factory_; |
| 109 | 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(MediaScanManager); | 110 DISALLOW_COPY_AND_ASSIGN(MediaScanManager); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_SCAN_MANAGER_H_ | 113 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_SCAN_MANAGER_H_ |
| OLD | NEW |