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

Side by Side Diff: src/JsEngine.cpp

Issue 10420020: Made sure FilterEngine instances are always initialized (Closed)
Patch Set: Created May 16, 2013, 2:27 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
« no previous file with comments | « src/GlobalJsObject.cpp ('k') | test/BaseJsTest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 { 86 {
87 const Context context(shared_from_this()); 87 const Context context(shared_from_this());
88 const v8::TryCatch tryCatch; 88 const v8::TryCatch tryCatch;
89 const v8::Handle<v8::Script> script = CompileScript(source, filename); 89 const v8::Handle<v8::Script> script = CompileScript(source, filename);
90 CheckTryCatch(tryCatch); 90 CheckTryCatch(tryCatch);
91 v8::Local<v8::Value> result = script->Run(); 91 v8::Local<v8::Value> result = script->Run();
92 CheckTryCatch(tryCatch); 92 CheckTryCatch(tryCatch);
93 return JsValuePtr(new JsValue(shared_from_this(), result)); 93 return JsValuePtr(new JsValue(shared_from_this(), result));
94 } 94 }
95 95
96 void AdblockPlus::JsEngine::SetInitCallback(AdblockPlus::JsEngine::InitCallback callback)
97 {
98 initCallback = callback;
99 }
100
101 void AdblockPlus::JsEngine::InitDone()
102 {
103 // Zero out callback immediately to prevent reentrance
104 InitCallback callback = initCallback;
105 initCallback = 0;
106 if (callback)
107 callback();
108 }
109
96 void AdblockPlus::JsEngine::Gc() 110 void AdblockPlus::JsEngine::Gc()
97 { 111 {
98 while (!v8::V8::IdleNotification()); 112 while (!v8::V8::IdleNotification());
99 } 113 }
100 114
101 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewValue(const std::string& val) 115 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewValue(const std::string& val)
102 { 116 {
103 const Context context(shared_from_this()); 117 const Context context(shared_from_this());
104 return JsValuePtr(new JsValue(shared_from_this(), 118 return JsValuePtr(new JsValue(shared_from_this(),
105 v8::String::New(val.c_str(), val.length()))); 119 v8::String::New(val.c_str(), val.length())));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 throw std::runtime_error("LogSystem cannot be null"); 215 throw std::runtime_error("LogSystem cannot be null");
202 216
203 logSystem = val; 217 logSystem = val;
204 } 218 }
205 219
206 AdblockPlus::JsEngine::Context::Context(const JsEnginePtr jsEngine) 220 AdblockPlus::JsEngine::Context::Context(const JsEnginePtr jsEngine)
207 : locker(jsEngine->isolate), handleScope(), 221 : locker(jsEngine->isolate), handleScope(),
208 contextScope(jsEngine->context) 222 contextScope(jsEngine->context)
209 { 223 {
210 } 224 }
OLDNEW
« no previous file with comments | « src/GlobalJsObject.cpp ('k') | test/BaseJsTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld