| 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 #include "extensions/renderer/api_request_handler.h" | 5 #include "extensions/renderer/api_request_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/guid.h" | 8 #include "base/guid.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (iter == pending_requests_.end()) | 119 if (iter == pending_requests_.end()) |
| 120 return; | 120 return; |
| 121 | 121 |
| 122 PendingRequest pending_request = std::move(iter->second); | 122 PendingRequest pending_request = std::move(iter->second); |
| 123 pending_requests_.erase(iter); | 123 pending_requests_.erase(iter); |
| 124 | 124 |
| 125 v8::Isolate* isolate = pending_request.isolate; | 125 v8::Isolate* isolate = pending_request.isolate; |
| 126 v8::HandleScope handle_scope(isolate); | 126 v8::HandleScope handle_scope(isolate); |
| 127 v8::Local<v8::Context> context = pending_request.context.Get(isolate); | 127 v8::Local<v8::Context> context = pending_request.context.Get(isolate); |
| 128 v8::Context::Scope context_scope(context); | 128 v8::Context::Scope context_scope(context); |
| 129 std::unique_ptr<content::V8ValueConverter> converter( | 129 std::unique_ptr<content::V8ValueConverter> converter = |
| 130 content::V8ValueConverter::create()); | 130 content::V8ValueConverter::Create(); |
| 131 std::vector<v8::Local<v8::Value>> args; | 131 std::vector<v8::Local<v8::Value>> args; |
| 132 args.reserve(response_args.GetSize() + | 132 args.reserve(response_args.GetSize() + |
| 133 pending_request.callback_arguments.size()); | 133 pending_request.callback_arguments.size()); |
| 134 for (const auto& arg : pending_request.callback_arguments) | 134 for (const auto& arg : pending_request.callback_arguments) |
| 135 args.push_back(arg.Get(isolate)); | 135 args.push_back(arg.Get(isolate)); |
| 136 for (const auto& arg : response_args) | 136 for (const auto& arg : response_args) |
| 137 args.push_back(converter->ToV8Value(&arg, context)); | 137 args.push_back(converter->ToV8Value(&arg, context)); |
| 138 | 138 |
| 139 blink::WebScopedUserGesture user_gesture(pending_request.user_gesture_token); | 139 blink::WebScopedUserGesture user_gesture(pending_request.user_gesture_token); |
| 140 if (!error.empty()) | 140 if (!error.empty()) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 169 } | 169 } |
| 170 | 170 |
| 171 std::set<int> APIRequestHandler::GetPendingRequestIdsForTesting() const { | 171 std::set<int> APIRequestHandler::GetPendingRequestIdsForTesting() const { |
| 172 std::set<int> result; | 172 std::set<int> result; |
| 173 for (const auto& pair : pending_requests_) | 173 for (const auto& pair : pending_requests_) |
| 174 result.insert(pair.first); | 174 result.insert(pair.first); |
| 175 return result; | 175 return result; |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace extensions | 178 } // namespace extensions |
| OLD | NEW |