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

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

Issue 661393002: [fsp] Separate logic for saving/restoring state to a separate class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: C++11 features. 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 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>
(...skipping 21 matching lines...) Expand all
32 class ExtensionRegistry; 32 class ExtensionRegistry;
33 } // namespace extensions 33 } // namespace extensions
34 34
35 namespace user_prefs { 35 namespace user_prefs {
36 class PrefRegistrySyncable; 36 class PrefRegistrySyncable;
37 } // namespace user_prefs 37 } // namespace user_prefs
38 38
39 namespace chromeos { 39 namespace chromeos {
40 namespace file_system_provider { 40 namespace file_system_provider {
41 41
42 // Key names for preferences.
43 extern const char kPrefKeyFileSystemId[];
44 extern const char kPrefKeyDisplayName[];
45 extern const char kPrefKeyWritable[];
46 extern const char kPrefKeySupportsNotifyTag[];
47 extern const char kPrefKeyObservedEntries[];
48 extern const char kPrefKeyObservedEntryEntryPath[];
49 extern const char kPrefKeyObservedEntryRecursive[];
50 extern const char kPrefKeyObservedEntryLastTag[];
51
52 class ProvidedFileSystemFactoryInterface; 42 class ProvidedFileSystemFactoryInterface;
53 class ProvidedFileSystemInfo; 43 class ProvidedFileSystemInfo;
54 class ProvidedFileSystemInterface; 44 class ProvidedFileSystemInterface;
45 class RegistryInterface;
55 class ServiceFactory; 46 class ServiceFactory;
56 struct MountOptions; 47 struct MountOptions;
57 48
58 // Registers preferences to remember registered file systems between reboots. 49 // Registers preferences to remember registered file systems between reboots.
59 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 50 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
60 51
61 // Manages and registers the file system provider service. Maintains provided 52 // Manages and registers the file system provider service. Maintains provided
62 // file systems. 53 // file systems.
63 class Service : public KeyedService, 54 class Service : public KeyedService,
64 public extensions::ExtensionRegistryObserver, 55 public extensions::ExtensionRegistryObserver,
(...skipping 10 matching lines...) Expand all
75 enum UnmountReason { UNMOUNT_REASON_USER, UNMOUNT_REASON_SHUTDOWN }; 66 enum UnmountReason { UNMOUNT_REASON_USER, UNMOUNT_REASON_SHUTDOWN };
76 67
77 Service(Profile* profile, extensions::ExtensionRegistry* extension_registry); 68 Service(Profile* profile, extensions::ExtensionRegistry* extension_registry);
78 virtual ~Service(); 69 virtual ~Service();
79 70
80 // Sets a custom ProvidedFileSystemInterface factory. Used by unit tests, 71 // Sets a custom ProvidedFileSystemInterface factory. Used by unit tests,
81 // where an event router is not available. 72 // where an event router is not available.
82 void SetFileSystemFactoryForTesting( 73 void SetFileSystemFactoryForTesting(
83 const FileSystemFactoryCallback& factory_callback); 74 const FileSystemFactoryCallback& factory_callback);
84 75
76 // Sets a custom Registry implementation. Used by unit tests.
77 void SetRegistryForTesting(scoped_ptr<RegistryInterface> registry);
78
85 // Mounts a file system provided by an extension with the |extension_id|. If 79 // Mounts a file system provided by an extension with the |extension_id|. If
86 // |writable| is set to true, then the file system is mounted in a R/W mode. 80 // |writable| is set to true, then the file system is mounted in a R/W mode.
87 // Otherwise, only read-only operations are supported. If change notification 81 // Otherwise, only read-only operations are supported. If change notification
88 // tags are supported, then |supports_notify_tag| must be true. Note, that 82 // tags are supported, then |supports_notify_tag| must be true. Note, that
89 // it is required in order to enable the internal cache. For success, returns 83 // it is required in order to enable the internal cache. For success, returns
90 // true, otherwise false. 84 // true, otherwise false.
91 bool MountFileSystem(const std::string& extension_id, 85 bool MountFileSystem(const std::string& extension_id,
92 const MountOptions& options); 86 const MountOptions& options);
93 87
94 // Unmounts a file system with the specified |file_system_id| for the 88 // Unmounts a file system with the specified |file_system_id| for the
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 content::BrowserContext* browser_context, 124 content::BrowserContext* browser_context,
131 const extensions::Extension* extension, 125 const extensions::Extension* extension,
132 extensions::UnloadedExtensionInfo::Reason reason) override; 126 extensions::UnloadedExtensionInfo::Reason reason) override;
133 virtual void OnExtensionLoaded( 127 virtual void OnExtensionLoaded(
134 content::BrowserContext* browser_context, 128 content::BrowserContext* browser_context,
135 const extensions::Extension* extension) override; 129 const extensions::Extension* extension) override;
136 130
137 // ProvidedFileSystemInterface::Observer overrides. 131 // ProvidedFileSystemInterface::Observer overrides.
138 virtual void OnObservedEntryChanged( 132 virtual void OnObservedEntryChanged(
139 const ProvidedFileSystemInfo& file_system_info, 133 const ProvidedFileSystemInfo& file_system_info,
140 const base::FilePath& observed_path, 134 const ObservedEntry& observed_entry,
141 ProvidedFileSystemObserver::ChangeType change_type, 135 ProvidedFileSystemObserver::ChangeType change_type,
142 const ProvidedFileSystemObserver::ChildChanges& child_changes, 136 const ProvidedFileSystemObserver::ChildChanges& child_changes,
143 const base::Closure& callback) override; 137 const base::Closure& callback) override;
144 virtual void OnObservedEntryTagUpdated( 138 virtual void OnObservedEntryTagUpdated(
145 const ProvidedFileSystemInfo& file_system_info, 139 const ProvidedFileSystemInfo& file_system_info,
146 const base::FilePath& observed_path, 140 const ObservedEntry& observed_entry) override;
147 const std::string& tag) override;
148 virtual void OnObservedEntryListChanged( 141 virtual void OnObservedEntryListChanged(
149 const ProvidedFileSystemInfo& file_system_info, 142 const ProvidedFileSystemInfo& file_system_info,
150 const ObservedEntries& observed_entries) override; 143 const ObservedEntries& observed_entries) override;
151 144
152 private: 145 private:
153 FRIEND_TEST_ALL_PREFIXES(FileSystemProviderServiceTest, RememberFileSystem); 146 FRIEND_TEST_ALL_PREFIXES(FileSystemProviderServiceTest, RememberFileSystem);
154 147
155 // 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
156 // unique among the entire service instance. 149 // unique among the entire service instance.
157 typedef std::pair<std::string, std::string> FileSystemKey; 150 typedef std::pair<std::string, std::string> FileSystemKey;
(...skipping 20 matching lines...) Expand all
178 // Restores from preferences file systems mounted previously by the 171 // Restores from preferences file systems mounted previously by the
179 // |extension_id| providing extension. 172 // |extension_id| providing extension.
180 void RestoreFileSystems(const std::string& extension_id); 173 void RestoreFileSystems(const std::string& extension_id);
181 174
182 Profile* profile_; 175 Profile* profile_;
183 extensions::ExtensionRegistry* extension_registry_; // Not owned. 176 extensions::ExtensionRegistry* extension_registry_; // Not owned.
184 FileSystemFactoryCallback file_system_factory_; 177 FileSystemFactoryCallback file_system_factory_;
185 ObserverList<Observer> observers_; 178 ObserverList<Observer> observers_;
186 ProvidedFileSystemMap file_system_map_; // Owns pointers. 179 ProvidedFileSystemMap file_system_map_; // Owns pointers.
187 MountPointNameToKeyMap mount_point_name_to_key_map_; 180 MountPointNameToKeyMap mount_point_name_to_key_map_;
181 scoped_ptr<RegistryInterface> registry_;
188 base::ThreadChecker thread_checker_; 182 base::ThreadChecker thread_checker_;
183
189 base::WeakPtrFactory<Service> weak_ptr_factory_; 184 base::WeakPtrFactory<Service> weak_ptr_factory_;
190
191 DISALLOW_COPY_AND_ASSIGN(Service); 185 DISALLOW_COPY_AND_ASSIGN(Service);
192 }; 186 };
193 187
194 } // namespace file_system_provider 188 } // namespace file_system_provider
195 } // namespace chromeos 189 } // namespace chromeos
196 190
197 #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