Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 const std::string& device_path) OVERRIDE; | 53 const std::string& device_path) OVERRIDE; |
| 54 | 54 |
| 55 virtual void MountCompleted(chromeos::MountLibrary::MountEvent event_type, | 55 virtual void MountCompleted(chromeos::MountLibrary::MountEvent event_type, |
| 56 chromeos::MountError error_code, | 56 chromeos::MountError error_code, |
| 57 const chromeos::MountLibrary::MountPointInfo& mount_info) OVERRIDE; | 57 const chromeos::MountLibrary::MountPointInfo& mount_info) OVERRIDE; |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> > | 60 typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> > |
| 61 NotificationMap; | 61 NotificationMap; |
| 62 typedef std::map<std::string, std::string> MountPointMap; | 62 typedef std::map<std::string, std::string> MountPointMap; |
| 63 typedef std::map<std::string, int> ExtensionUsageRegistry; | |
| 64 | |
| 63 typedef struct FileWatcherExtensions { | 65 typedef struct FileWatcherExtensions { |
|
zel
2011/09/12 15:58:42
let's make this a class now since it's not just co
Dmitry Zvorygin
2011/09/14 10:15:49
Done.
| |
| 64 FileWatcherExtensions(const FilePath& path, | 66 FileWatcherExtensions(const FilePath& path, |
| 65 const std::string& extension_id) { | 67 const std::string& extension_id); |
| 66 file_watcher.reset(new base::files::FilePathWatcher()); | 68 |
| 67 virtual_path = path; | |
| 68 extensions.insert(extension_id); | |
| 69 } | |
| 70 ~FileWatcherExtensions() {} | 69 ~FileWatcherExtensions() {} |
| 71 linked_ptr<base::files::FilePathWatcher> file_watcher; | 70 linked_ptr<base::files::FilePathWatcher> file_watcher; |
| 72 FilePath local_path; | 71 FilePath local_path; |
| 73 FilePath virtual_path; | 72 FilePath virtual_path; |
| 74 std::set<std::string> extensions; | 73 |
| 74 void AddExtension(const std::string& extension_id); | |
| 75 | |
| 76 void RemoveExtension(const std::string& extension_id); | |
| 77 | |
| 78 const ExtensionUsageRegistry& GetExtensions() const; | |
| 79 | |
| 80 unsigned int GetRefCount() const; | |
| 81 | |
| 82 private: | |
| 83 ExtensionUsageRegistry extensions; | |
| 84 unsigned int ref_count; | |
| 75 } FileWatcherProcess; | 85 } FileWatcherProcess; |
| 76 typedef std::map<FilePath, FileWatcherExtensions*> WatcherMap; | 86 typedef std::map<FilePath, FileWatcherExtensions*> WatcherMap; |
| 77 | 87 |
| 78 // Helper class for passing through file watch notification events. | 88 // Helper class for passing through file watch notification events. |
| 79 class FileWatcherDelegate : public base::files::FilePathWatcher::Delegate { | 89 class FileWatcherDelegate : public base::files::FilePathWatcher::Delegate { |
| 80 public: | 90 public: |
| 81 explicit FileWatcherDelegate(ExtensionFileBrowserEventRouter* router); | 91 explicit FileWatcherDelegate(ExtensionFileBrowserEventRouter* router); |
| 82 | 92 |
| 83 private: | 93 private: |
| 84 // base::files::FilePathWatcher::Delegate overrides. | 94 // base::files::FilePathWatcher::Delegate overrides. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 105 // Finds first notifications corresponding to the same device. Ensures that | 115 // Finds first notifications corresponding to the same device. Ensures that |
| 106 // we don't pop up multiple notifications for the same device. | 116 // we don't pop up multiple notifications for the same device. |
| 107 NotificationMap::iterator FindNotificationForId(const std::string& path); | 117 NotificationMap::iterator FindNotificationForId(const std::string& path); |
| 108 | 118 |
| 109 // Process file watch notifications. | 119 // Process file watch notifications. |
| 110 void HandleFileWatchNotification(const FilePath& path, | 120 void HandleFileWatchNotification(const FilePath& path, |
| 111 bool got_error); | 121 bool got_error); |
| 112 | 122 |
| 113 // Sends folder change event. | 123 // Sends folder change event. |
| 114 void DispatchFolderChangeEvent(const FilePath& path, bool error, | 124 void DispatchFolderChangeEvent(const FilePath& path, bool error, |
| 115 const std::set<std::string>& extensions); | 125 const ExtensionUsageRegistry& extensions); |
| 116 | 126 |
| 117 // Sends filesystem changed extension message to all renderers. | 127 // Sends filesystem changed extension message to all renderers. |
| 118 void DispatchMountEvent(const chromeos::MountLibrary::Disk* disk, bool added); | 128 void DispatchMountEvent(const chromeos::MountLibrary::Disk* disk, bool added); |
| 119 | 129 |
| 120 void DispatchMountCompletedEvent(chromeos::MountLibrary::MountEvent event, | 130 void DispatchMountCompletedEvent(chromeos::MountLibrary::MountEvent event, |
| 121 chromeos::MountError error_code, | 131 chromeos::MountError error_code, |
| 122 const chromeos::MountLibrary::MountPointInfo& mount_info); | 132 const chromeos::MountLibrary::MountPointInfo& mount_info); |
| 123 | 133 |
| 124 void RemoveBrowserFromVector(const std::string& path); | 134 void RemoveBrowserFromVector(const std::string& path); |
| 125 | 135 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 142 MountPointMap mounted_devices_; | 152 MountPointMap mounted_devices_; |
| 143 NotificationMap notifications_; | 153 NotificationMap notifications_; |
| 144 WatcherMap file_watchers_; | 154 WatcherMap file_watchers_; |
| 145 Profile* profile_; | 155 Profile* profile_; |
| 146 base::Lock lock_; | 156 base::Lock lock_; |
| 147 | 157 |
| 148 DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter); | 158 DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter); |
| 149 }; | 159 }; |
| 150 | 160 |
| 151 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 161 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ |
| OLD | NEW |