Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / net / websockets / websocket_extension_parser.h
blob6b2e4dc629873b50348d221283fe49d2afca5cc8
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.
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
8 #include <string>
9 #include <vector>
11 #include "base/strings/string_piece.h"
12 #include "net/base/net_export.h"
13 #include "net/websockets/websocket_extension.h"
15 namespace net {
17 class NET_EXPORT_PRIVATE WebSocketExtensionParser {
18 public:
19 WebSocketExtensionParser();
20 ~WebSocketExtensionParser();
22 // Parses the given string as a Sec-WebSocket-Extensions header value.
24 // There must be no newline characters in the input. LWS-concatenation must
25 // have already been done before calling this method.
26 void Parse(const char* data, size_t size);
27 void Parse(const std::string& data) {
28 Parse(data.data(), data.size());
31 // Returns true if the last Parse() method call encountered any syntax error.
32 bool has_error() const { return has_error_; }
33 // Returns the result of the last Parse() method call.
34 const std::vector<WebSocketExtension>& extensions() const {
35 return extensions_;
38 private:
39 // TODO(tyoshino): Make the following methods return success/fail.
40 void Consume(char c);
41 void ConsumeExtension(WebSocketExtension* extension);
42 void ConsumeExtensionParameter(WebSocketExtension::Parameter* parameter);
43 void ConsumeToken(base::StringPiece* token);
44 void ConsumeQuotedToken(std::string* token);
45 void ConsumeSpaces();
46 bool Lookahead(char c);
47 bool ConsumeIfMatch(char c);
48 size_t UnconsumedBytes() const { return end_ - current_; }
50 static bool IsControl(char c);
51 static bool IsSeparator(char c);
53 // The current position in the input string.
54 const char* current_;
55 // The pointer of the end of the input string.
56 const char* end_;
57 bool has_error_;
58 std::vector<WebSocketExtension> extensions_;
60 DISALLOW_COPY_AND_ASSIGN(WebSocketExtensionParser);
63 } // namespace net
65 #endif // NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_