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

Side by Side Diff: src/JsEngine.cpp

Issue 10085006: Implement setTimeout (Closed)
Patch Set: Created April 5, 2013, 3:49 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 #include <sstream> 2 #include <sstream>
3 3
4 #include "GlobalJsObject.h" 4 #include "GlobalJsObject.h"
5 5
6 namespace 6 namespace
7 { 7 {
8 v8::Handle<v8::Context> CreateContext( 8 v8::Handle<v8::Context> CreateContext(
9 AdblockPlus::ErrorCallback& errorCallback) 9 AdblockPlus::ErrorCallback& errorCallback)
10 { 10 {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 const v8::Local<v8::Object> global = context->Global(); 102 const v8::Local<v8::Object> global = context->Global();
103 const v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 103 const v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
104 global->Get(v8::String::New(functionName.c_str()))); 104 global->Get(v8::String::New(functionName.c_str())));
105 const v8::TryCatch tryCatch; 105 const v8::TryCatch tryCatch;
106 const v8::Local<v8::Value> result = function->Call(function, 0, 0); 106 const v8::Local<v8::Value> result = function->Call(function, 0, 0);
107 CheckTryCatch(tryCatch); 107 CheckTryCatch(tryCatch);
108 const v8::String::AsciiValue ascii(result); 108 const v8::String::AsciiValue ascii(result);
109 return *ascii; 109 return *ascii;
110 } 110 }
111 111
112 std::string AdblockPlus::JsEngine::GetGlobal(const std::string& name)
Wladimir Palant 2013/04/08 08:36:00 This name got me thoroughly confused. Please renam
Felix Dahlke 2013/04/08 13:07:49 Sure. Called it "GetVariable" since I think that "
113 {
114 const v8::Locker locker(v8::Isolate::GetCurrent());
115 const v8::HandleScope handleScope;
116 const v8::Context::Scope contextScope(context);
117 const v8::Local<v8::Object> global = context->Global();
118 const v8::Local<v8::Value> value = global->Get(v8::String::New(name.c_str()));
119 if (value->IsUndefined())
120 return "";
121 const v8::String::AsciiValue ascii(value);
122 return *ascii;
123 }
124
112 void AdblockPlus::JsEngine::Gc() 125 void AdblockPlus::JsEngine::Gc()
113 { 126 {
114 while (!v8::V8::IdleNotification()); 127 while (!v8::V8::IdleNotification());
115 } 128 }
OLDNEW

Powered by Google App Engine
This is Rietveld