OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_FILE_SYSTEM_PLUGIN_PLUGINEV
ENTROUTER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILE_SYSTEM_PLUGIN_PLUGINEV
ENTROUTER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 #include <string> |
| 11 |
| 12 #include "base/memory/linked_ptr.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/singleton.h" |
| 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/values.h" |
| 17 |
| 18 #include "chrome/browser/chromeos/file_system_provider/file_system_plugin/provid
ed_file_system_adapter.h" |
| 19 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" |
| 20 |
| 21 template <typename T> |
| 22 struct DefaultSingletonTraits; |
| 23 |
| 24 namespace extensions { |
| 25 struct Event; |
| 26 } // namespace extensions |
| 27 |
| 28 namespace chromeos { |
| 29 namespace file_system_provider { |
| 30 // Class that relays the |
| 31 class PluginOperationRouter { |
| 32 public: |
| 33 class PluginOperationRouterClient { |
| 34 virtual void OnDispatchOperationRequest(RequestType, |
| 35 scoped_ptr<base::ListValue> request) = 0; |
| 36 friend class PluginOperationRouter; |
| 37 }; |
| 38 |
| 39 static PluginOperationRouter* GetInstance(); |
| 40 // Register and array of events for a plugin |
| 41 void AddOperationsForListener(const std::vector<RequestType>& operation_types, |
| 42 PluginOperationRouterClient* plugin_ref, |
| 43 const std::string& plugin_id); |
| 44 // Register a single event for the plugin |
| 45 void AddOperationForListener(RequestType operation_type, |
| 46 PluginOperationRouterClient* plugin_ref, |
| 47 const std::string& plugin_id); |
| 48 // Remove an array of events at a time |
| 49 void RemoveOperationsForListener(const std::vector<RequestType>& |
| 50 operation_types, |
| 51 const std::string& plugin_id); |
| 52 // Remove a single event |
| 53 void RemoveOperationForListener(RequestType operation_type, |
| 54 const std::string& plugin_id); |
| 55 // Does a specific plugin have the event registered |
| 56 bool PluginHasOperationListener(RequestType operation_type, |
| 57 const std::string& plugin_id); |
| 58 void DispatchOperationToPlugin(const std::string& plugin_id, |
| 59 scoped_ptr<extensions::Event> request); |
| 60 |
| 61 private: |
| 62 PluginOperationRouter(); |
| 63 ~PluginOperationRouter(); |
| 64 friend struct DefaultSingletonTraits<PluginOperationRouter>; |
| 65 |
| 66 // map[ [event_name] -> map[ [pluginIdX]->PluginEventRouterClient* ] ] |
| 67 typedef std::map<std::string, PluginOperationRouterClient*> PluginInstances; |
| 68 typedef PluginInstances::iterator PluginInstancesIterator; |
| 69 typedef std::map<RequestType, PluginInstances> OperationsList; |
| 70 typedef OperationsList::iterator OperationsListIterator; |
| 71 OperationsList listOfListenedEvents_; |
| 72 |
| 73 base::WeakPtrFactory<PluginOperationRouter> weak_ptr_factory_; |
| 74 DISALLOW_COPY_AND_ASSIGN(PluginOperationRouter); |
| 75 }; |
| 76 } // namespace file_system_provider |
| 77 } // namespace chromeos |
| 78 |
| 79 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILE_SYSTEM_PLUGIN_PLUGI
NEVENTROUTER_H_ |
OLD | NEW |