diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 00:49:23 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 00:49:23 +0000 |
commit | 92d86a2cbb32d57b7d875c198783d961bed62dd0 (patch) | |
tree | 43fdb4216080f1a4b6892077a868b4513b624832 /webkit/glue/cpp_bound_class.h | |
parent | da2c2744e7103580326855e6b9cad971d8398b54 (diff) | |
download | chromium_src-92d86a2cbb32d57b7d875c198783d961bed62dd0.zip chromium_src-92d86a2cbb32d57b7d875c198783d961bed62dd0.tar.gz chromium_src-92d86a2cbb32d57b7d875c198783d961bed62dd0.tar.bz2 |
base::Bind() conversion for webkit.
BUG=none
TEST=trybots
Review URL: http://codereview.chromium.org/8550010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/cpp_bound_class.h')
-rw-r--r-- | webkit/glue/cpp_bound_class.h | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/webkit/glue/cpp_bound_class.h b/webkit/glue/cpp_bound_class.h index 1f67e05..3481258 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" +#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. |