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

Side by Side Diff: extensions/common/consumer.cc

Issue 822453002: Introduce HostID and de-couple Extensions from "script injection System" [browser side] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ConsumerIDFactory Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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 #include "extensions/common/consumer.h"
6
7 const int ConsumerID::kDefaultInstanceID = 0;
8 int ConsumerID::current_instance_id_ = ConsumerID::kDefaultInstanceID;
9
10 ConsumerID::ConsumerID()
11 : host_type_(ConsumerID::EXTENSIONS),
12 host_id_(std::string()),
13 instance_type_(ConsumerID::TAB),
14 instance_id_(ConsumerID::kDefaultInstanceID) {
15 }
16
17 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.
18 : host_type_(other.host_type()),
19 host_id_(other.host_id()),
20 instance_type_(other.instance_type()),
21 instance_id_(other.instance_id()) {
22 }
23
24 ConsumerID::ConsumerID(HostType host_type,
25 const std::string& host_id,
26 InstanceType instance_type,
27 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
28 : host_type_(host_type),
29 host_id_(host_id),
30 instance_type_(instance_type),
31 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.
32 }
33
34 // static
35 int ConsumerID::GetNextID() {
36 return ++current_instance_id_;
37 }
38
39 bool ConsumerID::operator<(const ConsumerID& id) const {
40 return host_type_ < id.host_type() ||
41 (host_type_ == id.host_type() && host_id_.compare(id.host_id()) < 0) ||
42 (host_type_ == id.host_type() && host_id_.compare(id.host_id()) == 0 &&
43 instance_type_ < id.instance_type()) ||
44 (host_type_ == id.host_type() && host_id_.compare(id.host_id()) == 0 &&
45 instance_type_ == id.instance_type() &&
46 instance_id_ < id.instance_id());
47 }
48
49 ConsumerID::~ConsumerID() {
50 }
51
52 Consumer::Consumer() {
53 }
54
55 Consumer::~Consumer() {
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698