Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: extensions/renderer/api_request_handler.cc

Issue 2575173002: [Extensions Bindings] Add a bridge to use current custom bindings (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 auto iter = pending_requests_.find(request_id); 48 auto iter = pending_requests_.find(request_id);
49 // The request may have been removed if the context was invalidated before a 49 // The request may have been removed if the context was invalidated before a
50 // response is ready. 50 // response is ready.
51 if (iter == pending_requests_.end()) 51 if (iter == pending_requests_.end())
52 return; 52 return;
53 53
54 PendingRequest pending_request = std::move(iter->second); 54 PendingRequest pending_request = std::move(iter->second);
55 pending_requests_.erase(iter); 55 pending_requests_.erase(iter);
56 56
57 v8::Isolate* isolate = pending_request.isolate; 57 v8::Isolate* isolate = pending_request.isolate;
58 v8::HandleScope handle_scope(isolate);
58 v8::Local<v8::Context> context = pending_request.context.Get(isolate); 59 v8::Local<v8::Context> context = pending_request.context.Get(isolate);
59 std::unique_ptr<content::V8ValueConverter> converter( 60 std::unique_ptr<content::V8ValueConverter> converter(
60 content::V8ValueConverter::create()); 61 content::V8ValueConverter::create());
61 std::vector<v8::Local<v8::Value>> args; 62 std::vector<v8::Local<v8::Value>> args;
62 args.reserve(response_args.GetSize()); 63 args.reserve(response_args.GetSize());
63 for (const auto& response : response_args) 64 for (const auto& response : response_args)
64 args.push_back(converter->ToV8Value(response.get(), context)); 65 args.push_back(converter->ToV8Value(response.get(), context));
65 66
66 // args.size() is converted to int, but args is controlled by chrome and is 67 // args.size() is converted to int, but args is controlled by chrome and is
67 // never close to std::numeric_limits<int>::max. 68 // never close to std::numeric_limits<int>::max.
(...skipping 12 matching lines...) Expand all
80 } 81 }
81 82
82 std::set<int> APIRequestHandler::GetPendingRequestIdsForTesting() const { 83 std::set<int> APIRequestHandler::GetPendingRequestIdsForTesting() const {
83 std::set<int> result; 84 std::set<int> result;
84 for (const auto& pair : pending_requests_) 85 for (const auto& pair : pending_requests_)
85 result.insert(pair.first); 86 result.insert(pair.first);
86 return result; 87 return result;
87 } 88 }
88 89
89 } // namespace extensions 90 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/api_bindings_system_unittest.cc ('k') | extensions/renderer/module_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698