Chromium Code Reviews| Index: extensions/common/consumer.cc |
| diff --git a/extensions/common/consumer.cc b/extensions/common/consumer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..60f4e9739802063768cf74debb478b8b381870d9 |
| --- /dev/null |
| +++ b/extensions/common/consumer.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2014 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 "extensions/common/consumer.h" |
| + |
| +const int ConsumerID::kDefaultInstanceID = 0; |
| +int ConsumerID::current_instance_id_ = ConsumerID::kDefaultInstanceID; |
| + |
| +ConsumerID::ConsumerID() |
| + : host_type_(ConsumerID::EXTENSIONS), |
| + host_id_(std::string()), |
| + instance_type_(ConsumerID::TAB), |
| + instance_id_(ConsumerID::kDefaultInstanceID) { |
| +} |
| + |
| +ConsumerID::ConsumerID(const ConsumerID& other) |
|
Fady Samuel
2015/01/09 22:07:24
What about having a single InvalidConsumerID? See
Xi Han
2015/01/09 22:59:33
Good idea, updated.
|
| + : host_type_(other.host_type()), |
| + host_id_(other.host_id()), |
| + instance_type_(other.instance_type()), |
| + instance_id_(other.instance_id()) { |
| +} |
| + |
| +ConsumerID::ConsumerID(HostType host_type, |
| + const std::string& host_id, |
| + InstanceType instance_type, |
| + int instance_id) |
|
Fady Samuel
2015/01/09 22:07:24
Get rid of this.
Xi Han
2015/01/09 22:59:32
As discuss offline, this constructor is still need
|
| + : host_type_(host_type), |
| + host_id_(host_id), |
| + instance_type_(instance_type), |
| + instance_id_(instance_id) { |
|
Fady Samuel
2015/01/09 22:07:24
instance_id_(++current_instance_id_)
Xi Han
2015/01/09 22:59:32
Same reason as above.
|
| +} |
| + |
| +// static |
| +int ConsumerID::GetNextID() { |
| + return ++current_instance_id_; |
| +} |
| + |
| +bool ConsumerID::operator<(const ConsumerID& id) const { |
| + return host_type_ < id.host_type() || |
| + (host_type_ == id.host_type() && host_id_.compare(id.host_id()) < 0) || |
| + (host_type_ == id.host_type() && host_id_.compare(id.host_id()) == 0 && |
| + instance_type_ < id.instance_type()) || |
| + (host_type_ == id.host_type() && host_id_.compare(id.host_id()) == 0 && |
| + instance_type_ == id.instance_type() && |
| + instance_id_ < id.instance_id()); |
| +} |
| + |
| +ConsumerID::~ConsumerID() { |
| +} |
| + |
| +Consumer::Consumer() { |
| +} |
| + |
| +Consumer::~Consumer() { |
| +} |