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

Side by Side Diff: chrome/browser/sync/engine/syncer_types.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
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_TYPES_H_
6 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_TYPES_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11 #include <vector>
12
13 #include "base/observer_list.h"
14 #include "chrome/browser/sync/syncable/model_type.h"
15
16 namespace syncable {
17 class Id;
18 }
19
20 // The intent of this is to keep all shared data types and enums for the syncer
21 // in a single place without having dependencies between other files.
22 namespace browser_sync {
23
24 namespace sessions {
25 struct SyncSessionSnapshot;
26 }
27 class Syncer;
28
29 enum UpdateAttemptResponse {
30 // Update was applied or safely ignored.
31 SUCCESS,
32
33 // The conditions described by the following enum values are not mutually
34 // exclusive. The list has been ordered according to priority in the case of
35 // overlap, with highest priority first.
36 //
37 // For example, in the case where an item had both the IS_UNSYCNED and
38 // IS_UNAPPLIED_UPDATE flags set (CONFLICT_SIMPLE), and a SERVER_PARENT_ID
39 // that, if applied, would cause a directory loop (CONFLICT_HIERARCHY), and
40 // specifics that we can't decrypt right now (CONFLICT_ENCRYPTION), the
41 // UpdateApplicator would return CONFLICT_ENCRYPTION when attempting to
42 // process the item.
43 //
44 // We do not attempt to resolve CONFLICT_HIERARCHY or CONFLICT_ENCRYPTION
45 // items. We will leave these updates unapplied and wait for the server
46 // to send us newer updates that will resolve the conflict.
47
48 // We were unable to decrypt/encrypt this server data. As such, we can't make
49 // forward progress on this node, but because the passphrase may not arrive
50 // until later we don't want to get the syncer stuck. See UpdateApplicator
51 // for how this is handled.
52 CONFLICT_ENCRYPTION,
53
54 // These are some updates that, if applied, would violate the tree's
55 // invariants. Examples of this include the server adding children to locally
56 // deleted directories and directory moves that would create loops.
57 CONFLICT_HIERARCHY,
58
59 // This indicates that item was modified both remotely (IS_UNAPPLIED_UPDATE)
60 // and locally (IS_UNSYNCED). We use the ConflictResolver to decide which of
61 // the changes should take priority, or if we can possibly merge the data.
62 CONFLICT_SIMPLE
63 };
64
65 enum ServerUpdateProcessingResult {
66 // Success. Update applied and stored in SERVER_* fields or dropped if
67 // irrelevant.
68 SUCCESS_PROCESSED,
69
70 // Success. Update details stored in SERVER_* fields, but wasn't applied.
71 SUCCESS_STORED,
72
73 // Update is illegally inconsistent with earlier updates. e.g. A bookmark
74 // becoming a folder.
75 FAILED_INCONSISTENT,
76
77 // Update is illegal when considered alone. e.g. broken UTF-8 in the name.
78 FAILED_CORRUPT,
79
80 // Only used by VerifyUpdate. Indicates that an update is valid. As
81 // VerifyUpdate cannot return SUCCESS_STORED, we reuse the value.
82 SUCCESS_VALID = SUCCESS_STORED
83 };
84
85 // Different results from the verify phase will yield different methods of
86 // processing in the ProcessUpdates phase. The SKIP result means the entry
87 // doesn't go to the ProcessUpdates phase.
88 enum VerifyResult {
89 VERIFY_FAIL,
90 VERIFY_SUCCESS,
91 VERIFY_UNDELETE,
92 VERIFY_SKIP,
93 VERIFY_UNDECIDED
94 };
95
96 enum VerifyCommitResult {
97 VERIFY_UNSYNCABLE,
98 VERIFY_OK,
99 };
100
101 struct SyncEngineEvent {
102 enum EventCause {
103 ////////////////////////////////////////////////////////////////
104 // Sent on entry of Syncer state machine
105 SYNC_CYCLE_BEGIN,
106
107 // SyncerCommand generated events.
108 STATUS_CHANGED,
109
110 // We have reached the SYNCER_END state in the main sync loop.
111 SYNC_CYCLE_ENDED,
112
113 ////////////////////////////////////////////////////////////////
114 // Generated in response to specific protocol actions or events.
115
116 // New token in updated_token.
117 UPDATED_TOKEN,
118
119 // This is sent after the Syncer (and SyncerThread) have initiated self
120 // halt due to no longer being permitted to communicate with the server.
121 // The listener should sever the sync / browser connections and delete sync
122 // data (i.e. as if the user clicked 'Stop Syncing' in the browser.
123 STOP_SYNCING_PERMANENTLY,
124
125 // These events are sent to indicate when we know the clearing of
126 // server data have failed or succeeded.
127 CLEAR_SERVER_DATA_SUCCEEDED,
128 CLEAR_SERVER_DATA_FAILED,
129
130 // This event is sent when we receive an actionable error. It is upto
131 // the listeners to figure out the action to take using the snapshot sent.
132 ACTIONABLE_ERROR,
133 };
134
135 explicit SyncEngineEvent(EventCause cause);
136 ~SyncEngineEvent();
137
138 EventCause what_happened;
139
140 // The last session used for syncing.
141 const sessions::SyncSessionSnapshot* snapshot;
142
143 // Update-Client-Auth returns a new token for sync use.
144 std::string updated_token;
145 };
146
147 class SyncEngineEventListener {
148 public:
149 // TODO(tim): Consider splitting this up to multiple callbacks, rather than
150 // have to do Event e(type); OnSyncEngineEvent(e); at all callsites,
151 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) = 0;
152 protected:
153 virtual ~SyncEngineEventListener() {}
154 };
155
156 } // namespace browser_sync
157
158 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_TYPES_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_proto_util_unittest.cc ('k') | chrome/browser/sync/engine/syncer_types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698