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

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

Issue 194693002: [fsp] Add requestUnmount() method together with the request manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed some too strict thread checks. Created 6 years, 8 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 <vector> 10 #include <vector>
11 11
12 #include "base/files/file.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
12 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/values.h"
13 #include "chrome/browser/chromeos/file_system_provider/observer.h" 17 #include "chrome/browser/chromeos/file_system_provider/observer.h"
18 #include "chrome/browser/chromeos/file_system_provider/request_manager.h"
14 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/extensions/api/file_system_provider.h" 20 #include "chrome/common/extensions/api/file_system_provider.h"
16 #include "components/keyed_service/core/keyed_service.h" 21 #include "components/keyed_service/core/keyed_service.h"
17 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
18 23
19 namespace chromeos { 24 namespace chromeos {
20 namespace file_system_provider { 25 namespace file_system_provider {
21 26
22 class ServiceFactory; 27 class ServiceFactory;
23 28
24 // Manages and registers the fileSystemProvider service. 29 // Manages and registers the fileSystemProvider service.
25 class Service : public KeyedService { 30 class Service : public KeyedService {
26 public: 31 public:
27 explicit Service(Profile* profile); 32 explicit Service(Profile* profile);
28 virtual ~Service(); 33 virtual ~Service();
29 34
30 // Registers a file system provided by an extension with the |extension_id|. 35 // Mounts a file system provided by an extension with the |extension_id|.
31 // For success, it returns a numeric file system id, which is an 36 // For success, it returns a numeric file system id, which is an
32 // auto-incremented non-zero value. For failures, it returns zero. 37 // auto-incremented non-zero value. For failures, it returns zero.
33 int RegisterFileSystem(const std::string& extension_id, 38 int MountFileSystem(const std::string& extension_id,
34 const std::string& file_system_name); 39 const std::string& file_system_name);
35 40
36 // Unregisters a file system with the specified |file_system_id| for the 41 // Unmounts a file system with the specified |file_system_id| for the
37 // |extension_id|. For success returns true, otherwise false. 42 // |extension_id|. For success returns true, otherwise false.
38 bool UnregisterFileSystem(const std::string& extension_id, 43 bool UnmountFileSystem(const std::string& extension_id, int file_system_id);
39 int file_system_id);
40 44
41 // Returns a list of currently registered file systems. All items are copied. 45 // Returns a list of currently mounted file systems. All items are copied.
42 std::vector<ProvidedFileSystem> GetRegisteredFileSystems(); 46 std::vector<ProvidedFileSystem> GetMountedFileSystems();
47
48 // Handles successful response for the |request_id|. If |has_next| is false,
49 // then the request is disposed, after handling the |response|. On error,
50 // returns false, and the request is disposed.
51 bool FulfillRequest(const std::string& extension_id,
52 int file_system_id,
53 int request_id,
54 scoped_ptr<base::DictionaryValue> result,
55 bool has_next);
56
57 // Handles error response for the |request_id|. If handling the error fails,
58 // returns false. Always disposes the request.
59 bool RejectRequest(const std::string& extension_id,
60 int file_system_id,
61 int request_id,
62 base::File::Error error);
63
64 // Requests unmounting of a file system with the passed |file_system_id|.
65 // Returns true is unmounting has been requested. False, if the request is
66 // invalid (eg. already unmounted).
67 bool RequestUnmount(int file_system_id);
43 68
44 // Adds and removes observers. 69 // Adds and removes observers.
45 void AddObserver(Observer* observer); 70 void AddObserver(Observer* observer);
46 void RemoveObserver(Observer* observer); 71 void RemoveObserver(Observer* observer);
47 72
48 // Gets the singleton instance for the |context|. 73 // Gets the singleton instance for the |context|.
49 static Service* Get(content::BrowserContext* context); 74 static Service* Get(content::BrowserContext* context);
50 75
76 // BrowserContextKeyedService overrides.
77 virtual void Shutdown() OVERRIDE;
78
51 private: 79 private:
52 typedef std::map<int, ProvidedFileSystem> FileSystemMap; 80 typedef std::map<int, ProvidedFileSystem> FileSystemMap;
53 81
82 // Called when the providing extension calls the success callback for the
83 // onUnmountRequested event.
84 void OnRequestUnmountError(const ProvidedFileSystem& file_system,
85 base::File::Error error);
86
87 RequestManager request_manager_;
54 Profile* profile_; 88 Profile* profile_;
55 ObserverList<Observer> observers_; 89 ObserverList<Observer> observers_;
56 FileSystemMap file_systems_; 90 FileSystemMap file_systems_;
57 int next_id_; 91 int next_id_;
92 base::WeakPtrFactory<Service> weak_ptr_factory_;
58 93
59 DISALLOW_COPY_AND_ASSIGN(Service); 94 DISALLOW_COPY_AND_ASSIGN(Service);
60 }; 95 };
61 96
62 } // namespace file_system_provider 97 } // namespace file_system_provider
63 } // namespace chromeos 98 } // namespace chromeos
64 99
65 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ 100 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698