1// Copyright (c) 2012 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 "sync/syncable/scoped_parent_child_index_updater.h"
6
7#include "sync/syncable/parent_child_index.h"
8
9namespace syncer {
10namespace syncable {
11
12ScopedParentChildIndexUpdater::ScopedParentChildIndexUpdater(
13    ScopedKernelLock& proof_of_lock,
14    EntryKernel* entry,
15    ParentChildIndex* index) : entry_(entry), index_(index) {
16  if (ParentChildIndex::ShouldInclude(entry_)) {
17    index_->Remove(entry_);
18  }
19}
20
21ScopedParentChildIndexUpdater::~ScopedParentChildIndexUpdater() {
22  if (ParentChildIndex::ShouldInclude(entry_)) {
23    index_->Insert(entry_);
24  }
25}
26
27}  // namespace syncer
28}  // namespace syncable
29