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

Delta Between Two Patch Sets: src/plugin/AdblockPlusClient.cpp

Issue 4806567450902528: Issue 1794 - add handling of std::vector<std::string> by Communication::{Input,Output}Buffer (Closed)
Left Patch Set: change tests Created Jan. 27, 2015, 3:27 p.m.
Right Patch Set: remove WriteStrings and ReadStrings Created Feb. 9, 2015, 2:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 #include "PluginSettings.h" 2 #include "PluginSettings.h"
3 #include "PluginSystem.h" 3 #include "PluginSystem.h"
4 #include "PluginFilter.h" 4 #include "PluginFilter.h"
5 #include "PluginClientFactory.h" 5 #include "PluginClientFactory.h"
6 #include "PluginMutex.h" 6 #include "PluginMutex.h"
7 #include "PluginClass.h" 7 #include "PluginClass.h"
8 8
9 #include "AdblockPlusClient.h" 9 #include "AdblockPlusClient.h"
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return new Communication::Pipe(Communication::pipeName, Communication: :Pipe::MODE_CONNECT); 101 return new Communication::Pipe(Communication::pipeName, Communication: :Pipe::MODE_CONNECT);
102 } 102 }
103 catch (Communication::PipeConnectionError e) 103 catch (Communication::PipeConnectionError e)
104 { 104 {
105 } 105 }
106 } 106 }
107 throw std::runtime_error("Unable to open Adblock Plus Engine pipe"); 107 throw std::runtime_error("Unable to open Adblock Plus Engine pipe");
108 } 108 }
109 } 109 }
110 110
111 std::vector<std::wstring> ReadStrings(Communication::InputBuffer& message)
112 {
113 int32_t count;
114 message >> count;
115
116 std::vector<std::wstring> result;
117 for (int32_t i = 0; i < count; i++)
118 {
119 std::string str;
120 message >> str;
121 result.push_back(ToUtf16String(str));
122 }
123 return result;
124 }
125
126 std::vector<SubscriptionDescription> ReadSubscriptions(Communication::InputBuf fer& message) 111 std::vector<SubscriptionDescription> ReadSubscriptions(Communication::InputBuf fer& message)
127 { 112 {
128 int32_t count; 113 int32_t count;
129 message >> count; 114 message >> count;
130 115
131 std::vector<SubscriptionDescription> result; 116 std::vector<SubscriptionDescription> result;
132 for (int32_t i = 0; i < count; i++) 117 for (int32_t i = 0; i < count; i++)
133 { 118 {
134 SubscriptionDescription description; 119 SubscriptionDescription description;
135 std::string url; 120 std::string url;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 287 }
303 288
304 std::vector<std::wstring> CAdblockPlusClient::GetElementHidingSelectors(const st d::wstring& domain) 289 std::vector<std::wstring> CAdblockPlusClient::GetElementHidingSelectors(const st d::wstring& domain)
305 { 290 {
306 Communication::OutputBuffer request; 291 Communication::OutputBuffer request;
307 request << Communication::PROC_GET_ELEMHIDE_SELECTORS << ToUtf8String(domain); 292 request << Communication::PROC_GET_ELEMHIDE_SELECTORS << ToUtf8String(domain);
308 293
309 Communication::InputBuffer response; 294 Communication::InputBuffer response;
310 if (!CallEngine(request, response)) 295 if (!CallEngine(request, response))
311 return std::vector<std::wstring>(); 296 return std::vector<std::wstring>();
312 return ReadStrings(response); 297
298 std::vector<std::string> selectors;
299 response >> selectors;
300 return ToUtf16Strings(selectors);
Eric 2015/02/09 16:18:57 Here and below, you're following a call to operato
313 } 301 }
314 302
315 std::vector<SubscriptionDescription> CAdblockPlusClient::FetchAvailableSubscript ions() 303 std::vector<SubscriptionDescription> CAdblockPlusClient::FetchAvailableSubscript ions()
316 { 304 {
317 Communication::InputBuffer response; 305 Communication::InputBuffer response;
318 if (!CallEngine(Communication::PROC_AVAILABLE_SUBSCRIPTIONS, response)) 306 if (!CallEngine(Communication::PROC_AVAILABLE_SUBSCRIPTIONS, response))
319 return std::vector<SubscriptionDescription>(); 307 return std::vector<SubscriptionDescription>();
320 return ReadSubscriptions(response); 308 return ReadSubscriptions(response);
321 } 309 }
322 310
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 void CAdblockPlusClient::UpdateAllSubscriptions() 356 void CAdblockPlusClient::UpdateAllSubscriptions()
369 { 357 {
370 CallEngine(Communication::PROC_UPDATE_ALL_SUBSCRIPTIONS); 358 CallEngine(Communication::PROC_UPDATE_ALL_SUBSCRIPTIONS);
371 } 359 }
372 360
373 std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains() 361 std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains()
374 { 362 {
375 Communication::InputBuffer response; 363 Communication::InputBuffer response;
376 if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS, response)) 364 if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS, response))
377 return std::vector<std::wstring>(); 365 return std::vector<std::wstring>();
378 return ReadStrings(response); 366
367 std::vector<std::string> domains;
368 response >> domains;
369 return ToUtf16Strings(domains);
Eric 2015/02/09 16:18:57 Second pair of calls: operator>>, ToUtf16Strings
379 } 370 }
380 371
381 bool CAdblockPlusClient::IsFirstRun() 372 bool CAdblockPlusClient::IsFirstRun()
382 { 373 {
383 DEBUG_GENERAL("IsFirstRun"); 374 DEBUG_GENERAL("IsFirstRun");
384 Communication::InputBuffer response; 375 Communication::InputBuffer response;
385 if (!CallEngine(Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED, response)) ret urn false; 376 if (!CallEngine(Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED, response)) ret urn false;
386 bool res; 377 bool res;
387 response >> res; 378 response >> res;
388 return res; 379 return res;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 DEBUG_GENERAL("CompareVersions"); 540 DEBUG_GENERAL("CompareVersions");
550 Communication::OutputBuffer request; 541 Communication::OutputBuffer request;
551 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S tring(v2); 542 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S tring(v2);
552 Communication::InputBuffer response; 543 Communication::InputBuffer response;
553 if (!CallEngine(request, response)) 544 if (!CallEngine(request, response))
554 return 0; 545 return 0;
555 int result; 546 int result;
556 response >> result; 547 response >> result;
557 return result; 548 return result;
558 } 549 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld