Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // A class representing an attempt to synchronize the local syncable data | 5 // A class representing an attempt to synchronize the local syncable data |
| 6 // store with a sync server. A SyncSession instance is passed as a stateful | 6 // store with a sync server. A SyncSession instance is passed as a stateful |
| 7 // bundle to and from various SyncerCommands with the goal of converging the | 7 // bundle to and from various SyncerCommands with the goal of converging the |
| 8 // client view of data with that of the server. The commands twiddle with | 8 // client view of data with that of the server. The commands twiddle with |
| 9 // session status in response to events and hiccups along the way, set and | 9 // session status in response to events and hiccups along the way, set and |
| 10 // query session progress with regards to conflict resolution and applying | 10 // query session progress with regards to conflict resolution and applying |
| 11 // server updates, and access the SyncSessionContext for the current session | 11 // server updates, and access the SyncSessionContext for the current session |
| 12 // via SyncSession instances. | 12 // via SyncSession instances. |
| 13 | 13 |
| 14 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_H_ | 14 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_H_ |
| 15 #define CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_H_ | 15 #define CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_H_ |
| 16 #pragma once | 16 #pragma once |
| 17 | 17 |
| 18 #include <map> | |
| 19 #include <string> | |
| 18 #include <utility> | 20 #include <utility> |
| 19 #include <vector> | 21 #include <vector> |
| 20 | 22 |
| 21 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
| 22 #include "base/scoped_ptr.h" | 24 #include "base/scoped_ptr.h" |
| 23 #include "base/time.h" | 25 #include "base/time.h" |
| 24 #include "chrome/browser/sync/sessions/ordered_commit_set.h" | 26 #include "chrome/browser/sync/sessions/ordered_commit_set.h" |
| 25 #include "chrome/browser/sync/sessions/session_state.h" | 27 #include "chrome/browser/sync/sessions/session_state.h" |
| 26 #include "chrome/browser/sync/sessions/status_controller.h" | 28 #include "chrome/browser/sync/sessions/status_controller.h" |
| 27 #include "chrome/browser/sync/sessions/sync_session_context.h" | 29 #include "chrome/browser/sync/sessions/sync_session_context.h" |
| 30 #include "chrome/browser/sync/syncable/model_type.h" | |
| 28 #include "chrome/browser/sync/util/extensions_activity_monitor.h" | 31 #include "chrome/browser/sync/util/extensions_activity_monitor.h" |
| 29 | 32 |
| 30 namespace syncable { | 33 namespace syncable { |
| 31 class WriteTransaction; | 34 class WriteTransaction; |
| 32 } | 35 } |
| 33 | 36 |
| 34 namespace browser_sync { | 37 namespace browser_sync { |
| 35 class ModelSafeWorker; | 38 class ModelSafeWorker; |
| 36 | 39 |
| 37 namespace sessions { | 40 namespace sessions { |
| 38 typedef std::pair<sync_pb::GetUpdatesCallerInfo::GetUpdatesSource, | 41 |
| 39 syncable::ModelTypeBitSet> SyncSourceInfo; | 42 // A container that contains a set of datatypes with possible string payloads. |
| 43 typedef std::map<syncable::ModelType, std::string> TypePayloadMap; | |
| 44 | |
| 45 // Helper utils for building TypePayloadMaps. | |
| 46 // Convert a ModelTypeBitset into a TypePayloadMap using a default payload. | |
| 47 TypePayloadMap ModelTypeBitSetToTypePayloadMap( | |
| 48 const syncable::ModelTypeBitSet& types, | |
| 49 const std::string& payload); | |
| 50 // Convert a ModelSafeRoutingInfo into a TypePayloadMap using a default payload. | |
| 51 TypePayloadMap RoutingInfoToTypePayloadMap( | |
| 52 const ModelSafeRoutingInfo& routes, | |
| 53 const std::string& payload); | |
| 54 // Coalesce |update| into |original|, overwriting only when |update| has | |
|
akalin
2011/01/26 01:15:17
I think it's safer to change the sig of this into:
Nicolas Zea
2011/01/26 01:41:28
Done.
| |
| 55 // a non-empty payload. | |
| 56 TypePayloadMap CoalescePayloads(const TypePayloadMap& original, | |
| 57 const TypePayloadMap& update); | |
| 58 | |
| 59 | |
| 60 // A container for the source of a sync session. This includes the update | |
| 61 // source, the datatypes triggering the sync session, and possible session | |
| 62 // specific payloads which should be sent to the server. | |
| 63 struct SyncSourceInfo { | |
| 64 SyncSourceInfo(); | |
| 65 SyncSourceInfo( | |
| 66 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& u, | |
| 67 const TypePayloadMap& t); | |
| 68 | |
| 69 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source; | |
| 70 TypePayloadMap types; | |
| 71 }; | |
| 40 | 72 |
| 41 class SyncSession { | 73 class SyncSession { |
| 42 public: | 74 public: |
| 43 // The Delegate services events that occur during the session requiring an | 75 // The Delegate services events that occur during the session requiring an |
| 44 // explicit (and session-global) action, as opposed to events that are simply | 76 // explicit (and session-global) action, as opposed to events that are simply |
| 45 // recorded in per-session state. | 77 // recorded in per-session state. |
| 46 class Delegate { | 78 class Delegate { |
| 47 public: | 79 public: |
| 48 // The client was throttled and should cease-and-desist syncing activity | 80 // The client was throttled and should cease-and-desist syncing activity |
| 49 // until the specified time. | 81 // until the specified time. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 | 195 |
| 164 private: | 196 private: |
| 165 SyncSession* session_; | 197 SyncSession* session_; |
| 166 DISALLOW_COPY_AND_ASSIGN(ScopedSetSessionWriteTransaction); | 198 DISALLOW_COPY_AND_ASSIGN(ScopedSetSessionWriteTransaction); |
| 167 }; | 199 }; |
| 168 | 200 |
| 169 } // namespace sessions | 201 } // namespace sessions |
| 170 } // namespace browser_sync | 202 } // namespace browser_sync |
| 171 | 203 |
| 172 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_H_ | 204 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_H_ |
| OLD | NEW |