Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2035)

Unified Diff: net/websockets/websocket_extension_parser.h

Issue 1050013002: [WebSocketExtensionParser] Have Consume.* methods return bool instead of using has_error() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary variable Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/websockets/websocket_extension_parser.h
diff --git a/net/websockets/websocket_extension_parser.h b/net/websockets/websocket_extension_parser.h
index 6b2e4dc629873b50348d221283fe49d2afca5cc8..b78acce9245e3bb6bcbf92d11f76abbca77fd3d2 100644
--- a/net/websockets/websocket_extension_parser.h
+++ b/net/websockets/websocket_extension_parser.h
@@ -23,13 +23,13 @@ class NET_EXPORT_PRIVATE WebSocketExtensionParser {
//
// There must be no newline characters in the input. LWS-concatenation must
// have already been done before calling this method.
- void Parse(const char* data, size_t size);
- void Parse(const std::string& data) {
- Parse(data.data(), data.size());
+ //
+ // Returns true if the method was successful (no syntax error was found).
+ bool Parse(const char* data, size_t size);
+ bool Parse(const std::string& data) {
+ return Parse(data.data(), data.size());
}
- // Returns true if the last Parse() method call encountered any syntax error.
- bool has_error() const { return has_error_; }
// Returns the result of the last Parse() method call.
const std::vector<WebSocketExtension>& extensions() const {
return extensions_;
@@ -37,11 +37,11 @@ class NET_EXPORT_PRIVATE WebSocketExtensionParser {
private:
// TODO(tyoshino): Make the following methods return success/fail.
eroman 2015/04/06 19:07:52 You can now remove this TODO
tyoshino (SeeGerritForStatus) 2015/04/13 14:11:59 Done.
- void Consume(char c);
- void ConsumeExtension(WebSocketExtension* extension);
- void ConsumeExtensionParameter(WebSocketExtension::Parameter* parameter);
- void ConsumeToken(base::StringPiece* token);
- void ConsumeQuotedToken(std::string* token);
+ bool Consume(char c);
eroman 2015/04/06 19:07:52 Something else you may consider is to add WARN_UNU
tyoshino (SeeGerritForStatus) 2015/04/13 14:11:59 Done.
+ bool ConsumeExtension(WebSocketExtension* extension);
+ bool ConsumeExtensionParameter(WebSocketExtension::Parameter* parameter);
+ bool ConsumeToken(base::StringPiece* token);
+ bool ConsumeQuotedToken(std::string* token);
void ConsumeSpaces();
bool Lookahead(char c);
bool ConsumeIfMatch(char c);
@@ -54,7 +54,6 @@ class NET_EXPORT_PRIVATE WebSocketExtensionParser {
const char* current_;
// The pointer of the end of the input string.
const char* end_;
- bool has_error_;
std::vector<WebSocketExtension> extensions_;
DISALLOW_COPY_AND_ASSIGN(WebSocketExtensionParser);

Powered by Google App Engine
This is Rietveld 408576698