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

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

Issue 334263017: [fsp] Remember mounted file systems as soon as possible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated a comment. Created 6 years, 5 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 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Manages and registers the file system provider service. Maintains provided 51 // Manages and registers the file system provider service. Maintains provided
52 // file systems. 52 // file systems.
53 class Service : public KeyedService, 53 class Service : public KeyedService,
54 public extensions::ExtensionRegistryObserver { 54 public extensions::ExtensionRegistryObserver {
55 public: 55 public:
56 typedef base::Callback<ProvidedFileSystemInterface*( 56 typedef base::Callback<ProvidedFileSystemInterface*(
57 Profile* profile, 57 Profile* profile,
58 const ProvidedFileSystemInfo& file_system_info)> 58 const ProvidedFileSystemInfo& file_system_info)>
59 FileSystemFactoryCallback; 59 FileSystemFactoryCallback;
60 60
61 // Reason for unmounting. In case of UNMOUNT_REASON_SHUTDOWN, the file system
62 // will be remounted automatically after a reboot. In case of
63 // UNMOUNT_REASON_USER it will be permanently unmounted.
64 enum UnmountReason { UNMOUNT_REASON_USER, UNMOUNT_REASON_SHUTDOWN };
65
61 Service(Profile* profile, extensions::ExtensionRegistry* extension_registry); 66 Service(Profile* profile, extensions::ExtensionRegistry* extension_registry);
62 virtual ~Service(); 67 virtual ~Service();
63 68
64 // Sets a custom ProvidedFileSystemInterface factory. Used by unit tests, 69 // Sets a custom ProvidedFileSystemInterface factory. Used by unit tests,
65 // where an event router is not available. 70 // where an event router is not available.
66 void SetFileSystemFactoryForTesting( 71 void SetFileSystemFactoryForTesting(
67 const FileSystemFactoryCallback& factory_callback); 72 const FileSystemFactoryCallback& factory_callback);
68 73
69 // Mounts a file system provided by an extension with the |extension_id|. 74 // Mounts a file system provided by an extension with the |extension_id|.
70 // For success, returns true, otherwise false. 75 // For success, returns true, otherwise false.
71 bool MountFileSystem(const std::string& extension_id, 76 bool MountFileSystem(const std::string& extension_id,
72 const std::string& file_system_id, 77 const std::string& file_system_id,
73 const std::string& display_name); 78 const std::string& display_name);
74 79
75 // Unmounts a file system with the specified |file_system_id| for the 80 // Unmounts a file system with the specified |file_system_id| for the
76 // |extension_id|. For success returns true, otherwise false. 81 // |extension_id|. For success returns true, otherwise false.
77 bool UnmountFileSystem(const std::string& extension_id, 82 bool UnmountFileSystem(const std::string& extension_id,
78 const std::string& file_system_id); 83 const std::string& file_system_id,
84 UnmountReason reason);
79 85
80 // Requests unmounting of the file system. The callback is called when the 86 // Requests unmounting of the file system. The callback is called when the
81 // request is accepted or rejected, with an error code. Returns false if the 87 // request is accepted or rejected, with an error code. Returns false if the
82 // request could not been created, true otherwise. 88 // request could not been created, true otherwise.
83 bool RequestUnmount(const std::string& extension_id, 89 bool RequestUnmount(const std::string& extension_id,
84 const std::string& file_system_id); 90 const std::string& file_system_id);
85 91
86 // Returns a list of information of all currently provided file systems. All 92 // Returns a list of information of all currently provided file systems. All
87 // items are copied. 93 // items are copied.
88 std::vector<ProvidedFileSystemInfo> GetProvidedFileSystemInfoList(); 94 std::vector<ProvidedFileSystemInfo> GetProvidedFileSystemInfoList();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 127
122 typedef std::map<FileSystemKey, ProvidedFileSystemInterface*> 128 typedef std::map<FileSystemKey, ProvidedFileSystemInterface*>
123 ProvidedFileSystemMap; 129 ProvidedFileSystemMap;
124 typedef std::map<std::string, FileSystemKey> MountPointNameToKeyMap; 130 typedef std::map<std::string, FileSystemKey> MountPointNameToKeyMap;
125 131
126 // Called when the providing extension accepts or refuses a unmount request. 132 // Called when the providing extension accepts or refuses a unmount request.
127 // If |error| is equal to FILE_OK, then the request is accepted. 133 // If |error| is equal to FILE_OK, then the request is accepted.
128 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, 134 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info,
129 base::File::Error error); 135 base::File::Error error);
130 136
131 // Saves a list of currently mounted file systems to preferences. Called 137 // Remembers the file system in preferences, in order to remount after a
132 // from a destructor (on shutdown). 138 // reboot.
133 void RememberFileSystems(); 139 void RememberFileSystem(const ProvidedFileSystemInfo& file_system_info);
134 140
135 // Removes all of the file systems mounted by the |extension_id| from 141 // Removes the file system from preferences, so it is not remounmted anymore
136 // preferences, so they are not loaded again after reboot. 142 // after a reboot.
137 void ForgetFileSystems(const std::string& extension_id); 143 void ForgetFileSystem(const std::string& extension_id,
144 const std::string& file_system_id);
138 145
139 // Restores from preferences file systems mounted previously by the 146 // Restores from preferences file systems mounted previously by the
140 // |extension_id| providing extension. 147 // |extension_id| providing extension.
141 void RestoreFileSystems(const std::string& extension_id); 148 void RestoreFileSystems(const std::string& extension_id);
142 149
143 Profile* profile_; 150 Profile* profile_;
144 extensions::ExtensionRegistry* extension_registry_; // Not owned. 151 extensions::ExtensionRegistry* extension_registry_; // Not owned.
145 FileSystemFactoryCallback file_system_factory_; 152 FileSystemFactoryCallback file_system_factory_;
146 ObserverList<Observer> observers_; 153 ObserverList<Observer> observers_;
147 ProvidedFileSystemMap file_system_map_; // Owns pointers. 154 ProvidedFileSystemMap file_system_map_; // Owns pointers.
148 MountPointNameToKeyMap mount_point_name_to_key_map_; 155 MountPointNameToKeyMap mount_point_name_to_key_map_;
149 base::ThreadChecker thread_checker_; 156 base::ThreadChecker thread_checker_;
150 base::WeakPtrFactory<Service> weak_ptr_factory_; 157 base::WeakPtrFactory<Service> weak_ptr_factory_;
151 158
152 DISALLOW_COPY_AND_ASSIGN(Service); 159 DISALLOW_COPY_AND_ASSIGN(Service);
153 }; 160 };
154 161
155 } // namespace file_system_provider 162 } // namespace file_system_provider
156 } // namespace chromeos 163 } // namespace chromeos
157 164
158 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ 165 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698