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

Side by Side Diff: chrome/browser/sync/engine/cleanup_disabled_types_command.cc

Issue 9699057: [Sync] Move 'sync' target to sync/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Tim's comments Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
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 "chrome/browser/sync/engine/cleanup_disabled_types_command.h"
6
7 #include <algorithm>
8
9 #include "chrome/browser/sync/sessions/sync_session.h"
10 #include "chrome/browser/sync/sessions/sync_session_context.h"
11 #include "chrome/browser/sync/syncable/model_type.h"
12 #include "chrome/browser/sync/syncable/syncable.h"
13
14 namespace browser_sync {
15
16 CleanupDisabledTypesCommand::CleanupDisabledTypesCommand() {}
17 CleanupDisabledTypesCommand::~CleanupDisabledTypesCommand() {}
18
19 SyncerError CleanupDisabledTypesCommand::ExecuteImpl(
20 sessions::SyncSession* session) {
21 using syncable::ModelTypeSet;
22 using syncable::ModelTypeSetToString;
23 // Because a full directory purge is slow, we avoid purging
24 // undesired types unless we have reason to believe they were
25 // previously enabled. Because purging could theoretically fail on
26 // the first sync session (when there's no previous routing info) we
27 // pay the full directory scan price once and do a "deep clean" of
28 // types that may potentially need cleanup so that we converge to
29 // the correct state.
30 //
31 // in_previous | !in_previous
32 // |
33 // initial_sync_ended should clean | may have attempted cleanup
34 // !initial_sync_ended should clean | may have never been enabled, or
35 // | could have been disabled before
36 // | initial sync ended and cleanup
37 // | may not have happened yet
38 // | (failure, browser restart
39 // | before another sync session,..)
40
41 const ModelTypeSet enabled_types =
42 GetRoutingInfoTypes(session->routing_info());
43
44 const ModelTypeSet previous_enabled_types =
45 GetRoutingInfoTypes(
46 session->context()->previous_session_routing_info());
47
48 ModelTypeSet to_cleanup = Difference(ModelTypeSet::All(), enabled_types);
49
50 // If |previous_enabled_types| is non-empty (i.e., not the first
51 // sync session), set |to_cleanup| to its intersection with
52 // |previous_enabled_types|.
53 if (!previous_enabled_types.Empty()) {
54 to_cleanup.RetainAll(previous_enabled_types);
55 }
56
57 DVLOG(1) << "enabled_types = " << ModelTypeSetToString(enabled_types)
58 << ", previous_enabled_types = "
59 << ModelTypeSetToString(previous_enabled_types)
60 << ", to_cleanup = " << ModelTypeSetToString(to_cleanup);
61
62 if (to_cleanup.Empty())
63 return SYNCER_OK;
64
65 session->context()->directory()->PurgeEntriesWithTypeIn(to_cleanup);
66 return SYNCER_OK;
67 }
68
69 } // namespace browser_sync
70
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698