Chromium Code Reviews| Index: chrome/browser/extensions/api/declarative/rule_identifier.cc |
| diff --git a/chrome/browser/extensions/api/declarative/rule_identifier.cc b/chrome/browser/extensions/api/declarative/rule_identifier.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..76d9fbbebb18739cfa055e8e5707a36c0ec4e596 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/declarative/rule_identifier.cc |
| @@ -0,0 +1,41 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/extensions/api/declarative/rule_identifier.h" |
| + |
| +namespace extensions { |
| + |
| +RuleIdentifier::RuleIdentifier(const std::string& extension_id, |
|
Aaron Boodman
2012/02/02 16:28:51
unit test?
battre
2012/02/06 16:21:04
Done.
|
| + const std::string& event_name, |
| + const std::string& rule_id) |
| + : extension_id_(extension_id), |
| + event_name_(event_name), |
| + rule_id_(rule_id) {} |
| + |
| +RuleIdentifier::RuleIdentifier(const RuleIdentifier& other) |
| +: extension_id_(other.extension_id_), |
| + event_name_(other.event_name_), |
| + rule_id_(other.rule_id_) {} |
| + |
| +RuleIdentifier::~RuleIdentifier() {} |
| + |
| +bool RuleIdentifier::operator<(const RuleIdentifier& other) const { |
| + // These are ordered so that the elements with most entropy are compared |
| + // first. |
| + if (rule_id_ < other.rule_id_) return true; |
| + if (rule_id_ > other.rule_id_) return false; |
| + if (event_name_ < other.event_name_) return true; |
| + if (event_name_ > other.event_name_) return false; |
| + if (extension_id_ < other.extension_id_) return true; |
| + return false; |
| +} |
| + |
| +RuleIdentifier& RuleIdentifier::operator=(const RuleIdentifier& other) { |
| + extension_id_ = other.extension_id_; |
| + event_name_ = other.event_name_; |
| + rule_id_ = other.rule_id_; |
| + return *this; |
| +} |
| + |
| +} // extensions |