Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_H_ | |
| 6 #define NET_WEBSOCKETS_WEBSOCKET_EXTENSION_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "net/base/net_export.h" | |
| 12 | |
| 13 namespace net { | |
| 14 | |
| 15 // A WebSocketExtension instance represents a WebSocket extension specified | |
| 16 // in RFC6455. | |
| 17 class NET_EXPORT_PRIVATE WebSocketExtension { | |
| 18 public: | |
| 19 // Note that RFC6455 does not allow a parameter with an empty value. | |
| 20 class Parameter { | |
| 21 public: | |
| 22 // Construct a parameter which does not have a value. | |
| 23 explicit Parameter(const std::string& name); | |
| 24 // Construct a parameter with a non-empty value. | |
| 25 Parameter(const std::string& name, const std::string& value); | |
| 26 | |
| 27 bool HasValue() const { return !value_.empty(); } | |
| 28 const std::string& name() const { return name_; } | |
| 29 const std::string& value() const { return value_; } | |
| 30 | |
| 31 bool operator == (const Parameter& other) const { | |
|
Adam Rice
2013/09/17 04:30:33
There should be no spaces around the == signs.
Al
yhirano
2013/09/17 06:03:31
Done.
| |
| 32 return name_ == other.name_ && value_ == other.value_; | |
| 33 } | |
| 34 | |
|
Adam Rice
2013/09/17 04:30:33
Please add a comment that you are using the compil
yhirano
2013/09/17 06:03:31
Done.
| |
| 35 private: | |
| 36 std::string name_; | |
| 37 std::string value_; | |
| 38 }; | |
| 39 | |
| 40 explicit WebSocketExtension(const std::string& name); | |
| 41 ~WebSocketExtension(); | |
| 42 | |
| 43 void Add(const Parameter& parameter) { parameters_.push_back(parameter); } | |
| 44 const std::string& name() const { return name_; } | |
| 45 const std::vector<Parameter>& parameters() const { return parameters_; } | |
| 46 | |
| 47 bool operator == (const WebSocketExtension& other) const { | |
| 48 return name_ == other.name_ && parameters_ == other.parameters_; | |
| 49 } | |
| 50 | |
| 51 private: | |
| 52 std::string name_; | |
| 53 std::vector<Parameter> parameters_; | |
| 54 }; | |
| 55 | |
| 56 } // namespace net | |
| 57 | |
| 58 #endif // NET_WEBSOCKETS_WEBSOCKET_EXTENSION_H_ | |
| OLD | NEW |