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

Side by Side Diff: src/shared/Communication.cpp

Issue 11013110: Cleanup (Closed)
Patch Set: More beautification and addressing comments Created July 29, 2013, 12:13 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 | « src/shared/Communication.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include <Windows.h> 1 #include <Windows.h>
2 #include <Lmcons.h> 2 #include <Lmcons.h>
3 #include <Sddl.h> 3 #include <Sddl.h>
4 4
5 #include "Communication.h" 5 #include "Communication.h"
6 #include "Utils.h" 6 #include "Utils.h"
7 7
8 namespace 8 namespace
9 { 9 {
10 const int bufferSize = 1024; 10 const int bufferSize = 1024;
(...skipping 26 matching lines...) Expand all
37 if (currentType != expectedType) 37 if (currentType != expectedType)
38 { 38 {
39 // Make sure we don't attempt to read the type again 39 // Make sure we don't attempt to read the type again
40 hasType = true; 40 hasType = true;
41 throw new std::runtime_error("Unexpected type found in input buffer"); 41 throw new std::runtime_error("Unexpected type found in input buffer");
42 } 42 }
43 else 43 else
44 hasType = false; 44 hasType = false;
45 } 45 }
46 46
47 Communication::ValueType Communication::InputBuffer::GetType()
48 {
49 if (!hasType)
50 ReadBinary(currentType);
51
52 hasType = true;
53 return currentType;
54 }
55
47 Communication::PipeConnectionError::PipeConnectionError() 56 Communication::PipeConnectionError::PipeConnectionError()
48 : std::runtime_error(AppendErrorCode("Unable to connect to a named pipe")) 57 : std::runtime_error(AppendErrorCode("Unable to connect to a named pipe"))
49 { 58 {
50 } 59 }
51 60
52 Communication::PipeBusyError::PipeBusyError() 61 Communication::PipeBusyError::PipeBusyError()
53 : std::runtime_error("Timeout while trying to connect to a named pipe, pipe is busy") 62 : std::runtime_error("Timeout while trying to connect to a named pipe, pipe is busy")
54 { 63 {
55 } 64 }
56 65
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 141
133 void Communication::Pipe::WriteMessage(Communication::OutputBuffer& message) 142 void Communication::Pipe::WriteMessage(Communication::OutputBuffer& message)
134 { 143 {
135 DWORD bytesWritten; 144 DWORD bytesWritten;
136 std::string data = message.Get(); 145 std::string data = message.Get();
137 if (!data.length()) 146 if (!data.length())
138 return; 147 return;
139 if (!WriteFile(pipe, data.c_str(), data.length(), &bytesWritten, 0)) 148 if (!WriteFile(pipe, data.c_str(), data.length(), &bytesWritten, 0))
140 throw std::runtime_error("Failed to write to pipe"); 149 throw std::runtime_error("Failed to write to pipe");
141 } 150 }
OLDNEW
« no previous file with comments | « src/shared/Communication.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld