summaryrefslogtreecommitdiffstats
path: root/jingle/notifier
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-24 18:08:46 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-24 18:08:46 +0000
commit40eb07fda546a23dcbd07e9e8a68d1d1d9c2ef9a (patch)
tree3a598ff7a461d42ba7cf6a3907ae3ad32bafbd12 /jingle/notifier
parent66e2c28c1f940c38f54fc042b625c11d63375b48 (diff)
downloadchromium_src-40eb07fda546a23dcbd07e9e8a68d1d1d9c2ef9a.zip
chromium_src-40eb07fda546a23dcbd07e9e8a68d1d1d9c2ef9a.tar.gz
chromium_src-40eb07fda546a23dcbd07e9e8a68d1d1d9c2ef9a.tar.bz2
Move TaskPump class from jingle/notifier/base to jingle/glue
BUG=137140 Review URL: https://chromiumcodereview.appspot.com/10809066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148142 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle/notifier')
-rw-r--r--jingle/notifier/base/fake_base_task.h4
-rw-r--r--jingle/notifier/base/mock_task.cc13
-rw-r--r--jingle/notifier/base/mock_task.h26
-rw-r--r--jingle/notifier/base/task_pump.cc59
-rw-r--r--jingle/notifier/base/task_pump.h41
-rw-r--r--jingle/notifier/base/task_pump_unittest.cc50
-rw-r--r--jingle/notifier/base/weak_xmpp_client_unittest.cc8
-rw-r--r--jingle/notifier/base/xmpp_connection.cc4
-rw-r--r--jingle/notifier/base/xmpp_connection.h7
-rw-r--r--jingle/notifier/base/xmpp_connection_unittest.cc7
10 files changed, 17 insertions, 202 deletions
diff --git a/jingle/notifier/base/fake_base_task.h b/jingle/notifier/base/fake_base_task.h
index 6470e5a..2cb6d77 100644
--- a/jingle/notifier/base/fake_base_task.h
+++ b/jingle/notifier/base/fake_base_task.h
@@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/memory/weak_ptr.h"
-#include "jingle/notifier/base/task_pump.h"
+#include "jingle/glue/task_pump.h"
namespace buzz {
class XmppTaskParentInterface;
@@ -26,7 +26,7 @@ class FakeBaseTask {
base::WeakPtr<buzz::XmppTaskParentInterface> AsWeakPtr();
private:
- notifier::TaskPump task_pump_;
+ jingle_glue::TaskPump task_pump_;
base::WeakPtr<buzz::XmppTaskParentInterface> base_task_;
DISALLOW_COPY_AND_ASSIGN(FakeBaseTask);
diff --git a/jingle/notifier/base/mock_task.cc b/jingle/notifier/base/mock_task.cc
deleted file mode 100644
index 0c398cd..0000000
--- a/jingle/notifier/base/mock_task.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "jingle/notifier/base/mock_task.h"
-
-namespace notifier {
-
-MockTask::MockTask(TaskParent* parent) : talk_base::Task(parent) {}
-
-MockTask::~MockTask() {}
-
-} // namespace notifier
diff --git a/jingle/notifier/base/mock_task.h b/jingle/notifier/base/mock_task.h
deleted file mode 100644
index af9b0bb..0000000
--- a/jingle/notifier/base/mock_task.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// A mock of talk_base::Task.
-
-#ifndef JINGLE_NOTIFIER_MOCK_TASK_H_
-#define JINGLE_NOTIFIER_MOCK_TASK_H_
-
-#include "talk/base/task.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-namespace notifier {
-
-class MockTask : public talk_base::Task {
- public:
- MockTask(TaskParent* parent);
-
- virtual ~MockTask();
-
- MOCK_METHOD0(ProcessStart, int());
-};
-
-} // namespace notifier
-
-#endif // JINGLE_NOTIFIER_MOCK_TASK_H_
diff --git a/jingle/notifier/base/task_pump.cc b/jingle/notifier/base/task_pump.cc
deleted file mode 100644
index a282478..0000000
--- a/jingle/notifier/base/task_pump.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/bind.h"
-#include "base/message_loop.h"
-#include "jingle/notifier/base/task_pump.h"
-
-namespace notifier {
-
-TaskPump::TaskPump()
- : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
- posted_wake_(false),
- stopped_(false) {}
-
-TaskPump::~TaskPump() {
- DCHECK(CalledOnValidThread());
-}
-
-void TaskPump::WakeTasks() {
- DCHECK(CalledOnValidThread());
- if (!stopped_ && !posted_wake_) {
- MessageLoop* current_message_loop = MessageLoop::current();
- CHECK(current_message_loop);
- // Do the requested wake up.
- current_message_loop->PostTask(
- FROM_HERE,
- base::Bind(&TaskPump::CheckAndRunTasks, weak_factory_.GetWeakPtr()));
- posted_wake_ = true;
- }
-}
-
-int64 TaskPump::CurrentTime() {
- DCHECK(CalledOnValidThread());
- // Only timeout tasks rely on this function. Since we're not using
- // libjingle tasks for timeout, it's safe to return 0 here.
- return 0;
-}
-
-void TaskPump::Stop() {
- stopped_ = true;
-}
-
-void TaskPump::CheckAndRunTasks() {
- DCHECK(CalledOnValidThread());
- if (stopped_) {
- return;
- }
- posted_wake_ = false;
- // We shouldn't be using libjingle for timeout tasks, so we should
- // have no timeout tasks at all.
-
- // TODO(akalin): Add HasTimeoutTask() back in TaskRunner class and
- // uncomment this check.
- // DCHECK(!HasTimeoutTask())
- RunTasks();
-}
-
-} // namespace notifier
diff --git a/jingle/notifier/base/task_pump.h b/jingle/notifier/base/task_pump.h
deleted file mode 100644
index ee18fbe..0000000
--- a/jingle/notifier/base/task_pump.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef JINGLE_NOTIFIER_BASE_TASK_PUMP_H_
-#define JINGLE_NOTIFIER_BASE_TASK_PUMP_H_
-
-#include "base/compiler_specific.h"
-#include "base/memory/weak_ptr.h"
-#include "base/threading/non_thread_safe.h"
-#include "talk/base/taskrunner.h"
-
-namespace notifier {
-
-class TaskPump : public talk_base::TaskRunner, public base::NonThreadSafe {
- public:
- TaskPump();
-
- virtual ~TaskPump();
-
- // talk_base::TaskRunner implementation.
- virtual void WakeTasks() OVERRIDE;
- virtual int64 CurrentTime() OVERRIDE;
-
- // No tasks will be processed after this is called, even if
- // WakeTasks() is called.
- void Stop();
-
- private:
- void CheckAndRunTasks();
-
- base::WeakPtrFactory<TaskPump> weak_factory_;
- bool posted_wake_;
- bool stopped_;
-
- DISALLOW_COPY_AND_ASSIGN(TaskPump);
-};
-
-} // namespace notifier
-
-#endif // JINGLE_NOTIFIER_BASE_TASK_PUMP_H_
diff --git a/jingle/notifier/base/task_pump_unittest.cc b/jingle/notifier/base/task_pump_unittest.cc
deleted file mode 100644
index 0f4e1f4..0000000
--- a/jingle/notifier/base/task_pump_unittest.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "jingle/notifier/base/task_pump.h"
-
-#include "base/message_loop.h"
-#include "jingle/notifier/base/mock_task.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace notifier {
-
-namespace {
-
-using ::testing::Return;
-
-class TaskPumpTest : public testing::Test {
- private:
- MessageLoop message_loop_;
-};
-
-TEST_F(TaskPumpTest, Basic) {
- TaskPump task_pump;
- MockTask* task = new MockTask(&task_pump);
- // We have to do this since the state enum is protected in
- // talk_base::Task.
- const int TASK_STATE_DONE = 2;
- EXPECT_CALL(*task, ProcessStart()).WillOnce(Return(TASK_STATE_DONE));
- task->Start();
-
- MessageLoop::current()->RunAllPending();
-}
-
-TEST_F(TaskPumpTest, Stop) {
- TaskPump task_pump;
- MockTask* task = new MockTask(&task_pump);
- // We have to do this since the state enum is protected in
- // talk_base::Task.
- const int TASK_STATE_ERROR = 3;
- ON_CALL(*task, ProcessStart()).WillByDefault(Return(TASK_STATE_ERROR));
- EXPECT_CALL(*task, ProcessStart()).Times(0);
- task->Start();
-
- task_pump.Stop();
- MessageLoop::current()->RunAllPending();
-}
-
-} // namespace
-
-} // namespace notifier
diff --git a/jingle/notifier/base/weak_xmpp_client_unittest.cc b/jingle/notifier/base/weak_xmpp_client_unittest.cc
index fa833fe9..d4d5043 100644
--- a/jingle/notifier/base/weak_xmpp_client_unittest.cc
+++ b/jingle/notifier/base/weak_xmpp_client_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,7 +8,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
-#include "jingle/notifier/base/task_pump.h"
+#include "jingle/glue/task_pump.h"
#include "talk/base/sigslot.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -32,7 +32,7 @@ const char kOutputLog[] = "output log";
class WeakXmppClientTest : public testing::Test {
protected:
- WeakXmppClientTest() : task_pump_(new TaskPump()) {}
+ WeakXmppClientTest() : task_pump_(new jingle_glue::TaskPump()) {}
virtual ~WeakXmppClientTest() {}
@@ -62,7 +62,7 @@ class WeakXmppClientTest : public testing::Test {
// Needed by TaskPump.
MessageLoop message_loop_;
- scoped_ptr<TaskPump> task_pump_;
+ scoped_ptr<jingle_glue::TaskPump> task_pump_;
MockXmppDelegate mock_xmpp_delegate_;
};
diff --git a/jingle/notifier/base/xmpp_connection.cc b/jingle/notifier/base/xmpp_connection.cc
index f8f83fd..2284c7f 100644
--- a/jingle/notifier/base/xmpp_connection.cc
+++ b/jingle/notifier/base/xmpp_connection.cc
@@ -9,8 +9,8 @@
#include "base/message_loop.h"
#include "base/string_piece.h"
#include "jingle/glue/chrome_async_socket.h"
+#include "jingle/glue/task_pump.h"
#include "jingle/glue/xmpp_client_socket_factory.h"
-#include "jingle/notifier/base/task_pump.h"
#include "jingle/notifier/base/weak_xmpp_client.h"
#include "net/base/ssl_config_service.h"
#include "net/socket/client_socket_factory.h"
@@ -51,7 +51,7 @@ XmppConnection::XmppConnection(
const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
Delegate* delegate,
buzz::PreXmppAuth* pre_xmpp_auth)
- : task_pump_(new TaskPump()),
+ : task_pump_(new jingle_glue::TaskPump()),
on_connect_called_(false),
delegate_(delegate) {
DCHECK(delegate_);
diff --git a/jingle/notifier/base/xmpp_connection.h b/jingle/notifier/base/xmpp_connection.h
index d009c6d..b783764 100644
--- a/jingle/notifier/base/xmpp_connection.h
+++ b/jingle/notifier/base/xmpp_connection.h
@@ -24,9 +24,12 @@ class XmppClientSettings;
class XmppTaskParentInterface;
} // namespace
+namespace jingle_glue {
+class TaskPump;
+} // namespace jingle_glue
+
namespace notifier {
-class TaskPump;
class WeakXmppClient;
class XmppConnection
@@ -83,7 +86,7 @@ class XmppConnection
void ClearClient();
- scoped_ptr<TaskPump> task_pump_;
+ scoped_ptr<jingle_glue::TaskPump> task_pump_;
base::WeakPtr<WeakXmppClient> weak_xmpp_client_;
bool on_connect_called_;
Delegate* delegate_;
diff --git a/jingle/notifier/base/xmpp_connection_unittest.cc b/jingle/notifier/base/xmpp_connection_unittest.cc
index e410378..18c4837 100644
--- a/jingle/notifier/base/xmpp_connection_unittest.cc
+++ b/jingle/notifier/base/xmpp_connection_unittest.cc
@@ -11,8 +11,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
-#include "jingle/notifier/base/mock_task.h"
-#include "jingle/notifier/base/task_pump.h"
+#include "jingle/glue/mock_task.h"
+#include "jingle/glue/task_pump.h"
#include "jingle/notifier/base/weak_xmpp_client.h"
#include "net/base/cert_verifier.h"
#include "net/url_request/url_request_context_getter.h"
@@ -231,7 +231,8 @@ TEST_F(XmppConnectionTest, TasksDontRunAfterXmppConnectionDestructor) {
url_request_context_getter_,
&mock_xmpp_connection_delegate_, NULL);
- MockTask* task = new MockTask(xmpp_connection.task_pump_.get());
+ jingle_glue::MockTask* task =
+ new jingle_glue::MockTask(xmpp_connection.task_pump_.get());
// We have to do this since the state enum is protected in
// talk_base::Task.
const int TASK_STATE_ERROR = 3;