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 #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 | 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 Profile; | 27 class Profile; |
28 | 28 |
29 namespace drive { | 29 namespace drive { |
30 class DriveEntryProto; | 30 class DriveEntryProto; |
31 class DriveFileSystemInterface; | 31 class DriveFileSystemInterface; |
32 } | 32 } |
33 | 33 |
34 // Monitors changes in disk mounts, network connection state and preferences | 34 // Monitors changes in disk mounts, network connection state and preferences |
35 // affecting File Manager. Dispatches appropriate File Browser events. | 35 // affecting File Manager. Dispatches appropriate File Browser events. |
36 class FileBrowserEventRouter | 36 class FileBrowserEventRouter |
37 : public base::RefCountedThreadSafe<FileBrowserEventRouter>, | 37 : public chromeos::disks::DiskMountManager::Observer, |
38 public chromeos::disks::DiskMountManager::Observer, | |
39 public chromeos::ConnectivityStateHelperObserver, | 38 public chromeos::ConnectivityStateHelperObserver, |
40 public chromeos::SystemKeyEventListener::ModifiersObserver, | 39 public chromeos::SystemKeyEventListener::ModifiersObserver, |
41 public drive::DriveFileSystemObserver, | 40 public drive::DriveFileSystemObserver, |
42 public google_apis::DriveServiceObserver { | 41 public google_apis::DriveServiceObserver { |
43 public: | 42 public: |
43 virtual ~FileBrowserEventRouter(); | |
hashimoto
2013/04/08 04:49:38
nit: How about moving this dtor to after SuspendSt
satorux1
2013/04/08 05:03:37
Done.
| |
44 | |
44 // Interface that should keep track of the system state in regards to system | 45 // Interface that should keep track of the system state in regards to system |
45 // suspend and resume events. | 46 // suspend and resume events. |
46 // When the |IsResuming()| returns true, it should be able to check if a | 47 // When the |IsResuming()| returns true, it should be able to check if a |
47 // removable device was present before the was system suspended. | 48 // removable device was present before the was system suspended. |
48 class SuspendStateDelegate { | 49 class SuspendStateDelegate { |
49 public: | 50 public: |
50 virtual ~SuspendStateDelegate() {} | 51 virtual ~SuspendStateDelegate() {} |
51 | 52 |
52 // Returns true if the system has recently woken up. | 53 // Returns true if the system has recently woken up. |
53 virtual bool SystemIsResuming() const = 0; | 54 virtual bool SystemIsResuming() const = 0; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 const base::FilePath& directory_path) OVERRIDE; | 104 const base::FilePath& directory_path) OVERRIDE; |
104 virtual void OnResourceListFetched(int num_accumulated_entries) OVERRIDE; | 105 virtual void OnResourceListFetched(int num_accumulated_entries) OVERRIDE; |
105 virtual void OnFileSystemMounted() OVERRIDE; | 106 virtual void OnFileSystemMounted() OVERRIDE; |
106 virtual void OnFileSystemBeingUnmounted() OVERRIDE; | 107 virtual void OnFileSystemBeingUnmounted() OVERRIDE; |
107 | 108 |
108 // chromeos::SystemKeyEventListener::ModifiersObserver overrides. | 109 // chromeos::SystemKeyEventListener::ModifiersObserver overrides. |
109 virtual void OnModifiersChange(int pressed_modifiers) OVERRIDE; | 110 virtual void OnModifiersChange(int pressed_modifiers) OVERRIDE; |
110 | 111 |
111 private: | 112 private: |
112 friend class FileBrowserPrivateAPI; | 113 friend class FileBrowserPrivateAPI; |
113 friend class base::RefCountedThreadSafe<FileBrowserEventRouter>; | |
114 | 114 |
115 typedef std::map<std::string, int> ExtensionUsageRegistry; | 115 typedef std::map<std::string, int> ExtensionUsageRegistry; |
116 | 116 |
117 class FileWatcherExtensions { | 117 class FileWatcherExtensions { |
118 public: | 118 public: |
119 FileWatcherExtensions(const base::FilePath& path, | 119 FileWatcherExtensions(const base::FilePath& path, |
120 const std::string& extension_id, | 120 const std::string& extension_id, |
121 bool is_remote_file_system); | 121 bool is_remote_file_system); |
122 | 122 |
123 ~FileWatcherExtensions(); | 123 ~FileWatcherExtensions(); |
(...skipping 15 matching lines...) Expand all Loading... | |
139 linked_ptr<base::FilePathWatcher> file_watcher_; | 139 linked_ptr<base::FilePathWatcher> file_watcher_; |
140 base::FilePath local_path_; | 140 base::FilePath local_path_; |
141 base::FilePath virtual_path_; | 141 base::FilePath virtual_path_; |
142 ExtensionUsageRegistry extensions_; | 142 ExtensionUsageRegistry extensions_; |
143 unsigned int ref_count_; | 143 unsigned int ref_count_; |
144 bool is_remote_file_system_; | 144 bool is_remote_file_system_; |
145 }; | 145 }; |
146 | 146 |
147 typedef std::map<base::FilePath, FileWatcherExtensions*> WatcherMap; | 147 typedef std::map<base::FilePath, FileWatcherExtensions*> WatcherMap; |
148 | 148 |
149 explicit FileBrowserEventRouter(Profile* profile); | 149 explicit FileBrowserEventRouter(Profile* profile); |
hashimoto
2013/04/08 04:49:38
Can't we make this ctor public and remove "friend
satorux1
2013/04/08 05:03:37
Done. Good catch!
| |
150 virtual ~FileBrowserEventRouter(); | |
151 | 150 |
152 // USB mount event handlers. | 151 // USB mount event handlers. |
153 void OnDiskAdded(const chromeos::disks::DiskMountManager::Disk* disk); | 152 void OnDiskAdded(const chromeos::disks::DiskMountManager::Disk* disk); |
154 void OnDiskRemoved(const chromeos::disks::DiskMountManager::Disk* disk); | 153 void OnDiskRemoved(const chromeos::disks::DiskMountManager::Disk* disk); |
155 void OnDiskMounted(const chromeos::disks::DiskMountManager::Disk* disk); | 154 void OnDiskMounted(const chromeos::disks::DiskMountManager::Disk* disk); |
156 void OnDiskUnmounted(const chromeos::disks::DiskMountManager::Disk* disk); | 155 void OnDiskUnmounted(const chromeos::disks::DiskMountManager::Disk* disk); |
157 void OnDeviceAdded(const std::string& device_path); | 156 void OnDeviceAdded(const std::string& device_path); |
158 void OnDeviceRemoved(const std::string& device_path); | 157 void OnDeviceRemoved(const std::string& device_path); |
159 void OnDeviceScanned(const std::string& device_path); | 158 void OnDeviceScanned(const std::string& device_path); |
160 void OnFormatStarted(const std::string& device_path, bool success); | 159 void OnFormatStarted(const std::string& device_path, bool success); |
(...skipping 28 matching lines...) Expand all Loading... | |
189 // Returns the DriveFileSystem for the current profile. | 188 // Returns the DriveFileSystem for the current profile. |
190 drive::DriveFileSystemInterface* GetRemoteFileSystem() const; | 189 drive::DriveFileSystemInterface* GetRemoteFileSystem() const; |
191 | 190 |
192 // Handles requests to start and stop periodic updates on remote file system. | 191 // Handles requests to start and stop periodic updates on remote file system. |
193 // When |start| is set to true, this function starts periodic updates only if | 192 // When |start| is set to true, this function starts periodic updates only if |
194 // it is not yet started; when |start| is set to false, this function stops | 193 // it is not yet started; when |start| is set to false, this function stops |
195 // periodic updates only if the number of outstanding update requests reaches | 194 // periodic updates only if the number of outstanding update requests reaches |
196 // zero. | 195 // zero. |
197 void HandleRemoteUpdateRequestOnUIThread(bool start); | 196 void HandleRemoteUpdateRequestOnUIThread(bool start); |
198 | 197 |
199 base::WeakPtrFactory<FileBrowserEventRouter> weak_factory_; | |
200 base::FilePathWatcher::Callback file_watcher_callback_; | 198 base::FilePathWatcher::Callback file_watcher_callback_; |
201 WatcherMap file_watchers_; | 199 WatcherMap file_watchers_; |
202 scoped_ptr<FileBrowserNotifications> notifications_; | 200 scoped_ptr<FileBrowserNotifications> notifications_; |
203 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 201 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
204 scoped_ptr<SuspendStateDelegate> suspend_state_delegate_; | 202 scoped_ptr<SuspendStateDelegate> suspend_state_delegate_; |
205 Profile* profile_; | 203 Profile* profile_; |
206 base::Lock lock_; | 204 base::Lock lock_; |
207 | 205 |
208 // Number of active update requests on the remote file system. | 206 // Number of active update requests on the remote file system. |
209 int num_remote_update_requests_; | 207 int num_remote_update_requests_; |
210 | 208 |
211 // Event router behavior depends on shift modifier status. This is designed | 209 // Event router behavior depends on shift modifier status. This is designed |
212 // for power users. | 210 // for power users. |
213 bool shift_pressed_; | 211 bool shift_pressed_; |
214 | 212 |
213 // Note: This should remain the last member so it'll be destroyed and | |
214 // invalidate the weak pointers before any other members are destroyed. | |
215 base::WeakPtrFactory<FileBrowserEventRouter> weak_factory_; | |
215 DISALLOW_COPY_AND_ASSIGN(FileBrowserEventRouter); | 216 DISALLOW_COPY_AND_ASSIGN(FileBrowserEventRouter); |
216 }; | 217 }; |
217 | 218 |
218 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 219 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ |
OLD | NEW |