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

Unified Diff: src/plugin/AdblockPlusClient.cpp

Issue 11430025: Shut down the engine when the last tab is closed (Closed)
Patch Set: Created Aug. 7, 2013, 2:57 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/AdblockPlusClient.h ('k') | src/shared/Communication.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/AdblockPlusClient.cpp
===================================================================
--- a/src/plugin/AdblockPlusClient.cpp
+++ b/src/plugin/AdblockPlusClient.cpp
@@ -38,11 +38,11 @@
CloseHandle(processInformation.hThread);
}
- std::auto_ptr<Communication::Pipe> OpenAdblockPlusEnginePipe()
+ Communication::Pipe* OpenEnginePipe()
{
try
{
- return std::auto_ptr<Communication::Pipe>(new Communication::Pipe(Communication::pipeName, Communication::Pipe::MODE_CONNECT));
+ return new Communication::Pipe(Communication::pipeName, Communication::Pipe::MODE_CONNECT);
}
catch (Communication::PipeConnectionError e)
{
@@ -54,7 +54,7 @@
Sleep(step);
try
{
- return std::auto_ptr<Communication::Pipe>(new Communication::Pipe(Communication::pipeName, Communication::Pipe::MODE_CONNECT));
+ return new Communication::Pipe(Communication::pipeName, Communication::Pipe::MODE_CONNECT);
}
catch (Communication::PipeConnectionError e)
{
@@ -102,29 +102,6 @@
}
return result;
}
-
- bool CallEngine(Communication::OutputBuffer& message, Communication::InputBuffer& inputBuffer = Communication::InputBuffer())
- {
- try
- {
- std::auto_ptr<Communication::Pipe> pipe = OpenAdblockPlusEnginePipe();
- pipe->WriteMessage(message);
- inputBuffer = pipe->ReadMessage();
- }
- catch (const std::exception& e)
- {
- DEBUG_GENERAL(e.what());
- return false;
- }
- return true;
- }
-
- bool CallEngine(Communication::ProcType proc, Communication::InputBuffer& inputBuffer = Communication::InputBuffer())
- {
- Communication::OutputBuffer message;
- message << proc;
- return CallEngine(message, inputBuffer);
- }
}
CAdblockPlusClient* CAdblockPlusClient::s_instance = NULL;
@@ -134,6 +111,30 @@
m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter());
}
+bool CAdblockPlusClient::CallEngine(Communication::OutputBuffer& message, Communication::InputBuffer& inputBuffer)
+{
+ try
+ {
+ if (!enginePipe)
+ 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
+ enginePipe->WriteMessage(message);
+ inputBuffer = enginePipe->ReadMessage();
+ }
+ catch (const std::exception& e)
+ {
+ DEBUG_GENERAL(e.what());
+ return false;
+ }
+ return true;
+}
+
+bool CAdblockPlusClient::CallEngine(Communication::ProcType proc, Communication::InputBuffer& inputBuffer)
+{
+ Communication::OutputBuffer message;
+ message << proc;
+ return CallEngine(message, inputBuffer);
+}
+
CAdblockPlusClient::~CAdblockPlusClient()
{
s_instance = NULL;
« no previous file with comments | « src/plugin/AdblockPlusClient.h ('k') | src/shared/Communication.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld