| Index: chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_operation_router.h
|
| diff --git a/chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_operation_router.h b/chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_operation_router.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..09390785baeaf747ce5db21e83ef405bc7db2f9f
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_operation_router.h
|
| @@ -0,0 +1,79 @@
|
| +// 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_PLUGINEVENTROUTER_H_
|
| +#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILE_SYSTEM_PLUGIN_PLUGINEVENTROUTER_H_
|
| +
|
| +#include <map>
|
| +#include <set>
|
| +#include <string>
|
| +
|
| +#include "base/memory/linked_ptr.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/singleton.h"
|
| +#include "base/memory/weak_ptr.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/request_manager.h"
|
| +
|
| +template <typename T>
|
| +struct DefaultSingletonTraits;
|
| +
|
| +namespace extensions {
|
| +struct Event;
|
| +} // namespace extensions
|
| +
|
| +namespace chromeos {
|
| +namespace file_system_provider {
|
| +// Class that relays the
|
| +class PluginOperationRouter {
|
| + public:
|
| + class PluginOperationRouterClient {
|
| + virtual void OnDispatchOperationRequest(RequestType,
|
| + scoped_ptr<base::ListValue> request) = 0;
|
| + friend class PluginOperationRouter;
|
| + };
|
| +
|
| + static PluginOperationRouter* GetInstance();
|
| + // Register and array of events for a plugin
|
| + void AddOperationsForListener(const std::vector<RequestType>& operation_types,
|
| + PluginOperationRouterClient* plugin_ref,
|
| + const std::string& plugin_id);
|
| + // Register a single event for the plugin
|
| + void AddOperationForListener(RequestType operation_type,
|
| + PluginOperationRouterClient* plugin_ref,
|
| + const std::string& plugin_id);
|
| + // Remove an array of events at a time
|
| + void RemoveOperationsForListener(const std::vector<RequestType>&
|
| + operation_types,
|
| + const std::string& plugin_id);
|
| + // Remove a single event
|
| + void RemoveOperationForListener(RequestType operation_type,
|
| + const std::string& plugin_id);
|
| + // Does a specific plugin have the event registered
|
| + bool PluginHasOperationListener(RequestType operation_type,
|
| + const std::string& plugin_id);
|
| + void DispatchOperationToPlugin(const std::string& plugin_id,
|
| + scoped_ptr<extensions::Event> request);
|
| +
|
| + private:
|
| + PluginOperationRouter();
|
| + ~PluginOperationRouter();
|
| + friend struct DefaultSingletonTraits<PluginOperationRouter>;
|
| +
|
| + // map[ [event_name] -> map[ [pluginIdX]->PluginEventRouterClient* ] ]
|
| + typedef std::map<std::string, PluginOperationRouterClient*> PluginInstances;
|
| + typedef PluginInstances::iterator PluginInstancesIterator;
|
| + typedef std::map<RequestType, PluginInstances> OperationsList;
|
| + typedef OperationsList::iterator OperationsListIterator;
|
| + OperationsList listOfListenedEvents_;
|
| +
|
| + base::WeakPtrFactory<PluginOperationRouter> weak_ptr_factory_;
|
| + DISALLOW_COPY_AND_ASSIGN(PluginOperationRouter);
|
| +};
|
| +} // namespace file_system_provider
|
| +} // namespace chromeos
|
| +
|
| +#endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILE_SYSTEM_PLUGIN_PLUGINEVENTROUTER_H_
|
|
|