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_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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 extensions::api::file_browser_private::MountCompletedEventType event_type, | 157 extensions::api::file_browser_private::MountCompletedEventType event_type, |
158 chromeos::MountError error, | 158 chromeos::MountError error, |
159 const VolumeInfo& volume_info); | 159 const VolumeInfo& volume_info); |
160 | 160 |
161 // If needed, opens a file manager window for the removable device mounted at | 161 // If needed, opens a file manager window for the removable device mounted at |
162 // |mount_path|. Disk.mount_path() is empty, since it is being filled out | 162 // |mount_path|. Disk.mount_path() is empty, since it is being filled out |
163 // after calling notifying observers by DiskMountManager. | 163 // after calling notifying observers by DiskMountManager. |
164 void ShowRemovableDeviceInFileManager(VolumeType type, | 164 void ShowRemovableDeviceInFileManager(VolumeType type, |
165 const base::FilePath& mount_path); | 165 const base::FilePath& mount_path); |
166 | 166 |
167 // Sends onFileTranferUpdated to extensions if needed. If |always| is true, | |
168 // it sends the event always. Otherwise, it sends the event if enough time has | |
169 // passed from the previous event so as not to make extension busy. | |
170 void SendDriveFileTransferEvent(bool always); | |
171 | |
172 // Manages the list of currently active Drive file transfer jobs. | 167 // Manages the list of currently active Drive file transfer jobs. |
173 struct DriveJobInfoWithStatus { | 168 struct DriveJobInfoWithStatus { |
174 DriveJobInfoWithStatus(); | 169 DriveJobInfoWithStatus(); |
175 DriveJobInfoWithStatus(const drive::JobInfo& info, | 170 DriveJobInfoWithStatus(const drive::JobInfo& info, |
176 const std::string& status); | 171 const std::string& status); |
177 drive::JobInfo job_info; | 172 drive::JobInfo job_info; |
178 std::string status; | 173 std::string status; |
179 }; | 174 }; |
| 175 |
| 176 // Sends onFileTransferUpdate event right now if |immediate| is set. Otherwise |
| 177 // it refrains from sending for a short while, and after that it sends the |
| 178 // most recently scheduled event once. |
| 179 // The delay is for waiting subsequent 'added' events to come after the first |
| 180 // one when multiple tasks are added. This way, we can avoid frequent UI |
| 181 // update caused by differences between singular and plural cases. |
| 182 void ScheduleDriveFileTransferEvent(const drive::JobInfo& job_info, |
| 183 const std::string& status, |
| 184 bool immediate); |
| 185 |
| 186 // Sends the most recently scheduled onFileTransferUpdated event to |
| 187 // extensions. |
| 188 // This is used for implementing ScheduledDriveFileTransferEvent(). |
| 189 void SendDriveFileTransferEvent(); |
| 190 |
180 std::map<drive::JobID, DriveJobInfoWithStatus> drive_jobs_; | 191 std::map<drive::JobID, DriveJobInfoWithStatus> drive_jobs_; |
181 base::Time last_file_transfer_event_; | 192 scoped_ptr<DriveJobInfoWithStatus> drive_job_info_for_scheduled_event_; |
182 base::Time last_copy_progress_event_; | 193 base::Time last_copy_progress_event_; |
| 194 base::Time next_send_file_transfer_event_; |
183 | 195 |
184 WatcherMap file_watchers_; | 196 WatcherMap file_watchers_; |
185 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 197 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
186 Profile* profile_; | 198 Profile* profile_; |
187 | 199 |
188 scoped_ptr<DeviceEventRouter> device_event_router_; | 200 scoped_ptr<DeviceEventRouter> device_event_router_; |
189 | 201 |
190 // Note: This should remain the last member so it'll be destroyed and | 202 // Note: This should remain the last member so it'll be destroyed and |
191 // invalidate the weak pointers before any other members are destroyed. | 203 // invalidate the weak pointers before any other members are destroyed. |
192 base::WeakPtrFactory<EventRouter> weak_factory_; | 204 base::WeakPtrFactory<EventRouter> weak_factory_; |
193 DISALLOW_COPY_AND_ASSIGN(EventRouter); | 205 DISALLOW_COPY_AND_ASSIGN(EventRouter); |
194 }; | 206 }; |
195 | 207 |
196 } // namespace file_manager | 208 } // namespace file_manager |
197 | 209 |
198 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_ | 210 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_ |
OLD | NEW |