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: Comments addressed Created July 20, 2013, 8:11 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
« no previous file with comments | « no previous file | src/plugin/AdblockPlusClient.h » ('j') | src/plugin/PluginClass.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 AdblockPlus::JsValuePtr valuePtr = filterEngine->GetPref(name); 164 AdblockPlus::JsValuePtr valuePtr = filterEngine->GetPref(name);
161 if ((valuePtr->IsNull()) || (!valuePtr->IsString())) 165 if ((valuePtr->IsNull()) || (!valuePtr->IsString()))
162 response << 0; 166 response << 0;
163 else 167 else
164 { 168 {
165 response << 1; 169 response << 1;
166 response << valuePtr->AsString(); 170 response << valuePtr->AsString();
167 } 171 }
168 break; 172 break;
169 } 173 }
170 case Communication::PROC_GET_IS_FIRST_RUN: 174 case Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED:
175 {
176 CriticalSection::Lock lock(firstRunLock);
177 if (!firstRunActionTaken && filterEngine->IsFirstRun())
171 { 178 {
172 response << filterEngine->IsFirstRun(); 179 response << !firstRunActionTaken;
Wladimir Palant 2013/07/21 11:53:45 How about just response << true? No point obscurin
173 break; 180 firstRunActionTaken = true;
174 } 181 }
Wladimir Palant 2013/07/21 11:53:45 What about: else response << false; Shouldn't
182 break;
183 }
175 184
176 } 185 }
177 return response; 186 return response;
178 } 187 }
179 188
180 DWORD WINAPI ClientThread(LPVOID param) 189 DWORD WINAPI ClientThread(LPVOID param)
181 { 190 {
182 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa ram)); 191 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa ram));
183 192
184 try 193 try
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 286 }
278 catch (std::runtime_error e) 287 catch (std::runtime_error e)
279 { 288 {
280 DebugException(e); 289 DebugException(e);
281 return 1; 290 return 1;
282 } 291 }
283 } 292 }
284 293
285 return 0; 294 return 0;
286 } 295 }
OLDNEW
« no previous file with comments | « no previous file | src/plugin/AdblockPlusClient.h » ('j') | src/plugin/PluginClass.cpp » ('J')

Powered by Google App Engine
This is Rietveld