summaryrefslogtreecommitdiffstats
path: root/chromium/sync/syncable/scoped_parent_child_index_updater.cc
blob: 0dc3e95332399d1a0242d24d2d7cf62eee6621e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// 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 "sync/syncable/scoped_parent_child_index_updater.h"

#include "sync/syncable/parent_child_index.h"

namespace syncer {
namespace syncable {

ScopedParentChildIndexUpdater::ScopedParentChildIndexUpdater(
    ScopedKernelLock& proof_of_lock,
    EntryKernel* entry,
    ParentChildIndex* index) : entry_(entry), index_(index) {
  if (ParentChildIndex::ShouldInclude(entry_)) {
    index_->Remove(entry_);
  }
}

ScopedParentChildIndexUpdater::~ScopedParentChildIndexUpdater() {
  if (ParentChildIndex::ShouldInclude(entry_)) {
    index_->Insert(entry_);
  }
}

}  // namespace syncer
}  // namespace syncable