Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / sync_file_system / drive_backend / tracker_id_set.cc
blob9fc4bbabb18645ed497236d94e93c4e648237e90
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.
5 #include "chrome/browser/sync_file_system/drive_backend/tracker_id_set.h"
7 #include "base/logging.h"
8 #include "base/stl_util.h"
9 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
11 namespace sync_file_system {
12 namespace drive_backend {
14 TrackerIDSet::TrackerIDSet() : active_tracker_(0) {}
16 TrackerIDSet::~TrackerIDSet() {}
18 void TrackerIDSet::Insert(const FileTracker& tracker) {
19 if (tracker.active())
20 InsertActiveTracker(tracker.tracker_id());
21 else
22 InsertInactiveTracker(tracker.tracker_id());
25 void TrackerIDSet::InsertActiveTracker(int64 tracker_id) {
26 DCHECK(tracker_id);
27 DCHECK(!active_tracker_);
29 active_tracker_ = tracker_id;
30 tracker_ids_.insert(tracker_id);
33 void TrackerIDSet::InsertInactiveTracker(int64 tracker_id) {
34 DCHECK(tracker_id);
35 DCHECK_NE(active_tracker_, tracker_id);
37 tracker_ids_.insert(tracker_id);
40 void TrackerIDSet::Erase(int64 tracker_id) {
41 DCHECK(ContainsKey(tracker_ids_, tracker_id));
43 if (active_tracker_ == tracker_id)
44 active_tracker_ = 0;
45 tracker_ids_.erase(tracker_id);
48 void TrackerIDSet::Activate(int64 tracker_id) {
49 DCHECK(!active_tracker_);
50 DCHECK(ContainsKey(tracker_ids_, tracker_id));
51 active_tracker_ = tracker_id;
54 void TrackerIDSet::Deactivate(int64 tracker_id) {
55 DCHECK_EQ(active_tracker_, tracker_id);
56 DCHECK(ContainsKey(tracker_ids_, tracker_id));
57 active_tracker_ = 0;
60 } // namespace drive_backend
61 } // namespace sync_file_system