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

Unified Diff: src/plugin/AdblockPlusClient.cpp

Issue 10874009: Use a proper enum type for procedures that can be called (Closed)
Patch Set: Created June 3, 2013, 1:53 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/plugin/AdblockPlusClient.cpp
===================================================================
--- a/src/plugin/AdblockPlusClient.cpp
+++ b/src/plugin/AdblockPlusClient.cpp
@@ -236,27 +236,27 @@ int CAdblockPlusClient::GetIEVersion()
Communication::InputBuffer CallAdblockPlusEngineProcedure(Communication::OutputBuffer& message)
{
std::auto_ptr<Communication::Pipe> pipe = OpenAdblockPlusEnginePipe();
pipe->WriteMessage(message);
return pipe->ReadMessage();
}
-Communication::InputBuffer CallAdblockPlusEngineProcedure(const std::string& proc)
+Communication::InputBuffer CallAdblockPlusEngineProcedure(Communication::ProcType proc)
{
Communication::OutputBuffer message;
message << proc;
return CallAdblockPlusEngineProcedure(message);
}
bool CAdblockPlusClient::Matches(const std::string& url, const std::string& contentType, const std::string& domain)
{
Communication::OutputBuffer request;
- request << std::string("Matches") << url << contentType << domain;
+ request << Communication::PROC_MATCHES << url << contentType << domain;
try
{
Communication::InputBuffer response = CallAdblockPlusEngineProcedure(request);
bool match;
response >> match;
return match;
@@ -266,17 +266,17 @@ bool CAdblockPlusClient::Matches(const s
DEBUG_GENERAL(e.what());
return false;
}
}
std::vector<std::string> CAdblockPlusClient::GetElementHidingSelectors(const std::string& domain)
{
Communication::OutputBuffer request;
- request << std::string("GetElementHidingSelectors") << domain;
+ request << Communication::PROC_GET_ELEMHIDE_SELECTORS << domain;
try
{
Communication::InputBuffer response = CallAdblockPlusEngineProcedure(request);
return ReadStrings(response);
}
catch (const std::exception& e)
{
@@ -284,85 +284,85 @@ std::vector<std::string> CAdblockPlusCli
return std::vector<std::string>();
}
}
std::vector<SubscriptionDescription> CAdblockPlusClient::FetchAvailableSubscriptions()
{
try
{
- Communication::InputBuffer response = CallAdblockPlusEngineProcedure("FetchAvailableSubscriptions");
+ Communication::InputBuffer response = CallAdblockPlusEngineProcedure(Communication::PROC_AVAILABLE_SUBSCRIPTIONS);
return ReadSubscriptions(response);
}
catch (const std::exception& e)
{
DEBUG_GENERAL(e.what());
return std::vector<SubscriptionDescription>();
}
}
std::vector<SubscriptionDescription> CAdblockPlusClient::GetListedSubscriptions()
{
try
{
- Communication::InputBuffer response = CallAdblockPlusEngineProcedure("GetListedSubscriptions");
+ Communication::InputBuffer response = CallAdblockPlusEngineProcedure(Communication::PROC_LISTED_SUBSCRIPTIONS);
return ReadSubscriptions(response);
}
catch (const std::exception& e)
{
DEBUG_GENERAL(e.what());
return std::vector<SubscriptionDescription>();
}
}
void CAdblockPlusClient::SetSubscription(std::string url)
{
Communication::OutputBuffer request;
- request << std::string("SetSubscription") << url;
+ request << Communication::PROC_SET_SUBSCRIPTION << url;
try
{
CallAdblockPlusEngineProcedure(request);
}
catch (const std::exception& e)
{
DEBUG_GENERAL(e.what());
}
}
void CAdblockPlusClient::UpdateAllSubscriptions()
{
try
{
- CallAdblockPlusEngineProcedure("UpdateAllSubscriptions");
+ CallAdblockPlusEngineProcedure(Communication::PROC_UPDATE_ALL_SUBSCRIPTIONS);
}
catch (const std::exception& e)
{
DEBUG_GENERAL(e.what());
}
}
std::vector<std::string> CAdblockPlusClient::GetExceptionDomains()
{
try
{
- Communication::InputBuffer response = CallAdblockPlusEngineProcedure("GetExceptionDomains");
+ Communication::InputBuffer response = CallAdblockPlusEngineProcedure(Communication::PROC_GET_EXCEPTION_DOMAINS);
return ReadStrings(response);
}
catch (const std::exception& e)
{
DEBUG_GENERAL(e.what());
return std::vector<std::string>();
}
}
void CAdblockPlusClient::AddFilter(const std::string& text)
{
Communication::OutputBuffer request;
- request << std::string("AddFilter") << text;
+ request << Communication::PROC_ADD_FILTER << text;
try
{
CallAdblockPlusEngineProcedure(request);
}
catch (const std::exception& e)
{
DEBUG_GENERAL(e.what());
« no previous file with comments | « src/engine/main.cpp ('k') | src/shared/Communication.h » ('j') | src/shared/Communication.h » ('J')

Powered by Google App Engine
This is Rietveld