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

Unified Diff: src/plugin/AdblockPlusClient.cpp

Issue 4882650246414336: Issue 2005 - Refactor working with strings in InputBuffer and OutputBuffer
Patch Set: rebase Created April 2, 2015, 11:09 a.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 | « no previous file | src/shared/Communication.h » ('j') | test/CommunicationTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/AdblockPlusClient.cpp
diff --git a/src/plugin/AdblockPlusClient.cpp b/src/plugin/AdblockPlusClient.cpp
index 149c600a5a0733b593edbf6c46a3f41209d3976b..ffa28bd350f29493a8b73471a72ab3551e896381 100644
--- a/src/plugin/AdblockPlusClient.cpp
+++ b/src/plugin/AdblockPlusClient.cpp
@@ -134,15 +134,9 @@ namespace
for (int32_t i = 0; i < count; i++)
{
SubscriptionDescription description;
- std::string url;
- message >> url;
- description.url = ToUtf16String(url);
- std::string title;
- message >> title;
- description.title = ToUtf16String(title);
- std::string specialization;
- message >> specialization;
- description.specialization = ToUtf16String(specialization);
+ message >> description.url;
+ message >> description.title;
+ message >> description.specialization;
message >> description.listed;
result.push_back(description);
}
@@ -151,7 +145,7 @@ namespace
}
CAdblockPlusClient* CAdblockPlusClient::s_instance = NULL;
-CComAutoCriticalSection CAdblockPlusClient::s_criticalSectionLocal;
+CComAutoCriticalSection CAdblockPlusClient::s_criticalSectionLocal;
CAdblockPlusClient::CAdblockPlusClient()
{
@@ -266,9 +260,9 @@ bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url)
std::string CAdblockPlusClient::GetWhitelistingFilter(const std::wstring& url)
{
- DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" start").c_str());
+ DEBUG_GENERAL((L"GetWhitelistingFilter: " + url + L" start").c_str());
Communication::OutputBuffer request;
- request << Communication::PROC_GET_WHITELISTING_FITER << ToUtf8String(url);
+ request << Communication::PROC_GET_WHITELISTING_FITER << url;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -277,14 +271,14 @@ std::string CAdblockPlusClient::GetWhitelistingFilter(const std::wstring& url)
std::string filterText;
response >> filterText;
- DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" end").c_str());
+ DEBUG_GENERAL((L"GetWhitelistingFilter: " + url + L" end").c_str());
return filterText;
}
bool CAdblockPlusClient::IsElemhideWhitelistedOnDomain(const std::wstring& url)
{
Communication::OutputBuffer request;
- request << Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL << ToUtf8String(url);
+ request << Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL << url;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -298,7 +292,7 @@ bool CAdblockPlusClient::IsElemhideWhitelistedOnDomain(const std::wstring& url)
bool CAdblockPlusClient::Matches(const std::wstring& url, AdblockPlus::FilterEngine::ContentType contentType, const std::wstring& domain)
{
Communication::OutputBuffer request;
- request << Communication::PROC_MATCHES << ToUtf8String(url) << static_cast<int32_t>(contentType) << ToUtf8String(domain);
+ request << Communication::PROC_MATCHES << url << contentType << domain;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -312,15 +306,15 @@ bool CAdblockPlusClient::Matches(const std::wstring& url, AdblockPlus::FilterEng
std::vector<std::wstring> CAdblockPlusClient::GetElementHidingSelectors(const std::wstring& domain)
{
Communication::OutputBuffer request;
- request << Communication::PROC_GET_ELEMHIDE_SELECTORS << ToUtf8String(domain);
+ request << Communication::PROC_GET_ELEMHIDE_SELECTORS << domain;
Communication::InputBuffer response;
if (!CallEngine(request, response))
return std::vector<std::wstring>();
- std::vector<std::string> selectors;
+ std::vector<std::wstring> selectors;
response >> selectors;
- return ToUtf16Strings(selectors);
+ return selectors;
}
std::vector<SubscriptionDescription> CAdblockPlusClient::FetchAvailableSubscriptions()
@@ -357,21 +351,21 @@ bool CAdblockPlusClient::IsAcceptableAdsEnabled()
void CAdblockPlusClient::SetSubscription(const std::wstring& url)
{
Communication::OutputBuffer request;
- request << Communication::PROC_SET_SUBSCRIPTION << ToUtf8String(url);
+ request << Communication::PROC_SET_SUBSCRIPTION << url;
CallEngine(request);
}
void CAdblockPlusClient::AddSubscription(const std::wstring& url)
{
Communication::OutputBuffer request;
- request << Communication::PROC_ADD_SUBSCRIPTION << ToUtf8String(url);
+ request << Communication::PROC_ADD_SUBSCRIPTION << url;
CallEngine(request);
}
void CAdblockPlusClient::RemoveSubscription(const std::wstring& url)
{
Communication::OutputBuffer request;
- request << Communication::PROC_REMOVE_SUBSCRIPTION << ToUtf8String(url);
+ request << Communication::PROC_REMOVE_SUBSCRIPTION << url;
CallEngine(request);
}
@@ -387,9 +381,9 @@ std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains()
if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS, response))
return std::vector<std::wstring>();
- std::vector<std::string> domains;
+ std::vector<std::wstring> domains;
response >> domains;
- return ToUtf16Strings(domains);
+ return domains;
}
bool CAdblockPlusClient::IsFirstRun()
@@ -405,7 +399,7 @@ bool CAdblockPlusClient::IsFirstRun()
void CAdblockPlusClient::AddFilter(const std::wstring& text)
{
Communication::OutputBuffer request;
- request << Communication::PROC_ADD_FILTER << ToUtf8String(text);
+ request << Communication::PROC_ADD_FILTER << text;
CallEngine(request);
}
@@ -424,21 +418,21 @@ void CAdblockPlusClient::RemoveFilter(const std::string& text)
void CAdblockPlusClient::SetPref(const std::wstring& name, const std::wstring& value)
{
Communication::OutputBuffer request;
- request << Communication::PROC_SET_PREF << ToUtf8String(name) << ToUtf8String(value);
+ request << Communication::PROC_SET_PREF << name << value;
CallEngine(request);
}
void CAdblockPlusClient::SetPref(const std::wstring& name, const int64_t & value)
{
Communication::OutputBuffer request;
- request << Communication::PROC_SET_PREF << ToUtf8String(name) << value;
+ request << Communication::PROC_SET_PREF << name << value;
CallEngine(request);
}
void CAdblockPlusClient::SetPref(const std::wstring& name, bool value)
{
Communication::OutputBuffer request;
- request << Communication::PROC_SET_PREF << ToUtf8String(name) << value;
+ request << Communication::PROC_SET_PREF << name << value;
CallEngine(request);
}
@@ -450,7 +444,7 @@ std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws
{
DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str());
Communication::OutputBuffer request;
- request << Communication::PROC_GET_PREF << ToUtf8String(name);
+ request << Communication::PROC_GET_PREF << name;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -459,10 +453,10 @@ std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws
response >> success;
if (success)
{
- std::string value;
+ std::wstring value;
response >> value;
DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str());
- return ToUtf16String(value);
+ return value;
}
else
{
@@ -475,7 +469,7 @@ bool CAdblockPlusClient::GetPref(const std::wstring& name, bool defaultValue)
{
DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str());
Communication::OutputBuffer request;
- request << Communication::PROC_GET_PREF << ToUtf8String(name);
+ request << Communication::PROC_GET_PREF << name;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -499,7 +493,7 @@ int64_t CAdblockPlusClient::GetPref(const std::wstring& name, int64_t defaultVal
{
DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str());
Communication::OutputBuffer request;
- request << Communication::PROC_GET_PREF << ToUtf8String(name);
+ request << Communication::PROC_GET_PREF << name;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -533,9 +527,9 @@ std::wstring CAdblockPlusClient::GetDocumentationLink()
Communication::InputBuffer response;
if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response))
return L"";
- std::string docLink;
+ std::wstring docLink;
response >> docLink;
- return ToUtf16String(docLink);
+ return docLink;
}
bool CAdblockPlusClient::TogglePluginEnabled()
@@ -553,21 +547,21 @@ std::wstring CAdblockPlusClient::GetHostFromUrl(const std::wstring& url)
{
DEBUG_GENERAL("GetHostFromUrl");
Communication::OutputBuffer request;
- request << Communication::PROC_GET_HOST << ToUtf8String(url);
+ request << Communication::PROC_GET_HOST << url;
Communication::InputBuffer response;
if (!CallEngine(request, response))
return L"";
- std::string host;
+ std::wstring host;
response >> host;
- return ToUtf16String(host);
+ return host;
}
int CAdblockPlusClient::CompareVersions(const std::wstring& v1, const std::wstring& v2)
{
DEBUG_GENERAL("CompareVersions");
Communication::OutputBuffer request;
- request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8String(v2);
+ request << Communication::PROC_COMPARE_VERSIONS << v1 << v2;
Communication::InputBuffer response;
if (!CallEngine(request, response))
return 0;
« no previous file with comments | « no previous file | src/shared/Communication.h » ('j') | test/CommunicationTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld