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

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

Issue 6286067: sync: add a SyncSessionJobPurpose for clearing sync user data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome
Patch Set: whitespace Created 9 years, 10 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_ 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_
6 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_ 6 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 VERIFY_UPDATES, 49 VERIFY_UPDATES,
50 PROCESS_UPDATES, 50 PROCESS_UPDATES,
51 STORE_TIMESTAMPS, 51 STORE_TIMESTAMPS,
52 APPLY_UPDATES, 52 APPLY_UPDATES,
53 BUILD_COMMIT_REQUEST, 53 BUILD_COMMIT_REQUEST,
54 POST_COMMIT_MESSAGE, 54 POST_COMMIT_MESSAGE,
55 PROCESS_COMMIT_RESPONSE, 55 PROCESS_COMMIT_RESPONSE,
56 BUILD_AND_PROCESS_CONFLICT_SETS, 56 BUILD_AND_PROCESS_CONFLICT_SETS,
57 RESOLVE_CONFLICTS, 57 RESOLVE_CONFLICTS,
58 APPLY_UPDATES_TO_RESOLVE_CONFLICTS, 58 APPLY_UPDATES_TO_RESOLVE_CONFLICTS,
59 CLEAR_PRIVATE_DATA, 59 CLEAR_PRIVATE_DATA, // TODO(tim): Rename 'private' to 'user'.
60 SYNCER_END 60 SYNCER_END
61 }; 61 };
62 62
63 // A Syncer provides a control interface for driving the individual steps 63 // A Syncer provides a control interface for driving the individual steps
64 // of the sync cycle. Each cycle (hopefully) moves the client into closer 64 // of the sync cycle. Each cycle (hopefully) moves the client into closer
65 // synchronization with the server. The individual steps are modeled 65 // synchronization with the server. The individual steps are modeled
66 // as SyncerCommands, and the ordering of the steps is expressed using 66 // as SyncerCommands, and the ordering of the steps is expressed using
67 // the SyncerStep enum. 67 // the SyncerStep enum.
68 // 68 //
69 // A Syncer instance expects to run on a dedicated thread. Calls 69 // A Syncer instance expects to run on a dedicated thread. Calls
70 // to SyncShare() may take an unbounded amount of time, as SyncerCommands 70 // to SyncShare() may take an unbounded amount of time, as SyncerCommands
71 // may block on network i/o, on lock contention, or on tasks posted to 71 // may block on network i/o, on lock contention, or on tasks posted to
72 // other threads. 72 // other threads.
73 class Syncer { 73 class Syncer {
74 public: 74 public:
75 typedef std::vector<int64> UnsyncedMetaHandles; 75 typedef std::vector<int64> UnsyncedMetaHandles;
76 76
77 // The constructor may be called from a thread that is not the Syncer's 77 // The constructor may be called from a thread that is not the Syncer's
78 // dedicated thread, to allow some flexibility in the setup. 78 // dedicated thread, to allow some flexibility in the setup.
79 Syncer(); 79 Syncer();
80 virtual ~Syncer(); 80 virtual ~Syncer();
81 81
82 // Called by other threads to tell the syncer to stop what it's doing 82 // Called by other threads to tell the syncer to stop what it's doing
83 // and return early from SyncShare, if possible. 83 // and return early from SyncShare, if possible.
84 bool ExitRequested(); 84 bool ExitRequested();
85 void RequestEarlyExit(); 85 void RequestEarlyExit();
86 86
87 // TODO(tim): Deprecated.
87 // Cause one sync cycle to occur. Like a good parent, it is the caller's 88 // Cause one sync cycle to occur. Like a good parent, it is the caller's
88 // responsibility to clean up after the syncer when it finishes a sync share 89 // responsibility to clean up after the syncer when it finishes a sync share
89 // operation and honor server mandated throttles. 90 // operation and honor server mandated throttles.
90 virtual void SyncShare(sessions::SyncSession* session); 91 virtual void SyncShare(sessions::SyncSession* session);
91 92
93 // Like SyncShare() above, but |first_step| and |last_step| are provided to
94 // perform a partial sync cycle, stopping after |last_step| is performed.
95 virtual void SyncShare(sessions::SyncSession* session,
96 SyncerStep first_step,
97 SyncerStep last_step);
98
92 private: 99 private:
93 // Implements the PROCESS_CLIENT_COMMAND syncer step. 100 // Implements the PROCESS_CLIENT_COMMAND syncer step.
94 void ProcessClientCommand(sessions::SyncSession *session); 101 void ProcessClientCommand(sessions::SyncSession *session);
95 102
96 // This is the bottom-most SyncShare variant, and does not cause transient
97 // state to be reset in session.
98 // Like SyncShare(), but |first_step| and |last_step| are provided to perform
99 // a partial sync cycle, stopping after |last_step| is performed.
100 void SyncShare(sessions::SyncSession* session,
101 SyncerStep first_step,
102 SyncerStep last_step);
103
104 bool early_exit_requested_; 103 bool early_exit_requested_;
105 base::Lock early_exit_requested_lock_; 104 base::Lock early_exit_requested_lock_;
106 105
107 ConflictResolver resolver_; 106 ConflictResolver resolver_;
108 107
109 // A callback hook used in unittests to simulate changes between conflict set 108 // A callback hook used in unittests to simulate changes between conflict set
110 // building and conflict resolution. 109 // building and conflict resolution.
111 Callback0::Type* pre_conflict_resolution_closure_; 110 Callback0::Type* pre_conflict_resolution_closure_;
112 111
113 friend class SyncerTest; 112 friend class SyncerTest;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return false; 158 return false;
160 } 159 }
161 // Utility function declarations. 160 // Utility function declarations.
162 void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest); 161 void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest);
163 void ClearServerData(syncable::MutableEntry* entry); 162 void ClearServerData(syncable::MutableEntry* entry);
164 163
165 } // namespace browser_sync 164 } // namespace browser_sync
166 165
167 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_ 166 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_
168 167
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698