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

Delta Between Two Patch Sets: src/shared/Communication.cpp

Issue 11013110: Cleanup (Closed)
Left Patch Set: More refactoring. Removing main thread, tab counting. Implementing SetPref and GetPref. Addressing … Created July 9, 2013, 12:59 p.m.
Right 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:
Right: Side by side diff | Download
« no previous file with change/comment | « src/shared/Communication.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 24 matching lines...) Expand all
35 ReadBinary(currentType); 35 ReadBinary(currentType);
36 36
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 }
46
47 Communication::ValueType Communication::InputBuffer::GetType()
48 {
49 if (!hasType)
50 ReadBinary(currentType);
51
52 hasType = true;
53 return currentType;
45 } 54 }
46 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 {
(...skipping 77 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 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld