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

Unified Diff: chrome/browser/extensions/api/declarative/rule_identifier.cc

Issue 9315010: RulesRegistry for declarative APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implemented ID and priority generation Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698