OLD | NEW |
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 <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
13 #include "base/files/file_path.h" | |
14 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
17 #include "base/values.h" | 16 #include "base/values.h" |
18 #include "chrome/browser/chromeos/file_system_provider/observer.h" | 17 #include "chrome/browser/chromeos/file_system_provider/observer.h" |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/common/extensions/api/file_system_provider.h" | 19 #include "chrome/common/extensions/api/file_system_provider.h" |
21 #include "components/keyed_service/core/keyed_service.h" | 20 #include "components/keyed_service/core/keyed_service.h" |
22 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
23 | 22 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // Returns a list of information of all currently provided file systems. All | 67 // Returns a list of information of all currently provided file systems. All |
69 // items are copied. | 68 // items are copied. |
70 std::vector<ProvidedFileSystemInfo> GetProvidedFileSystemInfoList(); | 69 std::vector<ProvidedFileSystemInfo> GetProvidedFileSystemInfoList(); |
71 | 70 |
72 // Returns a provided file system with |file_system_id|, handled by | 71 // Returns a provided file system with |file_system_id|, handled by |
73 // the extension with |extension_id|. If not found, then returns NULL. | 72 // the extension with |extension_id|. If not found, then returns NULL. |
74 ProvidedFileSystemInterface* GetProvidedFileSystem( | 73 ProvidedFileSystemInterface* GetProvidedFileSystem( |
75 const std::string& extension_id, | 74 const std::string& extension_id, |
76 int file_system_id); | 75 int file_system_id); |
77 | 76 |
78 // Returns a provided file system attached to the the passed | |
79 // |mount_point_name|. If not found, then returns NULL. | |
80 ProvidedFileSystemInterface* GetProvidedFileSystem( | |
81 const std::string& mount_point_name); | |
82 | |
83 // Adds and removes observers. | 77 // Adds and removes observers. |
84 void AddObserver(Observer* observer); | 78 void AddObserver(Observer* observer); |
85 void RemoveObserver(Observer* observer); | 79 void RemoveObserver(Observer* observer); |
86 | 80 |
87 // Gets the singleton instance for the |context|. | 81 // Gets the singleton instance for the |context|. |
88 static Service* Get(content::BrowserContext* context); | 82 static Service* Get(content::BrowserContext* context); |
89 | 83 |
90 // BrowserContextKeyedService overrides. | 84 // BrowserContextKeyedService overrides. |
91 virtual void Shutdown() OVERRIDE; | 85 virtual void Shutdown() OVERRIDE; |
92 | 86 |
93 private: | 87 private: |
94 typedef std::map<int, ProvidedFileSystemInterface*> ProvidedFileSystemMap; | 88 typedef std::map<int, ProvidedFileSystemInterface*> ProvidedFileSystemMap; |
95 typedef std::map<std::string, int> MountPointNameToIdMap; | |
96 | 89 |
97 // Called when the providing extension accepts or refuses a unmount request. | 90 // Called when the providing extension accepts or refuses a unmount request. |
98 // If |error| is equal to FILE_OK, then the request is accepted. | 91 // If |error| is equal to FILE_OK, then the request is accepted. |
99 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, | 92 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, |
100 base::File::Error error); | 93 base::File::Error error); |
101 | 94 |
102 Profile* profile_; | 95 Profile* profile_; |
103 FileSystemFactoryCallback file_system_factory_; | 96 FileSystemFactoryCallback file_system_factory_; |
104 ObserverList<Observer> observers_; | 97 ObserverList<Observer> observers_; |
105 ProvidedFileSystemMap file_system_map_; // Owns pointers. | 98 ProvidedFileSystemMap file_system_map_; // Owns pointers. |
106 MountPointNameToIdMap mount_point_name_to_id_map_; | |
107 int next_id_; | 99 int next_id_; |
108 base::WeakPtrFactory<Service> weak_ptr_factory_; | 100 base::WeakPtrFactory<Service> weak_ptr_factory_; |
109 | 101 |
110 DISALLOW_COPY_AND_ASSIGN(Service); | 102 DISALLOW_COPY_AND_ASSIGN(Service); |
111 }; | 103 }; |
112 | 104 |
113 } // namespace file_system_provider | 105 } // namespace file_system_provider |
114 } // namespace chromeos | 106 } // namespace chromeos |
115 | 107 |
116 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ | 108 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
OLD | NEW |