OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 entry. | 3 // found in the LICENSE entry. |
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 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "chrome/browser/sync/engine/client_command_channel.h" | 15 #include "chrome/browser/sync/engine/client_command_channel.h" |
16 #include "chrome/browser/sync/engine/conflict_resolver.h" | 16 #include "chrome/browser/sync/engine/conflict_resolver.h" |
17 #include "chrome/browser/sync/engine/syncer_types.h" | 17 #include "chrome/browser/sync/engine/syncer_types.h" |
18 #include "chrome/browser/sync/engine/syncproto.h" | 18 #include "chrome/browser/sync/engine/syncproto.h" |
19 #include "chrome/browser/sync/syncable/directory_event.h" | 19 #include "chrome/browser/sync/syncable/directory_event.h" |
| 20 #include "chrome/browser/sync/util/closure.h" |
20 #include "chrome/browser/sync/util/event_sys-inl.h" | 21 #include "chrome/browser/sync/util/event_sys-inl.h" |
21 #include "chrome/browser/sync/util/event_sys.h" | 22 #include "chrome/browser/sync/util/event_sys.h" |
22 #include "chrome/browser/sync/util/extensions_activity_monitor.h" | 23 #include "chrome/browser/sync/util/extensions_activity_monitor.h" |
23 #include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST | 24 #include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST |
24 | 25 |
25 namespace syncable { | 26 namespace syncable { |
26 class Directory; | 27 class Directory; |
27 class DirectoryManager; | 28 class DirectoryManager; |
28 class Entry; | 29 class Entry; |
29 class Id; | 30 class Id; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // as SyncerCommands, and the ordering of the steps is expressed using | 65 // as SyncerCommands, and the ordering of the steps is expressed using |
65 // the SyncerStep enum. | 66 // the SyncerStep enum. |
66 // | 67 // |
67 // A Syncer instance expects to run on a dedicated thread. Calls | 68 // A Syncer instance expects to run on a dedicated thread. Calls |
68 // to SyncShare() may take an unbounded amount of time, as SyncerCommands | 69 // to SyncShare() may take an unbounded amount of time, as SyncerCommands |
69 // may block on network i/o, on lock contention, or on tasks posted to | 70 // may block on network i/o, on lock contention, or on tasks posted to |
70 // other threads. | 71 // other threads. |
71 class Syncer { | 72 class Syncer { |
72 public: | 73 public: |
73 typedef std::vector<int64> UnsyncedMetaHandles; | 74 typedef std::vector<int64> UnsyncedMetaHandles; |
74 typedef void (*TestCallbackFunction)(syncable::Directory* dir); | |
75 | 75 |
76 // The constructor may be called from a thread that is not the Syncer's | 76 // The constructor may be called from a thread that is not the Syncer's |
77 // dedicated thread, to allow some flexibility in the setup. | 77 // dedicated thread, to allow some flexibility in the setup. |
78 Syncer(syncable::DirectoryManager* dirman, const PathString& account_name, | 78 Syncer(syncable::DirectoryManager* dirman, const PathString& account_name, |
79 ServerConnectionManager* connection_manager, | 79 ServerConnectionManager* connection_manager, |
80 ModelSafeWorker* model_safe_worker); | 80 ModelSafeWorker* model_safe_worker); |
81 ~Syncer(); | 81 ~Syncer(); |
82 | 82 |
83 // Called by other threads to tell the syncer to stop what it's doing | 83 // Called by other threads to tell the syncer to stop what it's doing |
84 // and return early from SyncShare, if possible. | 84 // and return early from SyncShare, if possible. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 ExtensionsActivityMonitor* extensions_monitor_; | 186 ExtensionsActivityMonitor* extensions_monitor_; |
187 | 187 |
188 // The source of the last nudge. | 188 // The source of the last nudge. |
189 sync_pb::GetUpdatesCallerInfo::GET_UPDATES_SOURCE updates_source_; | 189 sync_pb::GetUpdatesCallerInfo::GET_UPDATES_SOURCE updates_source_; |
190 | 190 |
191 // True only if the notification channel is authorized and open. | 191 // True only if the notification channel is authorized and open. |
192 bool notifications_enabled_; | 192 bool notifications_enabled_; |
193 | 193 |
194 // A callback hook used in unittests to simulate changes between conflict set | 194 // A callback hook used in unittests to simulate changes between conflict set |
195 // building and conflict resolution. | 195 // building and conflict resolution. |
196 TestCallbackFunction pre_conflict_resolution_function_; | 196 Closure* pre_conflict_resolution_closure_; |
197 | 197 |
198 FRIEND_TEST(SyncerTest, NewServerItemInAFolderHierarchyWeHaveDeleted3); | 198 FRIEND_TEST(SusanDeletingTest, |
| 199 NewServerItemInAFolderHierarchyWeHaveDeleted3); |
199 FRIEND_TEST(SyncerTest, TestCommitListOrderingAndNewParent); | 200 FRIEND_TEST(SyncerTest, TestCommitListOrderingAndNewParent); |
200 FRIEND_TEST(SyncerTest, TestCommitListOrderingAndNewParentAndChild); | 201 FRIEND_TEST(SyncerTest, TestCommitListOrderingAndNewParentAndChild); |
201 FRIEND_TEST(SyncerTest, TestCommitListOrderingCounterexample); | 202 FRIEND_TEST(SyncerTest, TestCommitListOrderingCounterexample); |
202 FRIEND_TEST(SyncerTest, TestCommitListOrderingWithNesting); | 203 FRIEND_TEST(SyncerTest, TestCommitListOrderingWithNesting); |
203 FRIEND_TEST(SyncerTest, TestCommitListOrderingWithNewItems); | 204 FRIEND_TEST(SyncerTest, TestCommitListOrderingWithNewItems); |
204 FRIEND_TEST(SyncerTest, TestGetUnsyncedAndSimpleCommit); | 205 FRIEND_TEST(SyncerTest, TestGetUnsyncedAndSimpleCommit); |
205 | 206 |
206 DISALLOW_COPY_AND_ASSIGN(Syncer); | 207 DISALLOW_COPY_AND_ASSIGN(Syncer); |
207 }; | 208 }; |
208 | 209 |
(...skipping 24 matching lines...) Expand all Loading... |
233 void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest); | 234 void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest); |
234 void ClearServerData(syncable::MutableEntry* entry); | 235 void ClearServerData(syncable::MutableEntry* entry); |
235 | 236 |
236 // Get update contents as a string. Intended for logging, and intended | 237 // Get update contents as a string. Intended for logging, and intended |
237 // to have a smaller footprint than the protobuf's built-in pretty printer. | 238 // to have a smaller footprint than the protobuf's built-in pretty printer. |
238 std::string SyncEntityDebugString(const sync_pb::SyncEntity& entry); | 239 std::string SyncEntityDebugString(const sync_pb::SyncEntity& entry); |
239 | 240 |
240 } // namespace browser_sync | 241 } // namespace browser_sync |
241 | 242 |
242 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_ | 243 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_H_ |
OLD | NEW |