Commit 8a3a9a3c authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions] Use v8 CreateDataProperty instead of DefineOwnProperty

v8::Object::CreateDataProperty is slightly more efficient than
v8::Object::DefineOwnProperty when no custom attributes are required.
Use CreateDataProperty instead in these cases.

Bug: None
Change-Id: I2674d6dd5b5f2d9bce8b932a2ee149633f6250a3
Reviewed-on: https://chromium-review.googlesource.com/897741Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534061}
parent bdc39893
...@@ -163,10 +163,10 @@ void ContentSetting::HandleFunction(const std::string& method_name, ...@@ -163,10 +163,10 @@ void ContentSetting::HandleFunction(const std::string& method_name,
// Deprecated settings are always set to "allow". Populate the result to // Deprecated settings are always set to "allow". Populate the result to
// avoid breaking extensions. // avoid breaking extensions.
v8::Local<v8::Object> object = v8::Object::New(isolate); v8::Local<v8::Object> object = v8::Object::New(isolate);
v8::Maybe<bool> result = object->DefineOwnProperty( v8::Maybe<bool> result = object->CreateDataProperty(
context, gin::StringToSymbol(isolate, "setting"), context, gin::StringToSymbol(isolate, "setting"),
gin::StringToSymbol(isolate, "allow")); gin::StringToSymbol(isolate, "allow"));
// Since we just defined this object, DefineOwnProperty() should never // Since we just defined this object, CreateDataProperty() should never
// fail. // fail.
CHECK(result.ToChecked()); CHECK(result.ToChecked());
args.push_back(object); args.push_back(object);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment