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

Unified Diff: src/shared/Communication.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
« src/plugin/AdblockPlusClient.cpp ('K') | « src/shared/Communication.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/shared/Communication.cpp
===================================================================
--- a/src/shared/Communication.cpp
+++ b/src/shared/Communication.cpp
@@ -63,6 +63,11 @@
{
}
+Communication::PipeDisconnectedError::PipeDisconnectedError()
+ : std::runtime_error("Pipe disconnected")
+{
+}
+
Communication::Pipe::Pipe(const std::wstring& pipeName, Communication::Pipe::Mode mode)
{
pipe = INVALID_HANDLE_VALUE;
@@ -128,11 +133,20 @@
DWORD bytesRead;
if (ReadFile(pipe, buffer.get(), bufferSize * sizeof(char), &bytesRead, 0))
doneReading = true;
- else if (GetLastError() != ERROR_MORE_DATA)
+ else
{
- std::stringstream stream;
- stream << "Error reading from pipe: " << GetLastError();
- throw std::runtime_error(stream.str());
+ DWORD lastError = GetLastError();
+ switch (lastError)
+ {
+ case ERROR_MORE_DATA:
+ break;
+ case ERROR_BROKEN_PIPE:
+ throw PipeDisconnectedError();
+ default:
+ std::stringstream stream;
+ stream << "Error reading from pipe: " << lastError;
+ throw std::runtime_error(stream.str());
+ }
}
stream << std::string(buffer.get(), bytesRead);
}
« src/plugin/AdblockPlusClient.cpp ('K') | « src/shared/Communication.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld