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

Unified Diff: src/engine/main.cpp

Issue 11013110: Cleanup (Closed)
Patch Set: Minor CallEngine refactoring Created July 26, 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
Index: src/engine/main.cpp
===================================================================
--- a/src/engine/main.cpp
+++ b/src/engine/main.cpp
@@ -143,6 +143,84 @@
filterEngine->GetFilter(text)->RemoveFromList();
break;
}
+ case Communication::PROC_SET_PREF:
+ {
+ std::string prefName;
+ request >> prefName;
+
+ Communication::ValueType valueType = request.GetType();
+ switch (valueType)
+ {
+ case Communication::TYPE_STRING:
+ {
+ std::string prefValue;
+ request >> prefValue;
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue));
+ break;
+ }
+ case Communication::TYPE_INT64:
+ {
+ int64_t prefValue;
+ request >> prefValue;
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue));
+ break;
+ }
+ case Communication::TYPE_INT32:
+ {
+ int prefValue;
+ request >> prefValue;
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue));
+ break;
+ }
+ case Communication::TYPE_BOOL:
+ {
+ bool prefValue;
+ request >> prefValue;
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue));
+ break;
+ }
+ default:
+ break;
+ }
+ break;
+ }
+ case Communication::PROC_GET_PREF:
+ {
+ std::string name;
+ request >> name;
+
+ AdblockPlus::JsValuePtr valuePtr = filterEngine->GetPref(name);
+ if (valuePtr->IsNull() || valuePtr->IsUndefined())
Wladimir Palant 2013/07/26 16:45:37 valuePtr->IsNull() will be true for undefined as w
Oleksandr 2013/08/05 23:11:01 This was addressed in: https://hg.adblockplus.org/
+ {
+ // Report no success
+ response << false;
+ break;
+ }
+
+
+ if (valuePtr->IsBool())
+ {
+ response << valuePtr->AsBool();
+ response << true;
Wladimir Palant 2013/07/26 16:45:37 I don't get this, shouldn't you first write succes
+ }
+ else if (valuePtr->IsNumber())
+ {
+ response << valuePtr->AsInt();
+ response << true;
+ }
+ else if (valuePtr->IsString())
+ {
+ response << valuePtr->AsString();
+ response << true;
+ }
+ else
+ {
+ // Report failure
+ response << false;
+ }
+ break;
+ }
+
}
return response;
}
« no previous file with comments | « adblockplus.gyp ('k') | src/plugin/AdblockPlus.rc » ('j') | src/plugin/AdblockPlus.rc » ('J')

Powered by Google App Engine
This is Rietveld