summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 20:44:08 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 20:44:08 +0000
commit4df27828d9fcc13b886a4aa878a16149025e63d2 (patch)
tree6fc53eb82cbcd8f7f514ff65b0d12d6a37f0a643 /webkit/glue
parenta1ddae6de490a6e415221b899067f31f78f52adf (diff)
downloadchromium_src-4df27828d9fcc13b886a4aa878a16149025e63d2.zip
chromium_src-4df27828d9fcc13b886a4aa878a16149025e63d2.tar.gz
chromium_src-4df27828d9fcc13b886a4aa878a16149025e63d2.tar.bz2
Remove base::Bind() from cpp_bound_class.h
We try not to include bind.h in header files for compilation speed. BUG=none TEST=trybots Review URL: http://codereview.chromium.org/8680004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/cpp_binding_example.cc20
-rw-r--r--webkit/glue/cpp_bound_class.h39
-rw-r--r--webkit/glue/cpp_bound_class_unittest.cc11
3 files changed, 23 insertions, 47 deletions
diff --git a/webkit/glue/cpp_binding_example.cc b/webkit/glue/cpp_binding_example.cc
index 79e96e4..678151a 100644
--- a/webkit/glue/cpp_binding_example.cc
+++ b/webkit/glue/cpp_binding_example.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -7,6 +7,9 @@
#include "cpp_binding_example.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+
namespace {
class PropertyCallbackExample : public CppBoundClass::PropertyCallback {
@@ -37,17 +40,22 @@ CppBindingExample::CppBindingExample() {
// Bind property with a callback.
BindProperty("my_value_with_callback", new PropertyCallbackExample());
// Bind property with a getter callback.
- BindProperty("same", &CppBindingExample::same);
+ BindGetterCallback("same", base::Bind(&CppBindingExample::same,
+ base::Unretained(this)));
// Map methods. See comment above about names.
- BindMethod("echoValue", &CppBindingExample::echoValue);
- BindMethod("echoType", &CppBindingExample::echoType);
- BindMethod("plus", &CppBindingExample::plus);
+ BindCallback("echoValue", base::Bind(&CppBindingExample::echoValue,
+ base::Unretained(this)));
+ BindCallback("echoType", base::Bind(&CppBindingExample::echoType,
+ base::Unretained(this)));
+ BindCallback("plus", base::Bind(&CppBindingExample::plus,
+ base::Unretained(this)));
// The fallback method is called when a nonexistent method is called on an
// object. If none is specified, calling a nonexistent method causes an
// exception to be thrown and the JavaScript execution is stopped.
- BindFallbackMethod(&CppBindingExample::fallbackMethod);
+ BindFallbackCallback(base::Bind(&CppBindingExample::fallbackMethod,
+ base::Unretained(this)));
my_value.Set(10);
my_other_value.Set("Reinitialized!");
diff --git a/webkit/glue/cpp_bound_class.h b/webkit/glue/cpp_bound_class.h
index 3481258..8bc0dfd 100644
--- a/webkit/glue/cpp_bound_class.h
+++ b/webkit/glue/cpp_bound_class.h
@@ -23,7 +23,6 @@
#include "webkit/glue/cpp_variant.h"
-#include "base/bind.h"
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
@@ -49,8 +48,8 @@ class CppBoundClass {
virtual bool SetValue(const CppVariant& value) = 0;
};
- // The constructor should call BindMethod, BindProperty, and
- // SetFallbackMethod as needed to set up the methods, properties, and
+ // The constructor should call BindCallback, BindProperty, and
+ // BindFallbackCallback as needed to set up the methods, properties, and
// fallback method.
CppBoundClass();
virtual ~CppBoundClass();
@@ -80,30 +79,11 @@ class CppBoundClass {
// Bind the Javascript method called |name| to the C++ 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|
- // must be a method of this CppBoundClass subclass.
- template<typename T>
- void BindMethod(const std::string& name,
- void (T::*method)(const CppArgumentList&, CppVariant*)) {
- 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,
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*)) {
- BindGetterCallback(
- name, base::Bind(method, base::Unretained(static_cast<T*>(this))));
- }
-
// Bind the Javascript property called |name| to a CppVariant |prop|.
void BindProperty(const std::string& name, CppVariant* prop);
@@ -125,21 +105,6 @@ class CppBoundClass {
fallback_callback_ = fallback_callback;
}
- // A wrapper for BindFallbackCallback, to simplify the common case of
- // binding a method on the current object. Though not verified here,
- // |method| must be a method of this CppBoundClass subclass.
- // Passing NULL for |method| clears out any existing binding.
- template<typename T>
- void BindFallbackMethod(
- void (T::*method)(const CppArgumentList&, CppVariant*)) {
- if (method) {
- BindFallbackCallback(base::Bind(method,
- base::Unretained(static_cast<T*>(this))));
- } else {
- BindFallbackCallback(Callback());
- }
- }
-
// Some fields are protected because some tests depend on accessing them,
// but otherwise they should be considered private.
diff --git a/webkit/glue/cpp_bound_class_unittest.cc b/webkit/glue/cpp_bound_class_unittest.cc
index fd6691f..0c97da5 100644
--- a/webkit/glue/cpp_bound_class_unittest.cc
+++ b/webkit/glue/cpp_bound_class_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -8,6 +8,8 @@
#include <vector>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/message_loop.h"
#include "base/string_util.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h"
@@ -40,9 +42,10 @@ class CppBindingExampleWithOptionalFallback : public CppBindingExample {
}
void set_fallback_method_enabled(bool state) {
- BindFallbackMethod(state ?
- &CppBindingExampleWithOptionalFallback::fallbackMethod
- : NULL);
+ BindFallbackCallback(state ?
+ base::Bind(&CppBindingExampleWithOptionalFallback::fallbackMethod,
+ base::Unretained(this))
+ : CppBoundClass::Callback());
}
// The fallback method does nothing, but because of it the JavaScript keeps