OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ |
6 #define EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ | 6 #define EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 19 matching lines...) Expand all Loading... |
30 // for Extension APIs. Designed to be used on a single thread, but safe between | 30 // for Extension APIs. Designed to be used on a single thread, but safe between |
31 // multiple v8::Contexts. | 31 // multiple v8::Contexts. |
32 class APIBindingsSystem { | 32 class APIBindingsSystem { |
33 public: | 33 public: |
34 using GetAPISchemaMethod = | 34 using GetAPISchemaMethod = |
35 base::Callback<const base::DictionaryValue&(const std::string&)>; | 35 base::Callback<const base::DictionaryValue&(const std::string&)>; |
36 | 36 |
37 APIBindingsSystem(const binding::RunJSFunction& call_js, | 37 APIBindingsSystem(const binding::RunJSFunction& call_js, |
38 const binding::RunJSFunctionSync& call_js_sync, | 38 const binding::RunJSFunctionSync& call_js_sync, |
39 const GetAPISchemaMethod& get_api_schema, | 39 const GetAPISchemaMethod& get_api_schema, |
40 const APIBinding::SendRequestMethod& send_request, | 40 const APIRequestHandler::SendRequestMethod& send_request, |
41 const APIEventHandler::EventListenersChangedMethod& | 41 const APIEventHandler::EventListenersChangedMethod& |
42 event_listeners_changed, | 42 event_listeners_changed, |
43 APILastError last_error); | 43 APILastError last_error); |
44 ~APIBindingsSystem(); | 44 ~APIBindingsSystem(); |
45 | 45 |
46 // Returns a new v8::Object representing the api specified by |api_name|. | 46 // Returns a new v8::Object representing the api specified by |api_name|. |
47 v8::Local<v8::Object> CreateAPIInstance( | 47 v8::Local<v8::Object> CreateAPIInstance( |
48 const std::string& api_name, | 48 const std::string& api_name, |
49 v8::Local<v8::Context> context, | 49 v8::Local<v8::Context> context, |
50 v8::Isolate* isolate, | 50 v8::Isolate* isolate, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 std::map<std::string, std::unique_ptr<APIBindingHooks>> binding_hooks_; | 99 std::map<std::string, std::unique_ptr<APIBindingHooks>> binding_hooks_; |
100 | 100 |
101 binding::RunJSFunction call_js_; | 101 binding::RunJSFunction call_js_; |
102 | 102 |
103 binding::RunJSFunctionSync call_js_sync_; | 103 binding::RunJSFunctionSync call_js_sync_; |
104 | 104 |
105 // The method to retrieve the DictionaryValue describing a given extension | 105 // The method to retrieve the DictionaryValue describing a given extension |
106 // API. Curried in for testing purposes so we can use fake APIs. | 106 // API. Curried in for testing purposes so we can use fake APIs. |
107 GetAPISchemaMethod get_api_schema_; | 107 GetAPISchemaMethod get_api_schema_; |
108 | 108 |
109 // The method to call when a new API call is triggered. Curried in for testing | |
110 // purposes. Typically, this would send an IPC to the browser to begin the | |
111 // function work. | |
112 APIBinding::SendRequestMethod send_request_; | |
113 | |
114 DISALLOW_COPY_AND_ASSIGN(APIBindingsSystem); | 109 DISALLOW_COPY_AND_ASSIGN(APIBindingsSystem); |
115 }; | 110 }; |
116 | 111 |
117 } // namespace | 112 } // namespace |
118 | 113 |
119 #endif // EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ | 114 #endif // EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ |
OLD | NEW |