summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 03:12:54 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 03:12:54 +0000
commit8ef69229433e8d735dcd51f9412011ced82b47d0 (patch)
tree50a8139cb9431b88f9bb567ea3edd636370a9889
parentea5d729346a55932e1e7c3ef7bb08550d07e2c1f (diff)
downloadchromium_src-8ef69229433e8d735dcd51f9412011ced82b47d0.zip
chromium_src-8ef69229433e8d735dcd51f9412011ced82b47d0.tar.gz
chromium_src-8ef69229433e8d735dcd51f9412011ced82b47d0.tar.bz2
Convert all of remoting/* to base::Bind().
Removing base/task.h also. BUG=none TEST=existing. Review URL: http://codereview.chromium.org/8994015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115074 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/client/input_handler.h1
-rw-r--r--remoting/client/plugin/chromoting_instance.cc1
-rw-r--r--remoting/client/plugin/chromoting_scriptable_object.cc17
-rw-r--r--remoting/client/plugin/chromoting_scriptable_object.h2
-rw-r--r--remoting/client/plugin/pepper_input_handler.h1
-rw-r--r--remoting/client/plugin/pepper_util.cc14
-rw-r--r--remoting/client/plugin/pepper_util.h18
-rw-r--r--remoting/client/plugin/pepper_view.cc12
-rw-r--r--remoting/client/plugin/pepper_view.h4
-rw-r--r--remoting/client/rectangle_update_decoder.h2
-rw-r--r--remoting/host/chromoting_host_unittest.cc1
-rw-r--r--remoting/host/client_session.cc1
-rw-r--r--remoting/host/event_executor_linux.cc1
-rw-r--r--remoting/host/event_executor_mac.cc1
-rw-r--r--remoting/host/host_key_pair.cc1
-rw-r--r--remoting/host/host_key_pair.h1
-rw-r--r--remoting/host/in_memory_host_config.cc3
-rw-r--r--remoting/host/json_host_config.cc1
-rw-r--r--remoting/host/screen_recorder.cc2
-rw-r--r--remoting/host/screen_recorder_unittest.cc1
-rw-r--r--remoting/jingle_glue/fake_signal_strategy.cc6
-rw-r--r--remoting/jingle_glue/fake_signal_strategy.h4
-rw-r--r--remoting/protocol/jingle_session.cc13
-rw-r--r--remoting/protocol/jingle_session.h2
24 files changed, 48 insertions, 62 deletions
diff --git a/remoting/client/input_handler.h b/remoting/client/input_handler.h
index 34265f6..e6082a2 100644
--- a/remoting/client/input_handler.h
+++ b/remoting/client/input_handler.h
@@ -8,7 +8,6 @@
#include <set>
#include "base/basictypes.h"
-#include "base/task.h"
#include "remoting/proto/event.pb.h"
namespace remoting {
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index a65a2a0..e6dea0e 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -14,7 +14,6 @@
#include "base/stringprintf.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
-#include "base/task.h"
#include "base/threading/thread.h"
#include "media/base/media.h"
#include "ppapi/cpp/completion_callback.h"
diff --git a/remoting/client/plugin/chromoting_scriptable_object.cc b/remoting/client/plugin/chromoting_scriptable_object.cc
index a9a60d5..218c3c9 100644
--- a/remoting/client/plugin/chromoting_scriptable_object.cc
+++ b/remoting/client/plugin/chromoting_scriptable_object.cc
@@ -4,6 +4,7 @@
#include "remoting/client/plugin/chromoting_scriptable_object.h"
+#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop_proxy.h"
// TODO(wez): Remove this when crbug.com/86353 is complete.
@@ -44,8 +45,7 @@ const char kRoundTripLatencyAttribute[] = "roundTripLatency";
ChromotingScriptableObject::ChromotingScriptableObject(
ChromotingInstance* instance, base::MessageLoopProxy* plugin_message_loop)
: instance_(instance),
- plugin_message_loop_(plugin_message_loop),
- ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
+ plugin_message_loop_(plugin_message_loop) {
}
ChromotingScriptableObject::~ChromotingScriptableObject() {
@@ -283,8 +283,8 @@ void ChromotingScriptableObject::AttachXmppProxy(PepperXmppProxy* xmpp_proxy) {
void ChromotingScriptableObject::SendIq(const std::string& message_xml) {
plugin_message_loop_->PostTask(
- FROM_HERE, task_factory_.NewRunnableMethod(
- &ChromotingScriptableObject::DoSendIq, message_xml));
+ FROM_HERE, base::Bind(
+ &ChromotingScriptableObject::DoSendIq, AsWeakPtr(), message_xml));
}
void ChromotingScriptableObject::AddAttribute(const std::string& name,
@@ -302,15 +302,16 @@ void ChromotingScriptableObject::AddMethod(const std::string& name,
void ChromotingScriptableObject::SignalConnectionInfoChange(int status,
int error) {
plugin_message_loop_->PostTask(
- FROM_HERE, task_factory_.NewRunnableMethod(
+ FROM_HERE, base::Bind(
&ChromotingScriptableObject::DoSignalConnectionInfoChange,
- status, error));
+ AsWeakPtr(), status, error));
}
void ChromotingScriptableObject::SignalDesktopSizeChange() {
plugin_message_loop_->PostTask(
- FROM_HERE, task_factory_.NewRunnableMethod(
- &ChromotingScriptableObject::DoSignalDesktopSizeChange));
+ FROM_HERE, base::Bind(
+ &ChromotingScriptableObject::DoSignalDesktopSizeChange,
+ AsWeakPtr()));
}
void ChromotingScriptableObject::DoSignalConnectionInfoChange(int status,
diff --git a/remoting/client/plugin/chromoting_scriptable_object.h b/remoting/client/plugin/chromoting_scriptable_object.h
index 547b349..ece9003 100644
--- a/remoting/client/plugin/chromoting_scriptable_object.h
+++ b/remoting/client/plugin/chromoting_scriptable_object.h
@@ -102,7 +102,6 @@
#include <string>
#include <vector>
-#include "base/task.h"
#include "base/memory/weak_ptr.h"
#include "ppapi/cpp/dev/scriptable_object_deprecated.h"
#include "ppapi/cpp/var.h"
@@ -235,7 +234,6 @@ class ChromotingScriptableObject
ChromotingInstance* instance_;
scoped_refptr<base::MessageLoopProxy> plugin_message_loop_;
- ScopedRunnableMethodFactory<ChromotingScriptableObject> task_factory_;
DISALLOW_COPY_AND_ASSIGN(ChromotingScriptableObject);
};
diff --git a/remoting/client/plugin/pepper_input_handler.h b/remoting/client/plugin/pepper_input_handler.h
index bc7f2be..759e5f2 100644
--- a/remoting/client/plugin/pepper_input_handler.h
+++ b/remoting/client/plugin/pepper_input_handler.h
@@ -5,6 +5,7 @@
#ifndef REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_
#define REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_
+#include "base/compiler_specific.h"
#include "remoting/client/input_handler.h"
namespace pp {
diff --git a/remoting/client/plugin/pepper_util.cc b/remoting/client/plugin/pepper_util.cc
index 2a726d2..013bba4 100644
--- a/remoting/client/plugin/pepper_util.cc
+++ b/remoting/client/plugin/pepper_util.cc
@@ -4,20 +4,16 @@
#include "remoting/client/plugin/pepper_util.h"
-#include "base/task.h"
+#include "base/callback.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/cpp/module.h"
namespace remoting {
-void CompletionCallbackTaskAdapter(void* user_data, int32_t not_used) {
- Task* task = reinterpret_cast<Task*>(user_data);
- task->Run();
- delete task;
-}
-
-pp::CompletionCallback TaskToCompletionCallback(Task* task) {
- return pp::CompletionCallback(&CompletionCallbackTaskAdapter, task);
+void CompletionCallbackClosureAdapter(void* user_data, int32_t not_used) {
+ base::Closure* closure = reinterpret_cast<base::Closure*>(user_data);
+ closure->Run();
+ delete closure;
}
} // namespace remoting
diff --git a/remoting/client/plugin/pepper_util.h b/remoting/client/plugin/pepper_util.h
index 9de64bc..90dbeb3 100644
--- a/remoting/client/plugin/pepper_util.h
+++ b/remoting/client/plugin/pepper_util.h
@@ -6,22 +6,18 @@
#define REMOTING_CLIENT_PLUGIN_PLUGIN_UTIL_H_
#include "base/basictypes.h"
+#include "base/callback_forward.h"
#include "ppapi/cpp/completion_callback.h"
-class Task;
-
namespace remoting {
-// Function for adapting a Chromium style Task into a
-// PP_CompletionCallback friendly function. The Task object should be passed
-// as |user_data|. This function will invoke Task::Run() on |user_data| when
-// called, and then delete |user_data|.
-void CompletionCallbackTaskAdapter(void* user_data, int32_t not_used);
-
-// Converts a Task* to a pp::CompletionCallback suitable for use with ppapi C++
-// APIs that require a pp::CompletionCallback. Takes ownership of |task|.
-pp::CompletionCallback TaskToCompletionCallback(Task* task);
+// Function for adapting a Chromium base::Closure to a PP_CompletionCallback
+// friendly function. The base::Closure object should be a dynamically
+// allocated copy of the result from base::Bind(). It should be passed as
+// |user_data|. This function will invoke base::Closure::Run() on
+// |user_data| when called, and then delete |user_data|.
+void CompletionCallbackClosureAdapter(void* user_data, int32_t not_used);
} // namespace remoting
diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc
index 04f8f98..ec29290 100644
--- a/remoting/client/plugin/pepper_view.cc
+++ b/remoting/client/plugin/pepper_view.cc
@@ -48,7 +48,7 @@ PepperView::PepperView(ChromotingInstance* instance, ClientContext* context)
flush_blocked_(false),
is_static_fill_(false),
static_fill_color_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
PepperView::~PepperView() {
@@ -61,7 +61,7 @@ bool PepperView::Initialize() {
void PepperView::TearDown() {
DCHECK(context_->main_message_loop()->BelongsToCurrentThread());
- task_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
}
void PepperView::Paint() {
@@ -178,8 +178,10 @@ void PepperView::BlankRect(pp::ImageData& image_data, const pp::Rect& rect) {
}
void PepperView::FlushGraphics(base::Time paint_start) {
- scoped_ptr<Task> task(
- task_factory_.NewRunnableMethod(&PepperView::OnPaintDone, paint_start));
+ scoped_ptr<base::Closure> task(
+ new base::Closure(
+ base::Bind(&PepperView::OnPaintDone, weak_factory_.GetWeakPtr(),
+ paint_start)));
// Flag needs to be set here in order to get a proper error code for Flush().
// Otherwise Flush() will always return PP_OK_COMPLETIONPENDING and the error
@@ -188,7 +190,7 @@ void PepperView::FlushGraphics(base::Time paint_start) {
// Note that we can also handle this by providing an actual callback which
// takes the result code. Right now everything goes to the task that doesn't
// result value.
- pp::CompletionCallback pp_callback(&CompletionCallbackTaskAdapter,
+ pp::CompletionCallback pp_callback(&CompletionCallbackClosureAdapter,
task.get(),
PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
int error = graphics2d_.Flush(pp_callback);
diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h
index 9036650..a64ae7f 100644
--- a/remoting/client/plugin/pepper_view.h
+++ b/remoting/client/plugin/pepper_view.h
@@ -13,7 +13,7 @@
#include <vector>
#include "base/memory/scoped_ptr.h"
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "media/base/video_frame.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/point.h"
@@ -103,7 +103,7 @@ class PepperView : public ChromotingView,
bool is_static_fill_;
uint32 static_fill_color_;
- ScopedRunnableMethodFactory<PepperView> task_factory_;
+ base::WeakPtrFactory<PepperView> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PepperView);
};
diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h
index fd5b2c2..cdbfa05 100644
--- a/remoting/client/rectangle_update_decoder.h
+++ b/remoting/client/rectangle_update_decoder.h
@@ -5,8 +5,8 @@
#ifndef REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H_
#define REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H_
+#include "base/callback_forward.h"
#include "base/memory/scoped_ptr.h"
-#include "base/task.h"
#include "media/base/video_frame.h"
#include "remoting/base/decoder.h"
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index f366a08..7ce925b 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -5,7 +5,6 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop_proxy.h"
-#include "base/task.h"
#include "remoting/host/capturer_fake.h"
#include "remoting/host/chromoting_host.h"
#include "remoting/host/chromoting_host_context.h"
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index df75407..c358508 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -7,7 +7,6 @@
#include <algorithm>
#include "base/message_loop_proxy.h"
-#include "base/task.h"
#include "remoting/host/capturer.h"
#include "remoting/proto/event.pb.h"
diff --git a/remoting/host/event_executor_linux.cc b/remoting/host/event_executor_linux.cc
index cfbd71b..0455925 100644
--- a/remoting/host/event_executor_linux.cc
+++ b/remoting/host/event_executor_linux.cc
@@ -14,7 +14,6 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/message_loop.h"
-#include "base/task.h"
#include "remoting/proto/internal.pb.h"
namespace remoting {
diff --git a/remoting/host/event_executor_mac.cc b/remoting/host/event_executor_mac.cc
index 6844df0..cb65832 100644
--- a/remoting/host/event_executor_mac.cc
+++ b/remoting/host/event_executor_mac.cc
@@ -11,7 +11,6 @@
#include "base/compiler_specific.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/message_loop.h"
-#include "base/task.h"
#include "remoting/host/capturer.h"
#include "remoting/proto/internal.pb.h"
#include "remoting/protocol/message_decoder.h"
diff --git a/remoting/host/host_key_pair.cc b/remoting/host/host_key_pair.cc
index 4f81aa8..7427471 100644
--- a/remoting/host/host_key_pair.cc
+++ b/remoting/host/host_key_pair.cc
@@ -11,7 +11,6 @@
#include "base/base64.h"
#include "base/logging.h"
#include "base/rand_util.h"
-#include "base/task.h"
#include "base/time.h"
#include "crypto/rsa_private_key.h"
#include "crypto/signature_creator.h"
diff --git a/remoting/host/host_key_pair.h b/remoting/host/host_key_pair.h
index 41a5420..6fd74f3 100644
--- a/remoting/host/host_key_pair.h
+++ b/remoting/host/host_key_pair.h
@@ -9,7 +9,6 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/task.h"
namespace crypto {
class RSAPrivateKey;
diff --git a/remoting/host/in_memory_host_config.cc b/remoting/host/in_memory_host_config.cc
index 253b563..4df3ada 100644
--- a/remoting/host/in_memory_host_config.cc
+++ b/remoting/host/in_memory_host_config.cc
@@ -1,10 +1,9 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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 "remoting/host/in_memory_host_config.h"
-#include "base/task.h"
#include "base/values.h"
namespace remoting {
diff --git a/remoting/host/json_host_config.cc b/remoting/host/json_host_config.cc
index 66ac912..97f1d74 100644
--- a/remoting/host/json_host_config.cc
+++ b/remoting/host/json_host_config.cc
@@ -11,7 +11,6 @@
#include "base/location.h"
#include "base/message_loop_proxy.h"
#include "base/synchronization/lock.h"
-#include "base/task.h"
#include "base/values.h"
namespace remoting {
diff --git a/remoting/host/screen_recorder.cc b/remoting/host/screen_recorder.cc
index 0098a0a..8aa333f 100644
--- a/remoting/host/screen_recorder.cc
+++ b/remoting/host/screen_recorder.cc
@@ -7,12 +7,12 @@
#include <algorithm>
#include "base/bind.h"
+#include "base/callback.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop_proxy.h"
#include "base/stl_util.h"
#include "base/sys_info.h"
-#include "base/task.h"
#include "base/time.h"
#include "remoting/base/capture_data.h"
#include "remoting/proto/control.pb.h"
diff --git a/remoting/host/screen_recorder_unittest.cc b/remoting/host/screen_recorder_unittest.cc
index 4a35cec..ae9e636 100644
--- a/remoting/host/screen_recorder_unittest.cc
+++ b/remoting/host/screen_recorder_unittest.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/message_loop.h"
-#include "base/task.h"
#include "remoting/base/base_mock_objects.h"
#include "remoting/host/host_mock_objects.h"
#include "remoting/proto/video.pb.h"
diff --git a/remoting/jingle_glue/fake_signal_strategy.cc b/remoting/jingle_glue/fake_signal_strategy.cc
index 7c219a7..4cbfd23 100644
--- a/remoting/jingle_glue/fake_signal_strategy.cc
+++ b/remoting/jingle_glue/fake_signal_strategy.cc
@@ -25,7 +25,7 @@ FakeSignalStrategy::FakeSignalStrategy(const std::string& jid)
: jid_(jid),
peer_(NULL),
last_id_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
@@ -85,8 +85,8 @@ std::string FakeSignalStrategy::GetNextId() {
void FakeSignalStrategy::OnIncomingMessage(buzz::XmlElement* stanza) {
pending_messages_.push(stanza);
MessageLoop::current()->PostTask(
- FROM_HERE, task_factory_.NewRunnableMethod(
- &FakeSignalStrategy::DeliverIncomingMessages));
+ FROM_HERE, base::Bind(&FakeSignalStrategy::DeliverIncomingMessages,
+ weak_factory_.GetWeakPtr()));
}
void FakeSignalStrategy::DeliverIncomingMessages() {
diff --git a/remoting/jingle_glue/fake_signal_strategy.h b/remoting/jingle_glue/fake_signal_strategy.h
index d54276b..e14931f 100644
--- a/remoting/jingle_glue/fake_signal_strategy.h
+++ b/remoting/jingle_glue/fake_signal_strategy.h
@@ -8,7 +8,7 @@
#include <queue>
#include <string>
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "remoting/jingle_glue/iq_sender.h"
#include "remoting/jingle_glue/signal_strategy.h"
@@ -45,7 +45,7 @@ class FakeSignalStrategy : public SignalStrategy,
std::queue<buzz::XmlElement*> pending_messages_;
- ScopedRunnableMethodFactory<FakeSignalStrategy> task_factory_;
+ base::WeakPtrFactory<FakeSignalStrategy> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(FakeSignalStrategy);
};
diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc
index 8abada2..ae1009e 100644
--- a/remoting/protocol/jingle_session.cc
+++ b/remoting/protocol/jingle_session.cc
@@ -41,7 +41,7 @@ JingleSession::JingleSession(
closing_(false),
cricket_session_(cricket_session),
config_set_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
jid_ = cricket_session_->remote_name();
cricket_session_->SignalState.connect(this, &JingleSession::OnSessionState);
cricket_session_->SignalError.connect(this, &JingleSession::OnSessionError);
@@ -286,12 +286,15 @@ void JingleSession::OnInitiate() {
// method.
// TODO(sergeyu): Add set_incoming_only() in TransportChannelProxy.
jingle_session_manager_->message_loop_->PostTask(
- FROM_HERE, task_factory_.NewRunnableMethod(
- &JingleSession::SetState, CONNECTING));
+ FROM_HERE,
+ base::Bind(&JingleSession::SetState,
+ weak_factory_.GetWeakPtr(),
+ CONNECTING));
} else {
jingle_session_manager_->message_loop_->PostTask(
- FROM_HERE, task_factory_.NewRunnableMethod(
- &JingleSession::AcceptConnection));
+ FROM_HERE,
+ base::Bind(&JingleSession::AcceptConnection,
+ weak_factory_.GetWeakPtr()));
}
}
diff --git a/remoting/protocol/jingle_session.h b/remoting/protocol/jingle_session.h
index 1c8b2cb..3f6b46a 100644
--- a/remoting/protocol/jingle_session.h
+++ b/remoting/protocol/jingle_session.h
@@ -145,7 +145,7 @@ class JingleSession : public protocol::Session,
// the object.
std::string terminate_reason_;
- ScopedRunnableMethodFactory<JingleSession> task_factory_;
+ base::WeakPtrFactory<JingleSession> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(JingleSession);
};