summaryrefslogtreecommitdiffstats
path: root/webkit
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
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')
-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
-rw-r--r--webkit/tools/test_shell/accessibility_ui_element.cc171
-rw-r--r--webkit/tools/test_shell/layout_test_controller.cc14
5 files changed, 151 insertions, 104 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
diff --git a/webkit/tools/test_shell/accessibility_ui_element.cc b/webkit/tools/test_shell/accessibility_ui_element.cc
index 78988a9..79acc51 100644
--- a/webkit/tools/test_shell/accessibility_ui_element.cc
+++ b/webkit/tools/test_shell/accessibility_ui_element.cc
@@ -2,6 +2,8 @@
// 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/bind_helpers.h"
#include "base/logging.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h"
@@ -233,55 +235,109 @@ AccessibilityUIElement::AccessibilityUIElement(
DCHECK(factory);
- BindMethod("allAttributes", &AccessibilityUIElement::AllAttributesCallback);
- BindMethod("attributesOfLinkedUIElements",
- &AccessibilityUIElement::AttributesOfLinkedUIElementsCallback);
- BindMethod("attributesOfDocumentLinks",
- &AccessibilityUIElement::AttributesOfDocumentLinksCallback);
- BindMethod("attributesOfChildren",
- &AccessibilityUIElement::AttributesOfChildrenCallback);
- BindMethod("parameterizedAttributeNames",
- &AccessibilityUIElement::ParametrizedAttributeNamesCallback);
- BindMethod("lineForIndex", &AccessibilityUIElement::LineForIndexCallback);
- BindMethod("boundsForRange", &AccessibilityUIElement::BoundsForRangeCallback);
- BindMethod("stringForRange", &AccessibilityUIElement::StringForRangeCallback);
- BindMethod("childAtIndex", &AccessibilityUIElement::ChildAtIndexCallback);
- BindMethod("elementAtPoint", &AccessibilityUIElement::ElementAtPointCallback);
- BindMethod("attributesOfColumnHeaders",
- &AccessibilityUIElement::AttributesOfColumnHeadersCallback);
- BindMethod("attributesOfRowHeaders",
- &AccessibilityUIElement::AttributesOfRowHeadersCallback);
- BindMethod("attributesOfColumns",
- &AccessibilityUIElement::AttributesOfColumnsCallback);
- BindMethod("attributesOfRows",
- &AccessibilityUIElement::AttributesOfRowsCallback);
- BindMethod("attributesOfVisibleCells",
- &AccessibilityUIElement::AttributesOfVisibleCellsCallback);
- BindMethod("attributesOfHeader",
- &AccessibilityUIElement::AttributesOfHeaderCallback);
- BindMethod("indexInTable", &AccessibilityUIElement::IndexInTableCallback);
- BindMethod("rowIndexRange", &AccessibilityUIElement::RowIndexRangeCallback);
- BindMethod("columnIndexRange",
- &AccessibilityUIElement::ColumnIndexRangeCallback);
- BindMethod("cellForColumnAndRow",
- &AccessibilityUIElement::CellForColumnAndRowCallback);
- BindMethod("titleUIElement", &AccessibilityUIElement::TitleUIElementCallback);
- BindMethod("setSelectedTextRange",
- &AccessibilityUIElement::SetSelectedTextRangeCallback);
- BindMethod("attributeValue", &AccessibilityUIElement::AttributeValueCallback);
- BindMethod("isAttributeSettable",
- &AccessibilityUIElement::IsAttributeSettableCallback);
- BindMethod("isActionSupported",
- &AccessibilityUIElement::IsActionSupportedCallback);
- BindMethod("parentElement", &AccessibilityUIElement::ParentElementCallback);
- BindMethod("increment", &AccessibilityUIElement::IncrementCallback);
- BindMethod("decrement", &AccessibilityUIElement::DecrementCallback);
-
- BindProperty("role", &AccessibilityUIElement::RoleGetterCallback);
+ BindCallback("allAttributes",
+ base::Bind(&AccessibilityUIElement::AllAttributesCallback,
+ base::Unretained(this)));
+ BindCallback(
+ "attributesOfLinkedUIElements",
+ base::Bind(&AccessibilityUIElement::AttributesOfLinkedUIElementsCallback,
+ base::Unretained(this)));
+ BindCallback(
+ "attributesOfDocumentLinks",
+ base::Bind(&AccessibilityUIElement::AttributesOfDocumentLinksCallback,
+ base::Unretained(this)));
+ BindCallback(
+ "attributesOfChildren",
+ base::Bind(&AccessibilityUIElement::AttributesOfChildrenCallback,
+ base::Unretained(this)));
+ BindCallback(
+ "parameterizedAttributeNames",
+ base::Bind(&AccessibilityUIElement::ParametrizedAttributeNamesCallback,
+ base::Unretained(this)));
+ BindCallback("lineForIndex",
+ base::Bind(&AccessibilityUIElement::LineForIndexCallback,
+ base::Unretained(this)));
+ BindCallback("boundsForRange",
+ base::Bind(&AccessibilityUIElement::BoundsForRangeCallback,
+ base::Unretained(this)));
+ BindCallback("stringForRange",
+ base::Bind(&AccessibilityUIElement::StringForRangeCallback,
+ base::Unretained(this)));
+ BindCallback("childAtIndex",
+ base::Bind(&AccessibilityUIElement::ChildAtIndexCallback,
+ base::Unretained(this)));
+ BindCallback("elementAtPoint",
+ base::Bind(&AccessibilityUIElement::ElementAtPointCallback,
+ base::Unretained(this)));
+ BindCallback(
+ "attributesOfColumnHeaders",
+ base::Bind(&AccessibilityUIElement::AttributesOfColumnHeadersCallback,
+ base::Unretained(this)));
+ BindCallback(
+ "attributesOfRowHeaders",
+ base::Bind(&AccessibilityUIElement::AttributesOfRowHeadersCallback,
+ base::Unretained(this)));
+ BindCallback("attributesOfColumns",
+ base::Bind(&AccessibilityUIElement::AttributesOfColumnsCallback,
+ base::Unretained(this)));
+ BindCallback("attributesOfRows",
+ base::Bind(&AccessibilityUIElement::AttributesOfRowsCallback,
+ base::Unretained(this)));
+ BindCallback(
+ "attributesOfVisibleCells",
+ base::Bind(&AccessibilityUIElement::AttributesOfVisibleCellsCallback,
+ base::Unretained(this)));
+ BindCallback("attributesOfHeader",
+ base::Bind(&AccessibilityUIElement::AttributesOfHeaderCallback,
+ base::Unretained(this)));
+ BindCallback("indexInTable",
+ base::Bind(&AccessibilityUIElement::IndexInTableCallback,
+ base::Unretained(this)));
+ BindCallback("rowIndexRange",
+ base::Bind(&AccessibilityUIElement::RowIndexRangeCallback,
+ base::Unretained(this)));
+ BindCallback("columnIndexRange",
+ base::Bind(&AccessibilityUIElement::ColumnIndexRangeCallback,
+ base::Unretained(this)));
+ BindCallback("cellForColumnAndRow",
+ base::Bind(&AccessibilityUIElement::CellForColumnAndRowCallback,
+ base::Unretained(this)));
+ BindCallback("titleUIElement",
+ base::Bind(&AccessibilityUIElement::TitleUIElementCallback,
+ base::Unretained(this)));
+ BindCallback("setSelectedTextRange",
+ base::Bind(&AccessibilityUIElement::SetSelectedTextRangeCallback,
+ base::Unretained(this)));
+ BindCallback("attributeValue",
+ base::Bind(&AccessibilityUIElement::AttributeValueCallback,
+ base::Unretained(this)));
+ BindCallback("isAttributeSettable",
+ base::Bind(&AccessibilityUIElement::IsAttributeSettableCallback,
+ base::Unretained(this)));
+ BindCallback("isActionSupported",
+ base::Bind(&AccessibilityUIElement::IsActionSupportedCallback,
+ base::Unretained(this)));
+ BindCallback("parentElement",
+ base::Bind(&AccessibilityUIElement::ParentElementCallback,
+ base::Unretained(this)));
+ BindCallback("increment",
+ base::Bind(&AccessibilityUIElement::IncrementCallback,
+ base::Unretained(this)));
+ BindCallback("decrement",
+ base::Bind(&AccessibilityUIElement::DecrementCallback,
+ base::Unretained(this)));
+
+ BindGetterCallback("role",
+ base::Bind(&AccessibilityUIElement::RoleGetterCallback,
+ base::Unretained(this)));
BindProperty("subrole", &subrole_);
- BindProperty("title", &AccessibilityUIElement::TitleGetterCallback);
- BindProperty("description",
- &AccessibilityUIElement::DescriptionGetterCallback);
+ BindGetterCallback("title",
+ base::Bind(&AccessibilityUIElement::TitleGetterCallback,
+ base::Unretained(this)));
+ BindGetterCallback(
+ "description",
+ base::Bind(&AccessibilityUIElement::DescriptionGetterCallback,
+ base::Unretained(this)));
BindProperty("language", &language_);
BindProperty("x", &x_);
BindProperty("y", &y_);
@@ -292,16 +348,25 @@ AccessibilityUIElement::AccessibilityUIElement(
BindProperty("intValue", &int_value_);
BindProperty("minValue", &min_value_);
BindProperty("maxValue", &max_value_);
- BindProperty("childrenCount",
- &AccessibilityUIElement::ChildrenCountGetterCallback);
+ BindGetterCallback(
+ "childrenCount",
+ base::Bind(&AccessibilityUIElement::ChildrenCountGetterCallback,
+ base::Unretained(this)));
BindProperty("insertionPointLineNumber", &insertion_point_line_number_);
BindProperty("selectedTextRange", &selected_text_range);
- BindProperty("isEnabled", &AccessibilityUIElement::IsEnabledGetterCallback);
+ BindGetterCallback(
+ "isEnabled",
+ base::Bind(&AccessibilityUIElement::IsEnabledGetterCallback,
+ base::Unretained(this)));
BindProperty("isRequired", &is_required_);
- BindProperty("isSelected", &AccessibilityUIElement::IsSelectedGetterCallback);
+ BindGetterCallback(
+ "isSelected",
+ base::Bind(&AccessibilityUIElement::IsSelectedGetterCallback,
+ base::Unretained(this)));
BindProperty("valueDescription", &value_description_);
- BindFallbackMethod(&AccessibilityUIElement::FallbackCallback);
+ BindFallbackCallback(base::Bind(&AccessibilityUIElement::FallbackCallback,
+ base::Unretained(this)));
}
AccessibilityUIElement::~AccessibilityUIElement() {}
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc
index c295aef..ce99a57 100644
--- a/webkit/tools/test_shell/layout_test_controller.cc
+++ b/webkit/tools/test_shell/layout_test_controller.cc
@@ -1,4 +1,4 @@
-// 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.
@@ -11,6 +11,7 @@
#include "base/base64.h"
#include "base/basictypes.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
@@ -81,11 +82,16 @@ LayoutTestController::LayoutTestController(TestShell* shell) :
// they will use when called by JavaScript. The actual binding of those
// names to their methods will be done by calling BindToJavaScript() (defined
// by CppBoundClass, the parent to LayoutTestController).
- BindMethod("waitUntilDone", &LayoutTestController::waitUntilDone);
- BindMethod("notifyDone", &LayoutTestController::notifyDone);
+ BindCallback("waitUntilDone",
+ base::Bind(&LayoutTestController::waitUntilDone,
+ base::Unretained(this)));
+ BindCallback("notifyDone",
+ base::Bind(&LayoutTestController::notifyDone,
+ base::Unretained(this)));
// The fallback method is called when an unknown method is invoked.
- BindFallbackMethod(&LayoutTestController::fallbackMethod);
+ BindFallbackCallback(base::Bind(&LayoutTestController::fallbackMethod,
+ base::Unretained(this)));
}
LayoutTestController::~LayoutTestController() {