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

Unified Diff: webkit/glue/cpp_bound_class.h

Issue 8550010: base::Bind() conversion for webkit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 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
Index: webkit/glue/cpp_bound_class.h
diff --git a/webkit/glue/cpp_bound_class.h b/webkit/glue/cpp_bound_class.h
index 1f67e05ca9e7440d07befc0d987c0d26713df1bd..348125886eb6d979ee1298349a236458ab4879ac 100644
--- a/webkit/glue/cpp_bound_class.h
+++ b/webkit/glue/cpp_bound_class.h
@@ -23,7 +23,8 @@
#include "webkit/glue/cpp_variant.h"
-#include "base/callback_old.h"
+#include "base/bind.h"
awong 2011/11/21 21:46:56 We try pretty hard to keep bind.h out of headers.
dcheng 2011/11/21 22:04:16 It's not a huge change, but it might make sense in
+#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
namespace WebKit {
@@ -68,8 +69,8 @@ class CppBoundClass {
void BindToJavascript(WebKit::WebFrame* frame, const std::string& classname);
// The type of callbacks.
- typedef Callback2<const CppArgumentList&, CppVariant*>::Type Callback;
- typedef Callback1<CppVariant*>::Type GetterCallback;
+ typedef base::Callback<void(const CppArgumentList&, CppVariant*)> Callback;
+ typedef base::Callback<void(CppVariant*)> GetterCallback;
// Used by a test. Returns true if a method with name |name| exists,
// regardless of whether a fallback is registered.
@@ -77,7 +78,7 @@ class CppBoundClass {
protected:
// Bind the Javascript method called |name| to the C++ callback |callback|.
- void BindCallback(const std::string& name, Callback* callback);
+ void BindCallback(const std::string& name, const Callback& callback);
// A wrapper for BindCallback, to simplify the common case of binding a
// method on the current object. Though not verified here, |method|
@@ -85,24 +86,22 @@ class CppBoundClass {
template<typename T>
void BindMethod(const std::string& name,
void (T::*method)(const CppArgumentList&, CppVariant*)) {
- Callback* callback =
- NewCallback<T, const CppArgumentList&, CppVariant*>(
- static_cast<T*>(this), method);
- BindCallback(name, callback);
+ BindCallback(name,
+ base::Bind(method, base::Unretained(static_cast<T*>(this))));
}
// Bind Javascript property |name| to the C++ getter callback |callback|.
// This can be used to create read-only properties.
- void BindGetterCallback(const std::string& name, GetterCallback* callback);
+ void BindGetterCallback(const std::string& name,
+ const GetterCallback& callback);
// A wrapper for BindGetterCallback, to simplify the common case of binding a
// property on the current object. Though not verified here, |method|
// must be a method of this CppBoundClass subclass.
template<typename T>
void BindProperty(const std::string& name, void (T::*method)(CppVariant*)) {
- GetterCallback* callback =
- NewCallback<T, CppVariant*>(static_cast<T*>(this), method);
- BindGetterCallback(name, callback);
+ BindGetterCallback(
+ name, base::Bind(method, base::Unretained(static_cast<T*>(this))));
}
// Bind the Javascript property called |name| to a CppVariant |prop|.
@@ -122,8 +121,8 @@ class CppBoundClass {
// as it may cause unexpected behaviors (a JavaScript object with a
// fallback always returns true when checked for a method's
// existence).
- void BindFallbackCallback(Callback* fallback_callback) {
- fallback_callback_.reset(fallback_callback);
+ void BindFallbackCallback(const Callback& fallback_callback) {
+ fallback_callback_ = fallback_callback;
}
// A wrapper for BindFallbackCallback, to simplify the common case of
@@ -134,12 +133,10 @@ class CppBoundClass {
void BindFallbackMethod(
void (T::*method)(const CppArgumentList&, CppVariant*)) {
if (method) {
- Callback* callback =
- NewCallback<T, const CppArgumentList&, CppVariant*>(
- static_cast<T*>(this), method);
- BindFallbackCallback(callback);
+ BindFallbackCallback(base::Bind(method,
+ base::Unretained(static_cast<T*>(this))));
} else {
- BindFallbackCallback(NULL);
+ BindFallbackCallback(Callback());
}
}
@@ -147,14 +144,14 @@ class CppBoundClass {
// but otherwise they should be considered private.
typedef std::map<NPIdentifier, PropertyCallback*> PropertyList;
- typedef std::map<NPIdentifier, Callback*> MethodList;
+ typedef std::map<NPIdentifier, Callback> MethodList;
// These maps associate names with property and method pointers to be
// exposed to JavaScript.
PropertyList properties_;
MethodList methods_;
// The callback gets invoked when a call is made to an nonexistent method.
- scoped_ptr<Callback> fallback_callback_;
+ Callback fallback_callback_;
private:
// NPObject callbacks.

Powered by Google App Engine
This is Rietveld 408576698