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

Unified Diff: src/FilterEngine.cpp

Issue 4578638519336960: Issue 1296 - Add SetUpdateAvailableCallback (Closed)
Patch Set: Created Sept. 18, 2014, 3: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
Index: src/FilterEngine.cpp
===================================================================
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -340,7 +340,27 @@
return func->Call(params)->AsString();
}
-void FilterEngine::ForceUpdateCheck(FilterEngine::UpdaterCallback callback)
+void FilterEngine::SetUpdateAvailableCallback(
+ FilterEngine::UpdateAvailableCallback callback)
+{
+ jsEngine->SetEventCallback("updateAvailable",
+ std::tr1::bind(&FilterEngine::UpdateAvailable, this, callback,
+ std::tr1::placeholders::_1));
+}
+
+void FilterEngine::RemoveUpdateAvailableCallback()
+{
+ jsEngine->RemoveEventCallback("updateAvailable");
+}
+
+void FilterEngine::UpdateAvailable(
+ FilterEngine::UpdateAvailableCallback callback, JsValueList& params)
+{
+ callback(params[0]->AsString());
Wladimir Palant 2014/09/18 19:44:17 I'd rather not crash if the JS code unexpectedly d
Felix Dahlke 2014/09/19 02:51:41 Knowing that the updater actually ensures a valid
+}
+
+void FilterEngine::ForceUpdateCheck(
+ FilterEngine::UpdateCheckDoneCallback callback)
{
std::string eventName = "updateCheckDone";
eventName += ++updateCheckId;
@@ -354,7 +374,8 @@
func->Call(params);
}
-void FilterEngine::UpdateCheckDone(const std::string& eventName, FilterEngine::UpdaterCallback callback, JsValueList& params)
+void FilterEngine::UpdateCheckDone(const std::string& eventName,
+ FilterEngine::UpdateCheckDoneCallback callback, JsValueList& params)
{
jsEngine->RemoveEventCallback(eventName);

Powered by Google App Engine
This is Rietveld