cleanup_disabled_types_command.h revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2010 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#ifndef CHROME_BROWSER_SYNC_ENGINE_CLEANUP_DISABLED_TYPES_COMMAND_H_
6#define CHROME_BROWSER_SYNC_ENGINE_CLEANUP_DISABLED_TYPES_COMMAND_H_
7#pragma once
8
9#include "chrome/browser/sync/engine/syncer_command.h"
10
11namespace browser_sync {
12
13// A syncer command that purges (from memory and disk) entries belonging to
14// a ModelType or ServerModelType that the user has not elected to sync.
15//
16// This is done as part of a session to 1) ensure it does not block the UI,
17// and 2) avoid complicated races that could arise between a) deleting
18// things b) a sync session trying to use these things c) and the potential
19// re-enabling of the data type by the user before some scheduled deletion
20// took place.  Here, we are safe to perform I/O synchronously and we know it
21// is a safe time to delete as we are in the only active session.
22//
23// The removal from memory is done synchronously, while the disk purge is left
24// to an asynchronous SaveChanges operation.  However, all the updates for
25// meta data fields (such as initial_sync_ended) as well as the actual entry
26// deletions will be committed in a single sqlite transaction.  Thus it is
27// possible that disabled types re-appear (in the sync db) after a reboot,
28// but things will remain in a consistent state.  This kind of error case is
29// cared for in this command by retrying; see ExecuteImpl.
30class CleanupDisabledTypesCommand : public SyncerCommand {
31 public:
32  CleanupDisabledTypesCommand();
33  virtual ~CleanupDisabledTypesCommand();
34
35  // SyncerCommand implementation.
36  virtual void ExecuteImpl(sessions::SyncSession* session);
37
38 private:
39  DISALLOW_COPY_AND_ASSIGN(CleanupDisabledTypesCommand);
40};
41
42}  // namespace browser_sync
43
44#endif  // CHROME_BROWSER_SYNC_ENGINE_CLEANUP_DISABLED_TYPES_COMMAND_H_
45
46