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

Side by Side Diff: net/websockets/websocket_extension_parser.h

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « net/websockets/websocket_extension.cc ('k') | net/websockets/websocket_extension_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
7
8 #include <string>
9
10 #include "base/strings/string_piece.h"
11 #include "net/base/net_export.h"
12 #include "net/websockets/websocket_extension.h"
13
14 namespace net {
15
16 class NET_EXPORT_PRIVATE WebSocketExtensionParser {
17 public:
18 WebSocketExtensionParser();
19 ~WebSocketExtensionParser();
20
21 // Parses the given string as a WebSocket extension header value.
22 // This parser assumes some preprocesses are made.
23 // - The parser parses single extension at a time. This means that
24 // the parser parses |extension| in RFC6455 9.1, not |extension-list|.
25 // - There is no newline characters in the input. LWS-concatenation must
26 // have already been done.
27 void Parse(const char* data, size_t size);
28 void Parse(const std::string& data) {
29 Parse(data.data(), data.size());
30 }
31
32 bool has_error() const { return has_error_; }
33 const WebSocketExtension& extension() const { return extension_; }
34
35 private:
36 void Consume(char c);
37 void ConsumeExtension(WebSocketExtension* extension);
38 void ConsumeExtensionParameter(WebSocketExtension::Parameter* parameter);
39 void ConsumeToken(base::StringPiece* token);
40 void ConsumeQuotedToken(std::string* token);
41 void ConsumeSpaces();
42 bool Lookahead(char c);
43 bool ConsumeIfMatch(char c);
44 size_t UnconsumedBytes() const { return end_ - current_; }
45
46 static bool IsControl(char c);
47 static bool IsSeparator(char c);
48
49 const char* current_;
50 const char* end_;
51 bool has_error_;
52 WebSocketExtension extension_;
53
54 DISALLOW_COPY_AND_ASSIGN(WebSocketExtensionParser);
55 };
56
57 } // namespace net
58
59 #endif // NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
OLDNEW
« no previous file with comments | « net/websockets/websocket_extension.cc ('k') | net/websockets/websocket_extension_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698