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

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

Issue 658013002: Changed api to notify when watched directory is deleted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed CreateDirectoryDeletionFileChange. Created 6 years, 2 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
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 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/files/file_path_watcher.h" 14 #include "base/files/file_path_watcher.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 16 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
16 #include "chrome/browser/chromeos/drive/file_system_observer.h" 17 #include "chrome/browser/chromeos/drive/file_system_observer.h"
17 #include "chrome/browser/chromeos/drive/job_list.h" 18 #include "chrome/browser/chromeos/drive/job_list.h"
18 #include "chrome/browser/chromeos/drive/sync_client.h" 19 #include "chrome/browser/chromeos/drive/sync_client.h"
19 #include "chrome/browser/chromeos/file_manager/file_watcher.h" 20 #include "chrome/browser/chromeos/file_manager/file_watcher.h"
(...skipping 30 matching lines...) Expand all
50 // Monitors changes in disk mounts, network connection state and preferences 51 // Monitors changes in disk mounts, network connection state and preferences
51 // affecting File Manager. Dispatches appropriate File Browser events. 52 // affecting File Manager. Dispatches appropriate File Browser events.
52 class EventRouter : public KeyedService, 53 class EventRouter : public KeyedService,
53 public chromeos::NetworkStateHandlerObserver, 54 public chromeos::NetworkStateHandlerObserver,
54 public drive::FileSystemObserver, 55 public drive::FileSystemObserver,
55 public drive::JobListObserver, 56 public drive::JobListObserver,
56 public drive::DriveServiceObserver, 57 public drive::DriveServiceObserver,
57 public VolumeManagerObserver, 58 public VolumeManagerObserver,
58 public content::NotificationObserver { 59 public content::NotificationObserver {
59 public: 60 public:
61 typedef base::Callback<void(const base::FilePath& virtual_path,
62 const drive::FileChange* list, bool got_error,
63 const std::vector<std::string>& extension_ids)>
64 DispatchDirectoryChangeEventImplCallback;
65
60 explicit EventRouter(Profile* profile); 66 explicit EventRouter(Profile* profile);
61 virtual ~EventRouter(); 67 virtual ~EventRouter();
62 68
63 // KeyedService overrides. 69 // KeyedService overrides.
64 virtual void Shutdown() override; 70 virtual void Shutdown() override;
65 71
66 typedef base::Callback<void(bool success)> BoolCallback; 72 typedef base::Callback<void(bool success)> BoolCallback;
67 73
68 // Adds a file watch at |local_path|, associated with |virtual_path|, for 74 // Adds a file watch at |local_path|, associated with |virtual_path|, for
69 // an extension with |extension_id|. 75 // an extension with |extension_id|.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 virtual void OnFormatStarted( 131 virtual void OnFormatStarted(
126 const std::string& device_path, bool success) override; 132 const std::string& device_path, bool success) override;
127 virtual void OnFormatCompleted( 133 virtual void OnFormatCompleted(
128 const std::string& device_path, bool success) override; 134 const std::string& device_path, bool success) override;
129 135
130 // content::NotificationObserver overrides. 136 // content::NotificationObserver overrides.
131 virtual void Observe(int type, 137 virtual void Observe(int type,
132 const content::NotificationSource& source, 138 const content::NotificationSource& source,
133 const content::NotificationDetails& details) override; 139 const content::NotificationDetails& details) override;
134 140
141 // Set custom dispatch directory change event implementation for testing.
142 void SetDispatchDirectoryChangeEventImplForTesting(
143 const DispatchDirectoryChangeEventImplCallback& callback);
144
135 private: 145 private:
136 typedef std::map<base::FilePath, FileWatcher*> WatcherMap; 146 typedef std::map<base::FilePath, FileWatcher*> WatcherMap;
137 147
138 // Starts observing file system change events. 148 // Starts observing file system change events.
139 void ObserveEvents(); 149 void ObserveEvents();
140 150
141 // Called when prefs related to file manager change. 151 // Called when prefs related to file manager change.
142 void OnFileManagerPrefsChanged(); 152 void OnFileManagerPrefsChanged();
143 153
144 // Process file watch notifications. 154 // Process file watch notifications.
145 void HandleFileWatchNotification(const drive::FileChange* list, 155 void HandleFileWatchNotification(const drive::FileChange* list,
146 const base::FilePath& path, 156 const base::FilePath& path,
147 bool got_error); 157 bool got_error);
148 158
149 // Sends directory change event. 159 // Sends directory change event.
150 void DispatchDirectoryChangeEvent( 160 void DispatchDirectoryChangeEvent(
151 const base::FilePath& path, 161 const base::FilePath& path,
152 const drive::FileChange* list, 162 const drive::FileChange* list,
153 bool got_error, 163 bool got_error,
154 const std::vector<std::string>& extension_ids); 164 const std::vector<std::string>& extension_ids);
155 165
166 // Default implementation of DispatchDirectoryChangeEvent.
167 void DispatchDirectoryChangeEventImpl(
168 const base::FilePath& path, const drive::FileChange* list, bool got_error,
169 const std::vector<std::string>& extension_ids);
170
156 // Sends directory change event, after converting the file definition to entry 171 // Sends directory change event, after converting the file definition to entry
157 // definition. 172 // definition.
158 void DispatchDirectoryChangeEventWithEntryDefinition( 173 void DispatchDirectoryChangeEventWithEntryDefinition(
159 const linked_ptr<drive::FileChange> list, 174 const linked_ptr<drive::FileChange> list,
160 const std::string* extension_id, 175 const std::string* extension_id,
161 bool watcher_error, 176 bool watcher_error,
162 const EntryDefinition& entry_definition); 177 const EntryDefinition& entry_definition);
163 178
164 // Dispatches the mount completed event. 179 // Dispatches the mount completed event.
165 void DispatchMountCompletedEvent( 180 void DispatchMountCompletedEvent(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 base::Time next_send_file_transfer_event_; 218 base::Time next_send_file_transfer_event_;
204 219
205 WatcherMap file_watchers_; 220 WatcherMap file_watchers_;
206 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; 221 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_;
207 Profile* profile_; 222 Profile* profile_;
208 223
209 content::NotificationRegistrar notification_registrar_; 224 content::NotificationRegistrar notification_registrar_;
210 225
211 scoped_ptr<DeviceEventRouter> device_event_router_; 226 scoped_ptr<DeviceEventRouter> device_event_router_;
212 227
228 DispatchDirectoryChangeEventImplCallback
229 dispatch_directory_change_event_impl_;
230
213 // Note: This should remain the last member so it'll be destroyed and 231 // Note: This should remain the last member so it'll be destroyed and
214 // invalidate the weak pointers before any other members are destroyed. 232 // invalidate the weak pointers before any other members are destroyed.
215 base::WeakPtrFactory<EventRouter> weak_factory_; 233 base::WeakPtrFactory<EventRouter> weak_factory_;
234
216 DISALLOW_COPY_AND_ASSIGN(EventRouter); 235 DISALLOW_COPY_AND_ASSIGN(EventRouter);
217 }; 236 };
218 237
219 } // namespace file_manager 238 } // namespace file_manager
220 239
221 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_ 240 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698