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

Unified Diff: chrome/browser/sync/engine/syncapi.cc

Issue 386030: Relieve SyncerSession,SyncCycleState, SyncProcessState, SyncerSession, Syncer... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/engine/sync_process_state.cc ('k') | chrome/browser/sync/engine/syncer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/syncapi.cc
===================================================================
--- chrome/browser/sync/engine/syncapi.cc (revision 32731)
+++ chrome/browser/sync/engine/syncapi.cc (working copy)
@@ -26,7 +26,6 @@
#include "chrome/browser/sync/engine/all_status.h"
#include "chrome/browser/sync/engine/auth_watcher.h"
#include "chrome/browser/sync/engine/change_reorder_buffer.h"
-#include "chrome/browser/sync/engine/client_command_channel.h"
#include "chrome/browser/sync/engine/model_safe_worker.h"
#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
#include "chrome/browser/sync/engine/net/server_connection_manager.h"
@@ -36,6 +35,7 @@
#include "chrome/browser/sync/notifier/listener/talk_mediator.h"
#include "chrome/browser/sync/notifier/listener/talk_mediator_impl.h"
#include "chrome/browser/sync/protocol/service_constants.h"
+#include "chrome/browser/sync/sessions/sync_session_context.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/util/character_set_converters.h"
@@ -53,15 +53,13 @@
using browser_sync::AllStatusEvent;
using browser_sync::AuthWatcher;
using browser_sync::AuthWatcherEvent;
-using browser_sync::ClientCommandChannel;
using browser_sync::Syncer;
using browser_sync::SyncerEvent;
-using browser_sync::SyncerStatus;
using browser_sync::SyncerThread;
-using browser_sync::SyncerThreadFactory;
using browser_sync::UserSettings;
using browser_sync::TalkMediator;
using browser_sync::TalkMediatorImpl;
+using browser_sync::sessions::SyncSessionContext;
using std::list;
using std::hex;
using std::string;
@@ -648,7 +646,6 @@
public:
explicit SyncInternal(SyncManager* sync_manager)
: observer_(NULL),
- command_channel_(0),
auth_problem_(AuthError::NONE),
sync_manager_(sync_manager),
address_watch_thread_("SyncEngine_AddressWatcher"),
@@ -819,9 +816,6 @@
// WARNING: This can be NULL!
Observer* observer_;
- // A sink for client commands from the syncer needed to create a SyncerThread.
- ClientCommandChannel command_channel_;
-
// The ServerConnectionManager used to abstract communication between the
// client (the Syncer) and the sync server.
scoped_ptr<SyncAPIServerConnectionManager> connection_manager_;
@@ -997,16 +991,15 @@
authwatcher_hookup_.reset(NewEventListenerHookup(auth_watcher_->channel(),
this, &SyncInternal::HandleAuthWatcherEvent));
- // Tell the SyncerThread to use the ModelSafeWorker for bookmark model work.
+ // Build a SyncSessionContext and store the worker in it.
// We set up both sides of the "bridge" here, with the ModelSafeWorkerBridge
// on the Syncer side, and |model_safe_worker| on the API client side.
ModelSafeWorkerBridge* worker = new ModelSafeWorkerBridge(model_safe_worker);
+ SyncSessionContext* context = new SyncSessionContext(
+ connection_manager_.get(), dir_manager(), worker);
- syncer_thread_ = SyncerThreadFactory::Create(&command_channel_,
- dir_manager(),
- connection_manager(),
- &allstatus_,
- worker);
+ // The SyncerThread takes ownership of |context|.
+ syncer_thread_ = new SyncerThread(context, &allstatus_);
syncer_thread()->WatchTalkMediator(talk_mediator());
allstatus()->WatchSyncerThread(syncer_thread());
@@ -1315,7 +1308,7 @@
// (because we attach HandleSyncerEvent only once we receive notification
// of successful authentication [locally or otherwise]), but B) the initial
// sync had not completed at that time.
- if (SyncerStatus(event.last_session).IsShareUsable())
+ if (event.snapshot->is_share_usable)
MarkAndNotifyInitializationComplete();
return;
}
@@ -1331,13 +1324,13 @@
// Notifications are sent at the end of every sync cycle, regardless of
// whether we should sync again.
if (event.what_happened == SyncerEvent::SYNC_CYCLE_ENDED) {
- if (!event.last_session->HasMoreToSync()) {
+ if (!event.snapshot->has_more_to_sync) {
observer_->OnSyncCycleCompleted();
}
- // TODO(chron): Consider changing this back to track HasMoreToSync
- // Only notify peers if a successful commit has occurred.
- if (event.last_session && event.last_session->HadSuccessfulCommits()) {
+ // TODO(chron): Consider changing this back to track has_more_to_sync
+ // only notify peers if a successful commit has occurred.
+ if (event.snapshot->syncer_status.num_successful_commits > 0) {
// We use a member variable here because talk may not have connected yet.
// The notification must be stored until it can be sent.
notification_pending_ = true;
@@ -1357,9 +1350,8 @@
}
} else {
LOG(INFO) << "Didn't send XMPP notification!"
- << " event.last_session: " << event.last_session
- << " event.last_session->items_committed(): "
- << event.last_session->items_committed()
+ << " event.snapshot.did_commit_items: "
+ << event.snapshot->did_commit_items
<< " talk_mediator(): " << talk_mediator();
}
}
@@ -1410,8 +1402,9 @@
{
// Start watching the syncer channel directly here.
DCHECK(syncer_thread() != NULL);
- syncer_event_.reset(NewEventListenerHookup(syncer_thread()->channel(),
- this, &SyncInternal::HandleSyncerEvent));
+ syncer_event_.reset(
+ NewEventListenerHookup(syncer_thread()->relay_channel(), this,
+ &SyncInternal::HandleSyncerEvent));
}
return;
// Authentication failures translate to GoogleServiceAuthError events.
« no previous file with comments | « chrome/browser/sync/engine/sync_process_state.cc ('k') | chrome/browser/sync/engine/syncer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698