| 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_REQUEST_HANDLER_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_REQUEST_HANDLER_H_ |
| 6 #define EXTENSIONS_RENDERER_API_REQUEST_HANDLER_H_ | 6 #define EXTENSIONS_RENDERER_API_REQUEST_HANDLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // Responds to the request with the given |request_id|, calling the callback | 67 // Responds to the request with the given |request_id|, calling the callback |
| 68 // with the given |response| arguments. | 68 // with the given |response| arguments. |
| 69 // Invalid ids are ignored. | 69 // Invalid ids are ignored. |
| 70 void CompleteRequest(int request_id, | 70 void CompleteRequest(int request_id, |
| 71 const base::ListValue& response, | 71 const base::ListValue& response, |
| 72 const std::string& error); | 72 const std::string& error); |
| 73 | 73 |
| 74 // Invalidates any requests that are associated with |context|. | 74 // Invalidates any requests that are associated with |context|. |
| 75 void InvalidateContext(v8::Local<v8::Context> context); | 75 void InvalidateContext(v8::Local<v8::Context> context); |
| 76 | 76 |
| 77 APILastError* last_error() { return &last_error_; } |
| 78 |
| 77 std::set<int> GetPendingRequestIdsForTesting() const; | 79 std::set<int> GetPendingRequestIdsForTesting() const; |
| 78 | 80 |
| 79 private: | 81 private: |
| 80 struct PendingRequest { | 82 struct PendingRequest { |
| 81 PendingRequest(v8::Isolate* isolate, | 83 PendingRequest(v8::Isolate* isolate, |
| 82 v8::Local<v8::Function> callback, | 84 v8::Local<v8::Function> callback, |
| 83 v8::Local<v8::Context> context, | 85 v8::Local<v8::Context> context, |
| 84 const std::vector<v8::Local<v8::Value>>& callback_args); | 86 const std::vector<v8::Local<v8::Value>>& callback_args); |
| 85 ~PendingRequest(); | 87 ~PendingRequest(); |
| 86 PendingRequest(PendingRequest&&); | 88 PendingRequest(PendingRequest&&); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 108 CallJSFunction call_js_; | 110 CallJSFunction call_js_; |
| 109 | 111 |
| 110 APILastError last_error_; | 112 APILastError last_error_; |
| 111 | 113 |
| 112 DISALLOW_COPY_AND_ASSIGN(APIRequestHandler); | 114 DISALLOW_COPY_AND_ASSIGN(APIRequestHandler); |
| 113 }; | 115 }; |
| 114 | 116 |
| 115 } // namespace extensions | 117 } // namespace extensions |
| 116 | 118 |
| 117 #endif // EXTENSIONS_RENDERER_API_REQUEST_HANDLER_H_ | 119 #endif // EXTENSIONS_RENDERER_API_REQUEST_HANDLER_H_ |
| OLD | NEW |