Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/event_router.h

Issue 490643005: Files.app: Start to use DeviceEventRouter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_MANAGER_EVENT_ROUTER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_ 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 29 matching lines...) Expand all
40 40
41 namespace chromeos { 41 namespace chromeos {
42 class NetworkState; 42 class NetworkState;
43 } 43 }
44 44
45 namespace drive { 45 namespace drive {
46 class FileChange; 46 class FileChange;
47 } 47 }
48 48
49 namespace file_manager { 49 namespace file_manager {
50 class DeviceEventRouter;
50 51
51 // Monitors changes in disk mounts, network connection state and preferences 52 // Monitors changes in disk mounts, network connection state and preferences
52 // affecting File Manager. Dispatches appropriate File Browser events. 53 // affecting File Manager. Dispatches appropriate File Browser events.
53 class EventRouter 54 class EventRouter
54 : public chromeos::NetworkStateHandlerObserver, 55 : public chromeos::NetworkStateHandlerObserver,
55 public drive::FileSystemObserver, 56 public drive::FileSystemObserver,
56 public drive::JobListObserver, 57 public drive::JobListObserver,
57 public drive::DriveServiceObserver, 58 public drive::DriveServiceObserver,
58 public VolumeManagerObserver, 59 public VolumeManagerObserver,
59 public content::NotificationObserver, 60 public content::NotificationObserver,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 bool mounting) OVERRIDE; 124 bool mounting) OVERRIDE;
124 virtual void OnDiskRemoved( 125 virtual void OnDiskRemoved(
125 const chromeos::disks::DiskMountManager::Disk& disk) OVERRIDE; 126 const chromeos::disks::DiskMountManager::Disk& disk) OVERRIDE;
126 virtual void OnDeviceAdded(const std::string& device_path) OVERRIDE; 127 virtual void OnDeviceAdded(const std::string& device_path) OVERRIDE;
127 virtual void OnDeviceRemoved(const std::string& device_path) OVERRIDE; 128 virtual void OnDeviceRemoved(const std::string& device_path) OVERRIDE;
128 virtual void OnVolumeMounted(chromeos::MountError error_code, 129 virtual void OnVolumeMounted(chromeos::MountError error_code,
129 const VolumeInfo& volume_info, 130 const VolumeInfo& volume_info,
130 bool is_remounting) OVERRIDE; 131 bool is_remounting) OVERRIDE;
131 virtual void OnVolumeUnmounted(chromeos::MountError error_code, 132 virtual void OnVolumeUnmounted(chromeos::MountError error_code,
132 const VolumeInfo& volume_info) OVERRIDE; 133 const VolumeInfo& volume_info) OVERRIDE;
133 virtual void OnHardUnplugged(const std::string& device_path) OVERRIDE;
134 virtual void OnFormatStarted( 134 virtual void OnFormatStarted(
135 const std::string& device_path, bool success) OVERRIDE; 135 const std::string& device_path, bool success) OVERRIDE;
136 virtual void OnFormatCompleted( 136 virtual void OnFormatCompleted(
137 const std::string& device_path, bool success) OVERRIDE; 137 const std::string& device_path, bool success) OVERRIDE;
138 138
139 // content::NotificationObserver overrides. 139 // content::NotificationObserver overrides.
140 virtual void Observe(int type, 140 virtual void Observe(int type,
141 const content::NotificationSource& source, 141 const content::NotificationSource& source,
142 const content::NotificationDetails& details) OVERRIDE; 142 const content::NotificationDetails& details) OVERRIDE;
143 143
(...skipping 23 matching lines...) Expand all
167 void DispatchDirectoryChangeEventWithEntryDefinition( 167 void DispatchDirectoryChangeEventWithEntryDefinition(
168 const linked_ptr<drive::FileChange> list, 168 const linked_ptr<drive::FileChange> list,
169 const std::string* extension_id, 169 const std::string* extension_id,
170 bool watcher_error, 170 bool watcher_error,
171 const EntryDefinition& entry_definition); 171 const EntryDefinition& entry_definition);
172 172
173 // Dispatches the mount completed event. 173 // Dispatches the mount completed event.
174 void DispatchMountCompletedEvent( 174 void DispatchMountCompletedEvent(
175 extensions::api::file_browser_private::MountCompletedEventType event_type, 175 extensions::api::file_browser_private::MountCompletedEventType event_type,
176 chromeos::MountError error, 176 chromeos::MountError error,
177 const VolumeInfo& volume_info, 177 const VolumeInfo& volume_info);
178 bool is_remounting);
179 178
180 // If needed, opens a file manager window for the removable device mounted at 179 // If needed, opens a file manager window for the removable device mounted at
181 // |mount_path|. Disk.mount_path() is empty, since it is being filled out 180 // |mount_path|. Disk.mount_path() is empty, since it is being filled out
182 // after calling notifying observers by DiskMountManager. 181 // after calling notifying observers by DiskMountManager.
183 void ShowRemovableDeviceInFileManager(VolumeType type, 182 void ShowRemovableDeviceInFileManager(VolumeType type,
184 const base::FilePath& mount_path); 183 const base::FilePath& mount_path);
185 184
186 // Dispatches an onDeviceChanged event containing |type| and |path| to
187 // extensions.
188 void DispatchDeviceEvent(
189 extensions::api::file_browser_private::DeviceEventType type,
190 const std::string& path);
191
192 // Sends onFileTranferUpdated to extensions if needed. If |always| is true, 185 // Sends onFileTranferUpdated to extensions if needed. If |always| is true,
193 // it sends the event always. Otherwise, it sends the event if enough time has 186 // it sends the event always. Otherwise, it sends the event if enough time has
194 // passed from the previous event so as not to make extension busy. 187 // passed from the previous event so as not to make extension busy.
195 void SendDriveFileTransferEvent(bool always); 188 void SendDriveFileTransferEvent(bool always);
196 189
197 // Manages the list of currently active Drive file transfer jobs. 190 // Manages the list of currently active Drive file transfer jobs.
198 struct DriveJobInfoWithStatus { 191 struct DriveJobInfoWithStatus {
199 DriveJobInfoWithStatus(); 192 DriveJobInfoWithStatus();
200 DriveJobInfoWithStatus(const drive::JobInfo& info, 193 DriveJobInfoWithStatus(const drive::JobInfo& info,
201 const std::string& status); 194 const std::string& status);
202 drive::JobInfo job_info; 195 drive::JobInfo job_info;
203 std::string status; 196 std::string status;
204 }; 197 };
205 std::map<drive::JobID, DriveJobInfoWithStatus> drive_jobs_; 198 std::map<drive::JobID, DriveJobInfoWithStatus> drive_jobs_;
206 base::Time last_file_transfer_event_; 199 base::Time last_file_transfer_event_;
207 base::Time last_copy_progress_event_; 200 base::Time last_copy_progress_event_;
208 201
209 WatcherMap file_watchers_; 202 WatcherMap file_watchers_;
210 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; 203 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_;
211 Profile* profile_; 204 Profile* profile_;
212 205
213 content::NotificationRegistrar notification_registrar_; 206 content::NotificationRegistrar notification_registrar_;
214 bool multi_user_window_manager_observer_registered_; 207 bool multi_user_window_manager_observer_registered_;
215 208
209 scoped_ptr<DeviceEventRouter> device_event_router_;
210
216 // Note: This should remain the last member so it'll be destroyed and 211 // Note: This should remain the last member so it'll be destroyed and
217 // invalidate the weak pointers before any other members are destroyed. 212 // invalidate the weak pointers before any other members are destroyed.
218 base::WeakPtrFactory<EventRouter> weak_factory_; 213 base::WeakPtrFactory<EventRouter> weak_factory_;
219 DISALLOW_COPY_AND_ASSIGN(EventRouter); 214 DISALLOW_COPY_AND_ASSIGN(EventRouter);
220 }; 215 };
221 216
222 } // namespace file_manager 217 } // namespace file_manager
223 218
224 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_ 219 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698