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

Delta Between Two Patch Sets: src/JsEngine.cpp

Issue 10420020: Made sure FilterEngine instances are always initialized (Closed)
Left Patch Set: Created May 16, 2013, 2:27 p.m.
Right Patch Set: Using a generic messaging mechanism Created May 23, 2013, 6:35 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/GlobalJsObject.cpp ('k') | test/BaseJsTest.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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) 96 void AdblockPlus::JsEngine::SetEventCallback(const std::string& eventName,
97 { 97 AdblockPlus::JsEngine::EventCallback callback)
98 initCallback = callback; 98 {
99 } 99 eventCallbacks[eventName] = callback;
100 100 }
101 void AdblockPlus::JsEngine::InitDone() 101
102 { 102 void AdblockPlus::JsEngine::RemoveEventCallback(const std::string& eventName)
103 // Zero out callback immediately to prevent reentrance 103 {
104 InitCallback callback = initCallback; 104 eventCallbacks.erase(eventName);
105 initCallback = 0; 105 }
106 if (callback) 106
107 callback(); 107 void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName)
108 {
109 EventMap::iterator it = eventCallbacks.find(eventName);
110 if (it != eventCallbacks.end())
111 it->second();
108 } 112 }
109 113
110 void AdblockPlus::JsEngine::Gc() 114 void AdblockPlus::JsEngine::Gc()
111 { 115 {
112 while (!v8::V8::IdleNotification()); 116 while (!v8::V8::IdleNotification());
113 } 117 }
114 118
115 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewValue(const std::string& val) 119 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewValue(const std::string& val)
116 { 120 {
117 const Context context(shared_from_this()); 121 const Context context(shared_from_this());
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 throw std::runtime_error("LogSystem cannot be null"); 219 throw std::runtime_error("LogSystem cannot be null");
216 220
217 logSystem = val; 221 logSystem = val;
218 } 222 }
219 223
220 AdblockPlus::JsEngine::Context::Context(const JsEnginePtr jsEngine) 224 AdblockPlus::JsEngine::Context::Context(const JsEnginePtr jsEngine)
221 : locker(jsEngine->isolate), handleScope(), 225 : locker(jsEngine->isolate), handleScope(),
222 contextScope(jsEngine->context) 226 contextScope(jsEngine->context)
223 { 227 {
224 } 228 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld