Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/JsValue.cpp

Issue 29369520: Issue #4692 - Rewrite web request task to avoid engine self-reference
Patch Set: Created Dec. 24, 2016, 4:58 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/JsEngine.cpp ('k') | src/Value.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/JsValue.cpp
===================================================================
--- a/src/JsValue.cpp
+++ b/src/JsValue.cpp
@@ -96,6 +96,15 @@
return UnwrapValue()->IsFunction();
}
+std::tuple<bool, std::string> ConvertString(v8::Local<v8::Value> v8value)
+{
+ if (!(v8value->IsString() || v8value->IsStringObject()))
+ {
+ return std::make_tuple(false, std::string());
+ }
+ return std::make_tuple(true, AdblockPlus::Utils::FromV8String(v8value));
+}
+
std::string AdblockPlus::JsValue::AsString() const
{
const JsContext context(jsEngine);
@@ -167,6 +176,12 @@
obj->Set(property, val);
}
+void SetPropertyOnV8Object(v8::Isolate* isolate, v8::Local<v8::Object>& target, const std::string& propertyName, const v8::Handle<v8::Value>& propertyValue)
+{
+ auto v8PropertyName = AdblockPlus::Utils::ToV8String(isolate, propertyName);
+ target->Set(v8PropertyName, propertyValue);
+}
+
v8::Local<v8::Value> AdblockPlus::JsValue::UnwrapValue() const
{
return v8::Local<v8::Value>::New(jsEngine->GetIsolate(), *value);
@@ -178,12 +193,22 @@
SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val));
}
+void SetPropertyOnV8Object(v8::Isolate* isolate, v8::Local<v8::Object>& target, const std::string& propertyName, const std::string& propertyValue)
+{
+ SetPropertyOnV8Object(isolate, target, propertyName, AdblockPlus::Utils::ToV8String(isolate, propertyValue));
+}
+
void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val)
{
const JsContext context(jsEngine);
SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val));
}
+void SetPropertyOnV8Object(v8::Isolate* isolate, v8::Local<v8::Object>& target, const std::string& propertyName, int64_t propertyValue)
+{
+ SetPropertyOnV8Object(isolate, target, propertyName, v8::Number::New(isolate, propertyValue));
+}
+
void AdblockPlus::JsValue::SetProperty(const std::string& name, const JsValuePtr& val)
{
const JsContext context(jsEngine);
« no previous file with comments | « src/JsEngine.cpp ('k') | src/Value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld