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

Side by Side Diff: chrome/browser/sync/engine/syncer.h

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
« no previous file with comments | « chrome/browser/sync/engine/syncapi_internal.cc ('k') | chrome/browser/sync/engine/syncer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_
6 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_
7 #pragma once
8
9 #include <utility>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/synchronization/lock.h"
16 #include "chrome/browser/sync/engine/conflict_resolver.h"
17 #include "chrome/browser/sync/engine/syncer_types.h"
18 #include "chrome/browser/sync/engine/syncproto.h"
19 #include "chrome/browser/sync/sessions/sync_session.h"
20 #include "chrome/browser/sync/syncable/model_type.h"
21 #include "chrome/browser/sync/util/extensions_activity_monitor.h"
22
23 namespace syncable {
24 class Entry;
25 class MutableEntry;
26 } // namespace syncable
27
28 namespace browser_sync {
29
30 enum SyncerStep {
31 SYNCER_BEGIN,
32 CLEANUP_DISABLED_TYPES,
33 DOWNLOAD_UPDATES,
34 PROCESS_CLIENT_COMMAND,
35 VERIFY_UPDATES,
36 PROCESS_UPDATES,
37 STORE_TIMESTAMPS,
38 APPLY_UPDATES,
39 BUILD_COMMIT_REQUEST,
40 POST_COMMIT_MESSAGE,
41 PROCESS_COMMIT_RESPONSE,
42 RESOLVE_CONFLICTS,
43 APPLY_UPDATES_TO_RESOLVE_CONFLICTS,
44 CLEAR_PRIVATE_DATA, // TODO(tim): Rename 'private' to 'user'.
45 SYNCER_END
46 };
47
48 // A Syncer provides a control interface for driving the individual steps
49 // of the sync cycle. Each cycle (hopefully) moves the client into closer
50 // synchronization with the server. The individual steps are modeled
51 // as SyncerCommands, and the ordering of the steps is expressed using
52 // the SyncerStep enum.
53 //
54 // A Syncer instance expects to run on a dedicated thread. Calls
55 // to SyncShare() may take an unbounded amount of time, as SyncerCommands
56 // may block on network i/o, on lock contention, or on tasks posted to
57 // other threads.
58 class Syncer {
59 public:
60 typedef std::vector<int64> UnsyncedMetaHandles;
61
62 Syncer();
63 virtual ~Syncer();
64
65 // Called by other threads to tell the syncer to stop what it's doing
66 // and return early from SyncShare, if possible.
67 bool ExitRequested();
68 void RequestEarlyExit();
69
70 // Runs a sync cycle from |first_step| to |last_step|.
71 virtual void SyncShare(sessions::SyncSession* session,
72 SyncerStep first_step,
73 SyncerStep last_step);
74
75 private:
76 // Implements the PROCESS_CLIENT_COMMAND syncer step.
77 void ProcessClientCommand(sessions::SyncSession* session);
78
79 bool early_exit_requested_;
80 base::Lock early_exit_requested_lock_;
81
82 ConflictResolver resolver_;
83
84 friend class SyncerTest;
85 FRIEND_TEST_ALL_PREFIXES(SyncerTest, NameClashWithResolver);
86 FRIEND_TEST_ALL_PREFIXES(SyncerTest, IllegalAndLegalUpdates);
87 FRIEND_TEST_ALL_PREFIXES(SyncerTest, TestCommitListOrderingAndNewParent);
88 FRIEND_TEST_ALL_PREFIXES(SyncerTest,
89 TestCommitListOrderingAndNewParentAndChild);
90 FRIEND_TEST_ALL_PREFIXES(SyncerTest, TestCommitListOrderingCounterexample);
91 FRIEND_TEST_ALL_PREFIXES(SyncerTest, TestCommitListOrderingWithNesting);
92 FRIEND_TEST_ALL_PREFIXES(SyncerTest, TestCommitListOrderingWithNewItems);
93 FRIEND_TEST_ALL_PREFIXES(SyncerTest, TestGetUnsyncedAndSimpleCommit);
94 FRIEND_TEST_ALL_PREFIXES(SyncerTest, TestPurgeWhileUnsynced);
95 FRIEND_TEST_ALL_PREFIXES(SyncerTest, TestPurgeWhileUnapplied);
96 FRIEND_TEST_ALL_PREFIXES(SyncerTest, UnappliedUpdateDuringCommit);
97 FRIEND_TEST_ALL_PREFIXES(SyncerTest, DeletingEntryInFolder);
98 FRIEND_TEST_ALL_PREFIXES(SyncerTest,
99 LongChangelistCreatesFakeOrphanedEntries);
100 FRIEND_TEST_ALL_PREFIXES(SyncerTest, QuicklyMergeDualCreatedHierarchy);
101 FRIEND_TEST_ALL_PREFIXES(SyncerTest, LongChangelistWithApplicationConflict);
102 FRIEND_TEST_ALL_PREFIXES(SyncerTest, DeletingEntryWithLocalEdits);
103 FRIEND_TEST_ALL_PREFIXES(EntryCreatedInNewFolderTest,
104 EntryCreatedInNewFolderMidSync);
105
106 DISALLOW_COPY_AND_ASSIGN(Syncer);
107 };
108
109 // Utility function declarations.
110 void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest);
111 void ClearServerData(syncable::MutableEntry* entry);
112 const char* SyncerStepToString(const SyncerStep);
113
114 } // namespace browser_sync
115
116 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncapi_internal.cc ('k') | chrome/browser/sync/engine/syncer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698