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 8, 2013, 1:07 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::GetVariable(const std::string& name)
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
« src/GlobalJsObject.cpp ('K') | « src/GlobalJsObject.cpp ('k') | test/GlobalJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld