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

Side by Side Diff: src/engine/main.cpp

Issue 11013110: Cleanup (Closed)
Patch Set: More refactoring. Removing main thread, tab counting. Implementing SetPref and GetPref. Addressing … Created July 9, 2013, 12:59 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 #include <functional> 2 #include <functional>
3 #include <vector> 3 #include <vector>
4 #include <Windows.h> 4 #include <Windows.h>
5 5
6 #include "../shared/AutoHandle.h" 6 #include "../shared/AutoHandle.h"
7 #include "../shared/Communication.h" 7 #include "../shared/Communication.h"
8 #include "../shared/Dictionary.h" 8 #include "../shared/Dictionary.h"
9 #include "../shared/Utils.h" 9 #include "../shared/Utils.h"
10 #include "../shared/Version.h" 10 #include "../shared/Version.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 filterEngine->GetFilter(text)->AddToList(); 136 filterEngine->GetFilter(text)->AddToList();
137 break; 137 break;
138 } 138 }
139 case Communication::PROC_REMOVE_FILTER: 139 case Communication::PROC_REMOVE_FILTER:
140 { 140 {
141 std::string text; 141 std::string text;
142 request >> text; 142 request >> text;
143 filterEngine->GetFilter(text)->RemoveFromList(); 143 filterEngine->GetFilter(text)->RemoveFromList();
144 break; 144 break;
145 } 145 }
146 case Communication::PROC_SET_PREF:
147 {
148 std::string prefName = "";
149 std::string prefValue = "";
Wladimir Palant 2013/07/11 12:53:10 Please don't initialize these variables, their ini
150 request >> prefName;
151 request >> prefValue;
Wladimir Palant 2013/07/11 12:53:10 These lines can be merged: request >> prefName >>
152 filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(pr efValue));
Wladimir Palant 2013/07/11 12:53:10 What about preferences with non-string values? Thi
153 break;
154 }
155 case Communication::PROC_GET_PREF:
156 {
157 std::string name;
158 request >> name;
159
160 AdblockPlus::JsValuePtr valuePtr = filterEngine->GetPref(name);
161 if ((valuePtr->IsNull()) || (!valuePtr->IsString()))
Wladimir Palant 2013/07/11 12:53:10 I think checking valuePtr->IsString() is sufficien
162 response << 0;
Wladimir Palant 2013/07/11 12:53:10 Please don't use an integer as a boolean, this sho
163 else
164 {
165 response << 1;
166 response << valuePtr->AsString();
Wladimir Palant 2013/07/11 12:53:10 These two lines can be merged: response << true
167 }
168 break;
169 }
170
146 } 171 }
147 return response; 172 return response;
148 } 173 }
149 174
150 DWORD WINAPI ClientThread(LPVOID param) 175 DWORD WINAPI ClientThread(LPVOID param)
151 { 176 {
152 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa ram)); 177 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa ram));
153 178
154 try 179 try
155 { 180 {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 272 }
248 catch (std::runtime_error e) 273 catch (std::runtime_error e)
249 { 274 {
250 DebugException(e); 275 DebugException(e);
251 return 1; 276 return 1;
252 } 277 }
253 } 278 }
254 279
255 return 0; 280 return 0;
256 } 281 }
OLDNEW

Powered by Google App Engine
This is Rietveld