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

Unified Diff: chrome/browser/sync/engine/syncer_thread.h

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/syncer_status.cc ('k') | chrome/browser/sync/engine/syncer_thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/syncer_thread.h
===================================================================
--- chrome/browser/sync/engine/syncer_thread.h (revision 32731)
+++ chrome/browser/sync/engine/syncer_thread.h (working copy)
@@ -21,7 +21,7 @@
#include "base/time.h"
#include "base/waitable_event.h"
#include "chrome/browser/sync/engine/all_status.h"
-#include "chrome/browser/sync/engine/client_command_channel.h"
+#include "chrome/browser/sync/sessions/sync_session.h"
#include "chrome/browser/sync/util/event_sys-inl.h"
#include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST
@@ -44,29 +44,8 @@
struct SyncerShutdownEvent;
struct TalkMediatorEvent;
-class SyncerThreadFactory {
- public:
- // Creates a SyncerThread based on the default (or user-overridden)
- // implementation. The thread does not start running until you call Start(),
- // which will cause it to check-and-wait for certain conditions to be met
- // (such as valid connection with Server established, syncable::Directory has
- // been opened) before performing an intial sync with a server. It uses
- // |connection_manager| to detect valid connections, and |mgr| to detect the
- // opening of a Directory, which will cause it to create a Syncer object for
- // said Directory, and assign |model_safe_worker| to it. |connection_manager|
- // and |mgr| should outlive the SyncerThread. You must stop the thread by
- // calling Stop before destroying the object. Stopping will first tear down
- // the Syncer object, allowing it to finish work in progress, before joining
- // the Stop-calling thread with the internal thread.
- static SyncerThread* Create(ClientCommandChannel* command_channel,
- syncable::DirectoryManager* mgr,
- ServerConnectionManager* connection_manager, AllStatus* all_status,
- ModelSafeWorker* model_safe_worker);
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(SyncerThreadFactory);
-};
-
-class SyncerThread : public base::RefCountedThreadSafe<SyncerThread> {
+class SyncerThread : public base::RefCountedThreadSafe<SyncerThread>,
+ public sessions::SyncSession::Delegate {
FRIEND_TEST(SyncerThreadTest, CalculateSyncWaitTime);
FRIEND_TEST(SyncerThreadTest, CalculatePollingWaitTime);
FRIEND_TEST(SyncerThreadWithSyncerTest, Polling);
@@ -117,6 +96,7 @@
// longest possible poll interval.
static const int kDefaultMaxPollIntervalMs;
+ SyncerThread(sessions::SyncSessionContext* context, AllStatus* all_status);
virtual ~SyncerThread();
virtual void WatchConnectionManager(ServerConnectionManager* conn_mgr);
@@ -136,16 +116,9 @@
// Registers this thread to watch talk mediator events.
virtual void WatchTalkMediator(TalkMediator* talk_mediator);
- virtual void WatchClientCommands(ClientCommandChannel* channel);
+ virtual SyncerEventChannel* relay_channel();
- virtual SyncerEventChannel* channel();
-
protected:
- SyncerThread(); // Necessary for temporary pthreads-based PIMPL impl.
- SyncerThread(ClientCommandChannel* command_channel,
- syncable::DirectoryManager* mgr,
- ServerConnectionManager* connection_manager, AllStatus* all_status,
- ModelSafeWorker* model_safe_worker);
virtual void ThreadMain();
void ThreadMainLoop();
@@ -227,8 +200,15 @@
void HandleDirectoryManagerEvent(
const syncable::DirectoryManagerEvent& event);
void HandleSyncerEvent(const SyncerEvent& event);
- void HandleClientCommand(ClientCommandChannel::EventType event);
+ // SyncSession::Delegate implementation.
+ virtual void OnSilencedUntil(const base::TimeTicks& silenced_until);
+ virtual bool IsSyncingCurrentlySilenced();
+ virtual void OnReceivedShortPollIntervalUpdate(
+ const base::TimeDelta& new_interval);
+ virtual void OnReceivedLongPollIntervalUpdate(
+ const base::TimeDelta& new_interval);
+
void HandleServerConnectionEvent(const ServerConnectionEvent& event);
void HandleTalkMediatorEvent(const TalkMediatorEvent& event);
@@ -274,13 +254,9 @@
bool p2p_authenticated_;
bool p2p_subscribed_;
- scoped_ptr<EventListenerHookup> client_command_hookup_;
scoped_ptr<EventListenerHookup> conn_mgr_hookup_;
const AllStatus* allstatus_;
- syncable::DirectoryManager* dirman_;
- ServerConnectionManager* scm_;
-
// Modifiable versions of kDefaultLongPollIntervalSeconds which can be
// updated by the server.
int syncer_short_poll_interval_seconds_;
@@ -295,23 +271,30 @@
// also takes previous failures into account.
int syncer_max_interval_;
- scoped_ptr<SyncerEventChannel> syncer_event_channel_;
-
// This causes syncer to start syncing ASAP. If the rate of requests is too
// high the request will be silently dropped. mutex_ should be held when
// this is called.
void NudgeSyncImpl(int milliseconds_from_now, NudgeSource source);
scoped_ptr<EventListenerHookup> talk_mediator_hookup_;
- ClientCommandChannel* const command_channel_;
scoped_ptr<EventListenerHookup> directory_manager_hookup_;
scoped_ptr<EventListenerHookup> syncer_events_;
- // Handles any tasks that will result in model changes (modifications of
- // syncable::Entries). Pass this to the syncer created and managed by |this|.
- // Only non-null in syncapi case.
- scoped_ptr<ModelSafeWorker> model_safe_worker_;
+ scoped_ptr<sessions::SyncSessionContext> session_context_;
+ // Events from the Syncer's syncer_event_channel are first processed by the
+ // SyncerThread and then get relayed onto this channel for consumers.
+ // TODO(timsteele): Wow did this confused me. I had removed the channel from
+ // here thinking there was only one, and then realized this relay was
+ // happening. Is this strict event handling order needed?!
+ scoped_ptr<SyncerEventChannel> syncer_event_relay_channel_;
+
+ // Set whenever the server instructs us to stop sending it requests until
+ // a specified time, and reset for each call to SyncShare. (Note that the
+ // WaitInterval::THROTTLED contract is such that we don't call SyncShare at
+ // all until the "silenced until" embargo expires.)
+ base::TimeTicks silenced_until_;
+
// Useful for unit tests
bool disable_idle_detection_;
« no previous file with comments | « chrome/browser/sync/engine/syncer_status.cc ('k') | chrome/browser/sync/engine/syncer_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698