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

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

Issue 11043057: First run page triggering (Closed)
Patch Set: All changes Created July 25, 2013, 2:02 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"
11 #include "../shared/CriticalSection.h"
11 #include "Debug.h" 12 #include "Debug.h"
12 #include "Updater.h" 13 #include "Updater.h"
13 14
14 namespace 15 namespace
15 { 16 {
16 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; 17 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine;
17 18
18 void WriteStrings(Communication::OutputBuffer& response, 19 void WriteStrings(Communication::OutputBuffer& response,
19 const std::vector<std::string>& strings) 20 const std::vector<std::string>& strings)
20 { 21 {
(...skipping 10 matching lines...) Expand all
31 response << count; 32 response << count;
32 for (int32_t i = 0; i < count; i++) 33 for (int32_t i = 0; i < count; i++)
33 { 34 {
34 AdblockPlus::SubscriptionPtr subscription = subscriptions[i]; 35 AdblockPlus::SubscriptionPtr subscription = subscriptions[i];
35 response << subscription->GetProperty("url")->AsString() 36 response << subscription->GetProperty("url")->AsString()
36 << subscription->GetProperty("title")->AsString() 37 << subscription->GetProperty("title")->AsString()
37 << subscription->GetProperty("specialization")->AsString() 38 << subscription->GetProperty("specialization")->AsString()
38 << subscription->IsListed(); 39 << subscription->IsListed();
39 } 40 }
40 } 41 }
42
43 CriticalSection firstRunLock;
44 bool firstRunActionTaken = false;
Felix Dahlke 2013/07/25 14:54:37 "firstRunActionTaken" sounds wrong to my ears, I t
41 45
42 Communication::OutputBuffer HandleRequest(Communication::InputBuffer& request) 46 Communication::OutputBuffer HandleRequest(Communication::InputBuffer& request)
43 { 47 {
44 Communication::OutputBuffer response; 48 Communication::OutputBuffer response;
45 49
46 Communication::ProcType procedure; 50 Communication::ProcType procedure;
47 request >> procedure; 51 request >> procedure;
48 switch (procedure) 52 switch (procedure)
49 { 53 {
50 case Communication::PROC_MATCHES: 54 case Communication::PROC_MATCHES:
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 else if (valuePtr->IsNumber()) 211 else if (valuePtr->IsNumber())
208 { 212 {
209 response << valuePtr->AsInt(); 213 response << valuePtr->AsInt();
210 } 214 }
211 else if (valuePtr->IsString()) 215 else if (valuePtr->IsString())
212 { 216 {
213 response << valuePtr->AsString(); 217 response << valuePtr->AsString();
214 } 218 }
215 break; 219 break;
216 } 220 }
221 case Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED:
Felix Dahlke 2013/07/25 14:54:37 How about PROC_IS_FIRST_RUN? The function invoking
Oleksandr 2013/07/26 12:07:01 I would say the PROC_IS_FIRST_RUN would be confusi
Felix Dahlke 2013/08/02 10:52:24 Fair enough I guess. Might want to rename IsFirstR
222 {
223 CriticalSection::Lock lock(firstRunLock);
224 if (!firstRunActionTaken && filterEngine->IsFirstRun())
225 {
226 response << true;
227 firstRunActionTaken = true;
228 }
229 else
230 {
231 response << false;
232 }
233 break;
234 }
217 235
218 } 236 }
219 return response; 237 return response;
220 } 238 }
221 239
222 DWORD WINAPI ClientThread(LPVOID param) 240 DWORD WINAPI ClientThread(LPVOID param)
223 { 241 {
224 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa ram)); 242 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa ram));
225 243
226 try 244 try
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 337 }
320 catch (std::runtime_error e) 338 catch (std::runtime_error e)
321 { 339 {
322 DebugException(e); 340 DebugException(e);
323 return 1; 341 return 1;
324 } 342 }
325 } 343 }
326 344
327 return 0; 345 return 0;
328 } 346 }
OLDNEW

Powered by Google App Engine
This is Rietveld