Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginSettings.h" | 3 #include "PluginSettings.h" |
4 #include "PluginSystem.h" | 4 #include "PluginSystem.h" |
5 #include "PluginFilter.h" | 5 #include "PluginFilter.h" |
6 #include "PluginClientFactory.h" | 6 #include "PluginClientFactory.h" |
7 #include "PluginMutex.h" | 7 #include "PluginMutex.h" |
8 #include "PluginClass.h" | 8 #include "PluginClass.h" |
9 | 9 |
10 #include "AdblockPlusClient.h" | 10 #include "AdblockPlusClient.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 { | 42 { |
43 try | 43 try |
44 { | 44 { |
45 return new Communication::Pipe(Communication::pipeName, Communication::Pip e::MODE_CONNECT); | 45 return new Communication::Pipe(Communication::pipeName, Communication::Pip e::MODE_CONNECT); |
46 } | 46 } |
47 catch (Communication::PipeConnectionError e) | 47 catch (Communication::PipeConnectionError e) |
48 { | 48 { |
49 SpawnAdblockPlusEngine(); | 49 SpawnAdblockPlusEngine(); |
50 | 50 |
51 const int step = 100; | 51 const int step = 100; |
52 for (int timeout = 10000; timeout > 0; timeout -= step) | 52 for (int timeout = ENGINE_STARTUP_TIMEOUT; timeout > 0; timeout -= step) |
53 { | 53 { |
54 Sleep(step); | 54 Sleep(step); |
55 try | 55 try |
56 { | 56 { |
57 return new Communication::Pipe(Communication::pipeName, Communication: :Pipe::MODE_CONNECT); | 57 return new Communication::Pipe(Communication::pipeName, Communication: :Pipe::MODE_CONNECT); |
58 } | 58 } |
59 catch (Communication::PipeConnectionError e) | 59 catch (Communication::PipeConnectionError e) |
60 { | 60 { |
61 } | 61 } |
62 } | 62 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 | 106 |
107 CAdblockPlusClient* CAdblockPlusClient::s_instance = NULL; | 107 CAdblockPlusClient* CAdblockPlusClient::s_instance = NULL; |
108 | 108 |
109 CAdblockPlusClient::CAdblockPlusClient() : CPluginClientBase() | 109 CAdblockPlusClient::CAdblockPlusClient() : CPluginClientBase() |
110 { | 110 { |
111 m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter()); | 111 m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter()); |
112 } | 112 } |
113 | 113 |
114 bool CAdblockPlusClient::CallEngine(Communication::OutputBuffer& message, Commun ication::InputBuffer& inputBuffer) | 114 bool CAdblockPlusClient::CallEngine(Communication::OutputBuffer& message, Commun ication::InputBuffer& inputBuffer) |
115 { | 115 { |
116 CriticalSection::Lock lock(enginePipeLock); | |
116 try | 117 try |
117 { | 118 { |
118 if (!enginePipe) | 119 if (!enginePipe) |
119 enginePipe.reset(OpenEnginePipe()); | 120 enginePipe.reset(OpenEnginePipe()); |
Oleksandr
2013/08/08 06:26:31
Might it make sense to have some sort of a thread
Felix Dahlke
2013/08/08 08:32:51
Do we use a single CAdblockPlusClient instance fro
| |
120 enginePipe->WriteMessage(message); | 121 enginePipe->WriteMessage(message); |
121 inputBuffer = enginePipe->ReadMessage(); | 122 inputBuffer = enginePipe->ReadMessage(); |
122 } | 123 } |
123 catch (const std::exception& e) | 124 catch (const std::exception& e) |
124 { | 125 { |
125 DEBUG_GENERAL(e.what()); | 126 DEBUG_GENERAL(e.what()); |
126 return false; | 127 return false; |
127 } | 128 } |
128 return true; | 129 return true; |
129 } | 130 } |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 | 427 |
427 std::wstring CAdblockPlusClient::GetDocumentationLink() | 428 std::wstring CAdblockPlusClient::GetDocumentationLink() |
428 { | 429 { |
429 Communication::InputBuffer response; | 430 Communication::InputBuffer response; |
430 if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response)) | 431 if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response)) |
431 return L""; | 432 return L""; |
432 std::wstring docLink; | 433 std::wstring docLink; |
433 response >> docLink; | 434 response >> docLink; |
434 return docLink; | 435 return docLink; |
435 } | 436 } |
LEFT | RIGHT |