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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/service.h

Issue 674413002: [fsp] Rename ObserveEntry with AddWatcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_FILE_SYSTEM_PROVIDER_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/files/file.h" 13 #include "base/files/file.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/chromeos/file_system_provider/observed_entry.h"
21 #include "chrome/browser/chromeos/file_system_provider/observer.h" 20 #include "chrome/browser/chromeos/file_system_provider/observer.h"
22 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h" 21 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h"
23 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_obse rver.h" 22 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_obse rver.h"
23 #include "chrome/browser/chromeos/file_system_provider/watcher.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/common/extensions/api/file_system_provider.h" 25 #include "chrome/common/extensions/api/file_system_provider.h"
26 #include "components/keyed_service/core/keyed_service.h" 26 #include "components/keyed_service/core/keyed_service.h"
27 #include "content/public/browser/browser_context.h" 27 #include "content/public/browser/browser_context.h"
28 #include "extensions/browser/extension_registry_observer.h" 28 #include "extensions/browser/extension_registry_observer.h"
29 #include "extensions/common/extension.h" 29 #include "extensions/common/extension.h"
30 30
31 namespace extensions { 31 namespace extensions {
32 class ExtensionRegistry; 32 class ExtensionRegistry;
33 } // namespace extensions 33 } // namespace extensions
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // extensions::ExtensionRegistryObserver overrides. 122 // extensions::ExtensionRegistryObserver overrides.
123 virtual void OnExtensionUnloaded( 123 virtual void OnExtensionUnloaded(
124 content::BrowserContext* browser_context, 124 content::BrowserContext* browser_context,
125 const extensions::Extension* extension, 125 const extensions::Extension* extension,
126 extensions::UnloadedExtensionInfo::Reason reason) override; 126 extensions::UnloadedExtensionInfo::Reason reason) override;
127 virtual void OnExtensionLoaded( 127 virtual void OnExtensionLoaded(
128 content::BrowserContext* browser_context, 128 content::BrowserContext* browser_context,
129 const extensions::Extension* extension) override; 129 const extensions::Extension* extension) override;
130 130
131 // ProvidedFileSystemInterface::Observer overrides. 131 // ProvidedFileSystemInterface::Observer overrides.
132 virtual void OnObservedEntryChanged( 132 virtual void OnWatcherChanged(
133 const ProvidedFileSystemInfo& file_system_info, 133 const ProvidedFileSystemInfo& file_system_info,
134 const ObservedEntry& observed_entry, 134 const Watcher& watcher,
135 ProvidedFileSystemObserver::ChangeType change_type, 135 ProvidedFileSystemObserver::ChangeType change_type,
136 const ProvidedFileSystemObserver::Changes& changes, 136 const ProvidedFileSystemObserver::Changes& changes,
137 const base::Closure& callback) override; 137 const base::Closure& callback) override;
138 virtual void OnObservedEntryTagUpdated( 138 virtual void OnWatcherTagUpdated(
139 const ProvidedFileSystemInfo& file_system_info, 139 const ProvidedFileSystemInfo& file_system_info,
140 const ObservedEntry& observed_entry) override; 140 const Watcher& watcher) override;
141 virtual void OnObservedEntryListChanged( 141 virtual void OnWatcherListChanged(
142 const ProvidedFileSystemInfo& file_system_info, 142 const ProvidedFileSystemInfo& file_system_info,
143 const ObservedEntries& observed_entries) override; 143 const Watchers& watchers) override;
144 144
145 private: 145 private:
146 FRIEND_TEST_ALL_PREFIXES(FileSystemProviderServiceTest, RememberFileSystem); 146 FRIEND_TEST_ALL_PREFIXES(FileSystemProviderServiceTest, RememberFileSystem);
147 147
148 // Key is a pair of an extension id and file system id, which makes it 148 // Key is a pair of an extension id and file system id, which makes it
149 // unique among the entire service instance. 149 // unique among the entire service instance.
150 typedef std::pair<std::string, std::string> FileSystemKey; 150 typedef std::pair<std::string, std::string> FileSystemKey;
151 151
152 typedef std::map<FileSystemKey, ProvidedFileSystemInterface*> 152 typedef std::map<FileSystemKey, ProvidedFileSystemInterface*>
153 ProvidedFileSystemMap; 153 ProvidedFileSystemMap;
154 typedef std::map<std::string, FileSystemKey> MountPointNameToKeyMap; 154 typedef std::map<std::string, FileSystemKey> MountPointNameToKeyMap;
155 155
156 // Called when the providing extension accepts or refuses a unmount request. 156 // Called when the providing extension accepts or refuses a unmount request.
157 // If |error| is equal to FILE_OK, then the request is accepted. 157 // If |error| is equal to FILE_OK, then the request is accepted.
158 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, 158 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info,
159 base::File::Error error); 159 base::File::Error error);
160 160
161 // Remembers the file system in preferences, in order to remount after a 161 // Remembers the file system in preferences, in order to remount after a
162 // reboot. 162 // reboot.
163 void RememberFileSystem(const ProvidedFileSystemInfo& file_system_info, 163 void RememberFileSystem(const ProvidedFileSystemInfo& file_system_info,
164 const ObservedEntries& observed_entries); 164 const Watchers& watchers);
165 165
166 // Removes the file system from preferences, so it is not remounmted anymore 166 // Removes the file system from preferences, so it is not remounmted anymore
167 // after a reboot. 167 // after a reboot.
168 void ForgetFileSystem(const std::string& extension_id, 168 void ForgetFileSystem(const std::string& extension_id,
169 const std::string& file_system_id); 169 const std::string& file_system_id);
170 170
171 // Restores from preferences file systems mounted previously by the 171 // Restores from preferences file systems mounted previously by the
172 // |extension_id| providing extension. 172 // |extension_id| providing extension.
173 void RestoreFileSystems(const std::string& extension_id); 173 void RestoreFileSystems(const std::string& extension_id);
174 174
175 Profile* profile_; 175 Profile* profile_;
176 extensions::ExtensionRegistry* extension_registry_; // Not owned. 176 extensions::ExtensionRegistry* extension_registry_; // Not owned.
177 FileSystemFactoryCallback file_system_factory_; 177 FileSystemFactoryCallback file_system_factory_;
178 ObserverList<Observer> observers_; 178 ObserverList<Observer> observers_;
179 ProvidedFileSystemMap file_system_map_; // Owns pointers. 179 ProvidedFileSystemMap file_system_map_; // Owns pointers.
180 MountPointNameToKeyMap mount_point_name_to_key_map_; 180 MountPointNameToKeyMap mount_point_name_to_key_map_;
181 scoped_ptr<RegistryInterface> registry_; 181 scoped_ptr<RegistryInterface> registry_;
182 base::ThreadChecker thread_checker_; 182 base::ThreadChecker thread_checker_;
183 183
184 base::WeakPtrFactory<Service> weak_ptr_factory_; 184 base::WeakPtrFactory<Service> weak_ptr_factory_;
185 DISALLOW_COPY_AND_ASSIGN(Service); 185 DISALLOW_COPY_AND_ASSIGN(Service);
186 }; 186 };
187 187
188 } // namespace file_system_provider 188 } // namespace file_system_provider
189 } // namespace chromeos 189 } // namespace chromeos
190 190
191 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ 191 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698