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

Side by Side Diff: chrome/browser/sync/sessions/sync_session.cc

Issue 5939006: sync: beginnings of MessageLoop based SyncerThread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 10 years 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) 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 file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/sessions/sync_session.h" 5 #include "chrome/browser/sync/sessions/sync_session.h"
6 #include "chrome/browser/sync/syncable/directory_manager.h" 6 #include "chrome/browser/sync/syncable/directory_manager.h"
7 #include "chrome/browser/sync/syncable/model_type.h" 7 #include "chrome/browser/sync/syncable/model_type.h"
8 8
9 namespace browser_sync { 9 namespace browser_sync {
10 namespace sessions { 10 namespace sessions {
11 11
12 SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate, 12 SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate,
13 SyncSourceInfo source, 13 SyncSourceInfo source,
14 const ModelSafeRoutingInfo& routing_info, 14 const ModelSafeRoutingInfo& routing_info,
15 const std::vector<ModelSafeWorker*>& workers) : 15 const std::vector<ModelSafeWorker*>& workers) :
16 context_(context), 16 context_(context),
17 source_(source), 17 source_(source),
18 write_transaction_(NULL), 18 write_transaction_(NULL),
19 delegate_(delegate), 19 delegate_(delegate),
20 workers_(workers), 20 workers_(workers),
21 routing_info_(routing_info) { 21 routing_info_(routing_info) {
22 status_controller_.reset(new StatusController(routing_info_)); 22 status_controller_.reset(new StatusController(routing_info_));
23 } 23 }
24 24
25 SyncSession::~SyncSession() {} 25 SyncSession::~SyncSession() {}
26 26
27 void SyncSession::Coalesce(const SyncSession* session) {
28 if (context_ != session->context() || delegate_ != session->delegate_) {
29 NOTREACHED();
30 return;
31 }
32
33 source_ = SyncSourceInfo(session->source_.first,
34 source_.second | session->source_.second);
35 // TODO(tim): Update routing_info_ and workers_.
36 }
37
38 void SyncSession::ResetTransientState() {
39 status_controller_.reset(new StatusController(routing_info_));
40 }
41
27 SyncSessionSnapshot SyncSession::TakeSnapshot() const { 42 SyncSessionSnapshot SyncSession::TakeSnapshot() const {
28 syncable::ScopedDirLookup dir(context_->directory_manager(), 43 syncable::ScopedDirLookup dir(context_->directory_manager(),
29 context_->account_name()); 44 context_->account_name());
30 if (!dir.good()) 45 if (!dir.good())
31 LOG(ERROR) << "Scoped dir lookup failed!"; 46 LOG(ERROR) << "Scoped dir lookup failed!";
32 47
33 bool is_share_useable = true; 48 bool is_share_useable = true;
34 syncable::ModelTypeBitSet initial_sync_ended; 49 syncable::ModelTypeBitSet initial_sync_ended;
35 for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) { 50 for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) {
36 syncable::ModelType type(syncable::ModelTypeFromInt(i)); 51 syncable::ModelType type(syncable::ModelTypeFromInt(i));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return ((status->commit_ids().size() < status->unsynced_handles().size()) && 84 return ((status->commit_ids().size() < status->unsynced_handles().size()) &&
70 status->syncer_status().num_successful_commits > 0) || 85 status->syncer_status().num_successful_commits > 0) ||
71 status->conflict_sets_built() || 86 status->conflict_sets_built() ||
72 status->conflicts_resolved(); 87 status->conflicts_resolved();
73 // Or, we have conflicting updates, but we're making progress on 88 // Or, we have conflicting updates, but we're making progress on
74 // resolving them... 89 // resolving them...
75 } 90 }
76 91
77 } // namespace sessions 92 } // namespace sessions
78 } // namespace browser_sync 93 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698