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

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: Addressed #7, Rebased Created 5 years, 8 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
« no previous file with comments | « net/websockets/websocket_basic_handshake_stream.cc ('k') | net/websockets/websocket_extension_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..007040de291408aa411fa24eb172a7db6c6246e7 100644
--- a/net/websockets/websocket_extension_parser.h
+++ b/net/websockets/websocket_extension_parser.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/compiler_specific.h"
#include "base/strings/string_piece.h"
#include "net/base/net_export.h"
#include "net/websockets/websocket_extension.h"
@@ -23,28 +24,28 @@ 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_;
}
private:
- // TODO(tyoshino): Make the following methods return success/fail.
- void Consume(char c);
- void ConsumeExtension(WebSocketExtension* extension);
- void ConsumeExtensionParameter(WebSocketExtension::Parameter* parameter);
- void ConsumeToken(base::StringPiece* token);
- void ConsumeQuotedToken(std::string* token);
+ WARN_UNUSED_RESULT bool Consume(char c);
+ WARN_UNUSED_RESULT bool ConsumeExtension(WebSocketExtension* extension);
+ WARN_UNUSED_RESULT bool ConsumeExtensionParameter(
+ WebSocketExtension::Parameter* parameter);
+ WARN_UNUSED_RESULT bool ConsumeToken(base::StringPiece* token);
+ WARN_UNUSED_RESULT bool ConsumeQuotedToken(std::string* token);
void ConsumeSpaces();
- bool Lookahead(char c);
- bool ConsumeIfMatch(char c);
+ WARN_UNUSED_RESULT bool Lookahead(char c);
+ WARN_UNUSED_RESULT bool ConsumeIfMatch(char c);
size_t UnconsumedBytes() const { return end_ - current_; }
static bool IsControl(char c);
@@ -54,7 +55,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);
« no previous file with comments | « net/websockets/websocket_basic_handshake_stream.cc ('k') | net/websockets/websocket_extension_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698