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

Unified Diff: src/FilterEngine.cpp

Issue 10862008: Automatically add default filter subscription when necessary. (Closed)
Patch Set: Created May 27, 2013, 2:12 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/AppInfoJsObject.cpp ('k') | src/GlobalJsObject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
===================================================================
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -129,31 +129,38 @@ bool Subscription::IsUpdating()
}
bool Subscription::operator==(const Subscription& subscription) const
{
return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsString();
}
FilterEngine::FilterEngine(JsEnginePtr jsEngine)
- : jsEngine(jsEngine), initialized(false)
+ : jsEngine(jsEngine), initialized(false), firstRun(false)
{
- jsEngine->SetEventCallback("init", std::tr1::bind(&FilterEngine::InitDone, this));
+ jsEngine->SetEventCallback("init", std::tr1::bind(&FilterEngine::InitDone,
+ this, std::tr1::placeholders::_1));
for (int i = 0; !jsSources[i].empty(); i += 2)
jsEngine->Evaluate(jsSources[i + 1], jsSources[i]);
// TODO: This should really be implemented via a conditional variable
while (!initialized)
::Sleep(10);
}
-void FilterEngine::InitDone()
+void FilterEngine::InitDone(JsValueList& params)
{
jsEngine->RemoveEventCallback("init");
initialized = true;
+ firstRun = params.size() && params[0]->AsBool();
+}
+
+bool FilterEngine::IsFirstRun() const
+{
+ return firstRun;
}
FilterPtr FilterEngine::GetFilter(const std::string& text)
{
JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText");
JsValueList params;
params.push_back(jsEngine->NewValue(text));
return FilterPtr(new Filter(func->Call(params)));
« no previous file with comments | « src/AppInfoJsObject.cpp ('k') | src/GlobalJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld