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

Unified 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: Simplified. 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 side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..16ef6356f2b02a131f8970e15e3a623edc0b4c63
--- /dev/null
+++ b/chrome/browser/chromeos/file_system_provider/service.h
@@ -0,0 +1,67 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_
+#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/observer_list.h"
+#include "chrome/browser/chromeos/file_system_provider/observer.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/file_system_provider.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "content/public/browser/browser_context.h"
+
+namespace chromeos {
+namespace file_system_provider {
+
+class ServiceFactory;
+
+// Manages and registers the fileSystemProvider service.
+class Service : public KeyedService {
+ public:
+ explicit Service(Profile* profile);
+ virtual ~Service();
+
+ // Registers a file system provided by an extension with the |extension_id|.
+ // For success, it returns a file system id, which is of the following format:
+ // |extension_id|-unique-hash, where unique is an auto-incremented non-zero
+ // number, and hash is the user profile hash.
+ // For failures, it returns an empty string.
+ std::string RegisterFileSystem(const std::string& extension_id,
+ const std::string& file_system_name);
+
+ // Unregisters a file system with the specified |file_system_id| for the
+ // |extension_id|. For success returns true, otherwise false.
+ bool UnregisterFileSystem(const std::string& extension_id,
+ const std::string& file_system_id);
+
+ // Returns a list of currently registered file systems. All items are copied.
+ std::vector<ProvidedFileSystem> GetRegisteredFileSystems();
+
+ // Adds and removes observers.
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ // Gets the singleton instance for the |context|.
+ static Service* Get(content::BrowserContext* context);
+
+ private:
+ typedef std::map<std::string, ProvidedFileSystem> FileSystemMap;
+
+ Profile* profile_;
+ ObserverList<Observer> observers_;
+ FileSystemMap file_systems_;
+ int next_handle_;
+
+ DISALLOW_COPY_AND_ASSIGN(Service);
+};
+
+} // namespace file_system_provider
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698