| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/websockets/websocket_extension.h" | 5 #include "net/websockets/websocket_extension.h" |
| 6 | 6 |
| 7 #include <map> |
| 7 #include <string> | 8 #include <string> |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 | 11 |
| 11 namespace net { | 12 namespace net { |
| 12 | 13 |
| 13 WebSocketExtension::Parameter::Parameter(const std::string& name) | 14 WebSocketExtension::Parameter::Parameter(const std::string& name) |
| 14 : name_(name) {} | 15 : name_(name) {} |
| 15 | 16 |
| 16 WebSocketExtension::Parameter::Parameter(const std::string& name, | 17 WebSocketExtension::Parameter::Parameter(const std::string& name, |
| 17 const std::string& value) | 18 const std::string& value) |
| 18 : name_(name), value_(value) { | 19 : name_(name), value_(value) { |
| 19 DCHECK(!value.empty()); | 20 DCHECK(!value.empty()); |
| 20 } | 21 } |
| 21 | 22 |
| 22 bool WebSocketExtension::Parameter::Equals(const Parameter& other) const { | 23 bool WebSocketExtension::Parameter::Equals(const Parameter& other) const { |
| 23 return name_ == other.name_ && value_ == other.value_; | 24 return name_ == other.name_ && value_ == other.value_; |
| 24 } | 25 } |
| 25 | 26 |
| 26 WebSocketExtension::WebSocketExtension() {} | 27 WebSocketExtension::WebSocketExtension() {} |
| 27 | 28 |
| 28 WebSocketExtension::WebSocketExtension(const std::string& name) | 29 WebSocketExtension::WebSocketExtension(const std::string& name) |
| 29 : name_(name) {} | 30 : name_(name) {} |
| 30 | 31 |
| 31 WebSocketExtension::~WebSocketExtension() {} | 32 WebSocketExtension::~WebSocketExtension() {} |
| 32 | 33 |
| 33 bool WebSocketExtension::Equals(const WebSocketExtension& other) const { | 34 bool WebSocketExtension::Equals(const WebSocketExtension& other) const { |
| 34 if (name_ != other.name_) return false; | 35 if (name_ != other.name_) return false; |
| 35 if (parameters_.size() != other.parameters_.size()) return false; | 36 if (parameters_.size() != other.parameters_.size()) return false; |
| 36 for (size_t i = 0; i < other.parameters_.size(); ++i) { | 37 |
| 37 if (!parameters_[i].Equals(other.parameters_[i])) | 38 std::multimap<std::string, std::string> this_parameters, other_parameters; |
| 38 return false; | 39 for (const auto& p : parameters_) { |
| 40 this_parameters.insert(std::make_pair(p.name(), p.value())); |
| 39 } | 41 } |
| 40 return true; | 42 for (const auto& p : other.parameters_) { |
| 43 other_parameters.insert(std::make_pair(p.name(), p.value())); |
| 44 } |
| 45 return this_parameters == other_parameters; |
| 41 } | 46 } |
| 42 | 47 |
| 43 } // namespace net | 48 } // namespace net |
| OLD | NEW |