| Index: chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_service.h
|
| diff --git a/chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_service.h b/chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_service.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..334950fc5503e4b0d33a95fd8e19cb6cbcb9ee3a
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_service.h
|
| @@ -0,0 +1,102 @@
|
| +// Copyright 2015 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_FILE_SYSTEM_PLUGIN_PLUGIN_SERVICE_H_
|
| +#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILE_SYSTEM_PLUGIN_PLUGIN_SERVICE_H_
|
| +
|
| +#include "base/files/file.h"
|
| +#include "base/files/file_path.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/observer_list.h"
|
| +#include "base/threading/thread_checker.h"
|
| +#include "base/values.h"
|
| +#include "chrome/browser/chromeos/file_system_provider/file_system_plugin/provided_file_system_adapter.h"
|
| +#include "chrome/browser/chromeos/file_system_provider/observer.h"
|
| +#include "chrome/browser/chromeos/file_system_provider/provided_file_system_defs.h"
|
| +#include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h"
|
| +#include "chrome/browser/chromeos/file_system_provider/provided_file_system_observer.h"
|
| +#include "chrome/browser/chromeos/file_system_provider/watcher.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "components/keyed_service/core/keyed_service.h"
|
| +#include "content/public/browser/browser_context.h"
|
| +#include "storage/browser/fileapi/watcher_manager.h"
|
| +
|
| +namespace chromeos {
|
| +namespace file_system_provider {
|
| +
|
| +class ProvidedFileSystemInfo;
|
| +class ProvidedFileSystemInterface;
|
| +struct MountOptions;
|
| +
|
| +// Manages and registers the file system plugin provider service.
|
| +class PluginService : public KeyedService/*,
|
| + public ProvidedFileSystemObserver*/ {
|
| + public:
|
| + enum UnmountReason { UNMOUNT_REASON_USER, UNMOUNT_REASON_SHUTDOWN };
|
| + PluginService(Profile* profile);
|
| + ~PluginService() override;
|
| + base::File::Error MountFileSystem(
|
| + const std::string& source_id,
|
| + const MountOptions& options);
|
| + base::File::Error UnmountFileSystem( const std::string& source_id,
|
| + const std::string& file_system_id,
|
| + UnmountReason reason);
|
| +
|
| + // Adds and removes observers.
|
| + void AddObserver(Observer* observer);
|
| + void RemoveObserver(Observer* observer);
|
| + // Gets the singleton instance for the |context|.
|
| + static PluginService* Get(content::BrowserContext* context);
|
| + ProvidedFileSystemAdapter* GetProvidedFileSystemAdapter(
|
| + const std::string& plugin_id,
|
| + const std::string& file_system_id);
|
| + ProvidedFileSystemInterface* GetProvidedFileSystem(
|
| + const std::string& source_id,
|
| + const std::string& file_system_id);
|
| + // Returns a provided file system attached to the the passed
|
| + // |mount_point_name|. If not found, then returns NULL.
|
| + ProvidedFileSystemInterface* GetProvidedFileSystem(
|
| + const std::string& mount_point_name);
|
| + // Returns a list of information of all currently provided file systems. All
|
| + // items are copied.
|
| + std::vector<ProvidedFileSystemInfo> GetProvidedFileSystemInfoList();
|
| +// // ProvidedFileSystemInterface::Observer overrides.
|
| +// void OnWatcherChanged(const ProvidedFileSystemInfo& file_system_info,
|
| +// const Watcher& watcher,
|
| +// storage::WatcherManager::ChangeType change_type,
|
| +// const ProvidedFileSystemObserver::Changes& changes,
|
| +// const base::Closure& callback) override;
|
| +// void OnWatcherTagUpdated(const ProvidedFileSystemInfo& file_system_info,
|
| +// const Watcher& watcher) override;
|
| +// void OnWatcherListChanged(const ProvidedFileSystemInfo& file_system_info,
|
| +// const Watchers& watchers) override;
|
| + private:
|
| + base::File::Error MountFileSystemInternal(
|
| + const std::string& source_id,
|
| + const MountOptions& options,
|
| + MountContext context);
|
| + // Key is a pair of an extension id and file system id, which makes it
|
| + // unique among the entire service instance.
|
| + typedef std::pair<std::string, std::string> FileSystemKey;
|
| +
|
| + typedef std::map<FileSystemKey, ProvidedFileSystemAdapter*>
|
| + ProvidedFileSystemMap;
|
| + typedef std::map<std::string, FileSystemKey> MountPointNameToKeyMap;
|
| +
|
| + Profile* profile_;
|
| + base::ObserverList<Observer> observers_;
|
| + ProvidedFileSystemMap file_system_map_; // Owns pointers.
|
| + MountPointNameToKeyMap mount_point_name_to_key_map_;
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + base::WeakPtrFactory<PluginService> weak_ptr_factory_;
|
| + DISALLOW_COPY_AND_ASSIGN(PluginService);
|
| +};
|
| +
|
| +} // namespace file_system_provider
|
| +} // namespace chromeos
|
| +
|
| +#endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILE_SYSTEM_PLUGIN_PLUGIN_SERVICE_H_
|
| +
|
|
|