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

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

Issue 192573002: [fsp] Introduce file_system_provider::Service class for the FileSystemProvider API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 6 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "base/observer_list.h"
13 #include "chrome/browser/chromeos/file_system_provider/observer.h"
14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/extensions/api/file_system_provider.h"
16 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
17 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h"
18 #include "content/public/browser/browser_context.h"
19
20 namespace chromeos {
21 namespace file_system_provider {
22
23 class ServiceFactory;
24
25 // Manages and registers the fileSystemProvider service.
26 class Service : public BrowserContextKeyedService {
27 public:
28 explicit Service(Profile* profile);
29 virtual ~Service();
30
31 // Registers a file system provided by an extension with the |extension_id|.
32 // For success, it returns a file system id, which is of the following format:
33 // |extension_id|-unique-hash, where unique is an auto-incremented non-zero
34 // number, and hash is the user profile hash.
35 // For failures, it returns an empty string.
36 std::string RegisterFileSystem(const std::string& extension_id,
37 const std::string& file_system_name);
38
39 // Unregisters a file system with the specified |file_system_id| for the
40 // |extension_id|. For success returns true, otherwise false.
41 bool UnregisterFileSystem(const std::string& extension_id,
42 const std::string& file_system_id);
43
44 // Returns a list of currently registered file systems. All items are copied.
45 std::vector<ProvidedFileSystem> GetRegisteredFileSystems();
46
47 // Adds and removes observers.
48 void AddObserver(Observer* observer);
49 void RemoveObserver(Observer* observer);
50
51 // Gets the singleton instance for the |context|.
52 static Service* Get(content::BrowserContext* context);
53
54 private:
55 typedef std::map<std::string, ProvidedFileSystem> FileSystemMap;
56
57 Profile* profile_;
58 ObserverList<Observer> observers_;
59 FileSystemMap file_systems_;
60 int next_handle_;
61
62 DISALLOW_COPY_AND_ASSIGN(Service);
63 };
64
65 } // namespace file_system_provider
66 } // namespace chromeos
67
68 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698