Chromium Code Reviews| Index: chrome/browser/chromeos/file_system_provider/service.h |
| diff --git a/chrome/browser/chromeos/file_system_provider/service.h b/chrome/browser/chromeos/file_system_provider/service.h |
| index 735e05fb9bf14f79a37f67a34639838da72c7a7e..cd1c57dbbd02f4edd713fbcb5c0bcca401c34ba7 100644 |
| --- a/chrome/browser/chromeos/file_system_provider/service.h |
| +++ b/chrome/browser/chromeos/file_system_provider/service.h |
| @@ -24,14 +24,28 @@ |
| namespace chromeos { |
| namespace file_system_provider { |
| +class ProvidedFileSystemFactoryInterface; |
| +class ProvidedFileSystemInfo; |
| +class ProvidedFileSystemInterface; |
| class ServiceFactory; |
| -// Manages and registers the fileSystemProvider service. |
| +// Manages and registers the file system provider service. Maintains provided |
| +// file systems. |
| +// |
| +// Internally creates ProvidedFileSystem instances which require a browser |
| +// running. For unit tests, create with a custom factory (in most cases |
| +// FakeProvidedFileSystemFactory will do) via CreateForTesting(). |
| class Service : public KeyedService { |
| public: |
| explicit Service(Profile* profile); |
| virtual ~Service(); |
| + // Creates a service instance for tests. Takes ownership on the |
| + // |file_system_factory| instance. |
|
hashimoto
2014/04/15 07:22:45
scoped_ptr always takes the ownership.
No need to
mtomasz
2014/04/15 09:42:12
Done.
|
| + static Service* CreateForTesting( |
| + Profile* profile, |
| + scoped_ptr<ProvidedFileSystemFactoryInterface> file_system_factory); |
| + |
| // Mounts a file system provided by an extension with the |extension_id|. |
| // For success, it returns a numeric file system id, which is an |
| // auto-incremented non-zero value. For failures, it returns zero. |
| @@ -42,30 +56,21 @@ class Service : public KeyedService { |
| // |extension_id|. For success returns true, otherwise false. |
| bool UnmountFileSystem(const std::string& extension_id, int file_system_id); |
| - // Returns a list of currently mounted file systems. All items are copied. |
| - std::vector<ProvidedFileSystem> GetMountedFileSystems(); |
| - |
| - // Handles successful response for the |request_id|. If |has_next| is false, |
| - // then the request is disposed, after handling the |response|. On error, |
| - // returns false, and the request is disposed. |
| - bool FulfillRequest(const std::string& extension_id, |
| - int file_system_id, |
| - int request_id, |
| - scoped_ptr<base::DictionaryValue> result, |
| - bool has_next); |
| - |
| - // Handles error response for the |request_id|. If handling the error fails, |
| - // returns false. Always disposes the request. |
| - bool RejectRequest(const std::string& extension_id, |
| - int file_system_id, |
| - int request_id, |
| - base::File::Error error); |
| - |
| - // Requests unmounting of a file system with the passed |file_system_id|. |
| - // Returns true is unmounting has been requested. False, if the request is |
| - // invalid (eg. already unmounted). |
| + // Requests unmounting of the file system. The callback is called when the |
| + // request is accepted or rejected, with an error code. Returns false if the |
| + // request could not been created, true otherwise. |
| bool RequestUnmount(int file_system_id); |
| + // Returns a list of information of all currently provided file systems. All |
| + // items are copied. |
| + std::vector<ProvidedFileSystemInfo> GetProvidedFileSystemInfoList(); |
| + |
| + // Returns a provided file system with |file_system_id|, handled by |
| + // the extension with |extension_id|. If not found, then returns NULL. |
| + ProvidedFileSystemInterface* GetProvidedFileSystem( |
| + const std::string& extension_id, |
| + int file_system_id); |
| + |
| // Adds and removes observers. |
| void AddObserver(Observer* observer); |
| void RemoveObserver(Observer* observer); |
| @@ -76,18 +81,28 @@ class Service : public KeyedService { |
| // BrowserContextKeyedService overrides. |
| virtual void Shutdown() OVERRIDE; |
| + // Getter for the request manager. Used by the extension API to forward |
| + // replies. Valid as long as the service. |
| + RequestManager* request_manager() { return &request_manager_; } |
| + |
| private: |
| - typedef std::map<int, ProvidedFileSystem> FileSystemMap; |
| + typedef std::map<int, ProvidedFileSystemInterface*> ProvidedFileSystemMap; |
| + |
| + // Creates a service with a custom factory. Takes ownership on the |
| + // |file_system_factory| instance. |
| + Service(Profile* profile, |
| + scoped_ptr<ProvidedFileSystemFactoryInterface> file_system_factory); |
| - // Called when the providing extension calls the success callback for the |
| - // onUnmountRequested event. |
| - void OnRequestUnmountError(const ProvidedFileSystem& file_system, |
| - base::File::Error error); |
| + // Called when the providing extension accepts or refuses a unmount request. |
| + // If |error| is equal to FILE_OK, then the request is accepted. |
| + void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, |
| + base::File::Error error); |
| RequestManager request_manager_; |
| Profile* profile_; |
| + scoped_ptr<ProvidedFileSystemFactoryInterface> file_system_factory_; |
| ObserverList<Observer> observers_; |
| - FileSystemMap file_systems_; |
| + ProvidedFileSystemMap file_system_map_; // Owns pointers. |
| int next_id_; |
| base::WeakPtrFactory<Service> weak_ptr_factory_; |