diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 09:10:17 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 09:10:17 +0000 |
commit | 1f7eba7875a15cc7318f3ce2c039e1ab5f31cd1d (patch) | |
tree | 2633a2e94903e75db84ef2b49dc963d409378e38 /jingle | |
parent | 37b928e54179f9baed76b3a0c8f4c105c9fabc5f (diff) | |
download | chromium_src-1f7eba7875a15cc7318f3ce2c039e1ab5f31cd1d.zip chromium_src-1f7eba7875a15cc7318f3ce2c039e1ab5f31cd1d.tar.gz chromium_src-1f7eba7875a15cc7318f3ce2c039e1ab5f31cd1d.tar.bz2 |
[Sync] Make InvalidationNotifier use PushClient
This removes a lot of duplicated code and unifies the two main
SyncNotifier implementations (P2P and Invalidation) to use the same
underlying transport layer.
Replace CacheInvalidationPacketHandler and ChromeNetwork with PushClientChannel.
Add PushClient::CreateDefaultOnIOThread which creates
an XmppPushClient directly.
BUG=76764
TEST=
Review URL: https://chromiumcodereview.appspot.com/10436013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139508 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r-- | jingle/notifier/communicator/single_login_attempt.cc | 1 | ||||
-rw-r--r-- | jingle/notifier/listener/push_client.cc | 7 | ||||
-rw-r--r-- | jingle/notifier/listener/push_client.h | 6 | ||||
-rw-r--r-- | jingle/notifier/listener/push_client_unittest.cc | 11 |
4 files changed, 23 insertions, 2 deletions
diff --git a/jingle/notifier/communicator/single_login_attempt.cc b/jingle/notifier/communicator/single_login_attempt.cc index b4cae89..0c789ee 100644 --- a/jingle/notifier/communicator/single_login_attempt.cc +++ b/jingle/notifier/communicator/single_login_attempt.cc @@ -41,6 +41,7 @@ SingleLoginAttempt::~SingleLoginAttempt() {} void SingleLoginAttempt::OnConnect( base::WeakPtr<buzz::XmppTaskParentInterface> base_task) { + DVLOG(1) << "Connected to " << current_settings_->ToString(); delegate_->OnConnect(base_task); } diff --git a/jingle/notifier/listener/push_client.cc b/jingle/notifier/listener/push_client.cc index d704264..f96e8f8 100644 --- a/jingle/notifier/listener/push_client.cc +++ b/jingle/notifier/listener/push_client.cc @@ -31,4 +31,11 @@ scoped_ptr<PushClient> PushClient::CreateDefault( base::Bind(&CreateXmppPushClient, notifier_options))); } +scoped_ptr<PushClient> PushClient::CreateDefaultOnIOThread( + const NotifierOptions& notifier_options) { + CHECK(notifier_options.request_context_getter->GetIOMessageLoopProxy()-> + BelongsToCurrentThread()); + return CreateXmppPushClient(notifier_options); +} + } // namespace notifier diff --git a/jingle/notifier/listener/push_client.h b/jingle/notifier/listener/push_client.h index ea975a8..f80f422 100644 --- a/jingle/notifier/listener/push_client.h +++ b/jingle/notifier/listener/push_client.h @@ -27,6 +27,12 @@ class PushClient { static scoped_ptr<PushClient> CreateDefault( const NotifierOptions& notifier_options); + // Creates a default blocking PushClient implementation from the + // given options. Must be called from the IO thread (according to + // |notifier_options|). + static scoped_ptr<PushClient> CreateDefaultOnIOThread( + const NotifierOptions& notifier_options); + // Manage the list of observers for incoming notifications. virtual void AddObserver(PushClientObserver* observer) = 0; virtual void RemoveObserver(PushClientObserver* observer) = 0; diff --git a/jingle/notifier/listener/push_client_unittest.cc b/jingle/notifier/listener/push_client_unittest.cc index fd45466..42daf2a 100644 --- a/jingle/notifier/listener/push_client_unittest.cc +++ b/jingle/notifier/listener/push_client_unittest.cc @@ -33,13 +33,13 @@ class PushClientTest : public testing::Test { }; // Make sure calling CreateDefault on the IO thread doesn't blow up. -TEST_F(PushClientTest, OnIOThread) { +TEST_F(PushClientTest, CreateDefaultOnIOThread) { const scoped_ptr<PushClient> push_client( PushClient::CreateDefault(notifier_options_)); } // Make sure calling CreateDefault on a non-IO thread doesn't blow up. -TEST_F(PushClientTest, OffIOThread) { +TEST_F(PushClientTest, CreateDefaultOffIOThread) { base::Thread thread("Non-IO thread"); EXPECT_TRUE(thread.Start()); thread.message_loop()->PostTask( @@ -49,6 +49,13 @@ TEST_F(PushClientTest, OffIOThread) { thread.Stop(); } +// Make sure calling CreateDefaultOnIOThread on the IO thread doesn't +// blow up. +TEST_F(PushClientTest, CreateDefaultOnIOThreadOnIOThread) { + const scoped_ptr<PushClient> push_client( + PushClient::CreateDefaultOnIOThread(notifier_options_)); +} + } // namespace } // namespace notifier |