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

Unified Diff: chrome/test/automation/value_conversion_traits.cc

Issue 7522024: Refactor chromedriver's script execution to reduce amount of custom Value parsing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 4 months 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
« no previous file with comments | « chrome/test/automation/value_conversion_traits.h ('k') | chrome/test/automation/value_conversion_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/automation/value_conversion_traits.cc
diff --git a/chrome/test/automation/value_conversion_traits.cc b/chrome/test/automation/value_conversion_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f5c1f2c00ac66f7278b5cffa3243705ed2ac72dd
--- /dev/null
+++ b/chrome/test/automation/value_conversion_traits.cc
@@ -0,0 +1,99 @@
+// 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 "chrome/test/automation/value_conversion_traits.h"
+
+#include "base/values.h"
+
+using base::DictionaryValue;
+using base::ListValue;
+using base::Value;
+
+Value* ValueConversionTraits<int>::CreateValueFrom(int t) {
+ return Value::CreateIntegerValue(t);
+}
+
+bool ValueConversionTraits<int>::SetFromValue(const Value* value, int* t) {
+ return value->GetAsInteger(t);
+}
+
+bool ValueConversionTraits<int>::CanConvert(const Value* value) {
+ int t;
+ return SetFromValue(value, &t);
+}
+
+Value* ValueConversionTraits<bool>::CreateValueFrom(bool t) {
+ return Value::CreateBooleanValue(t);
+}
+
+bool ValueConversionTraits<bool>::SetFromValue(const Value* value, bool* t) {
+ return value->GetAsBoolean(t);
+}
+
+bool ValueConversionTraits<bool>::CanConvert(const Value* value) {
+ bool t;
+ return SetFromValue(value, &t);
+}
+
+Value* ValueConversionTraits<std::string>::CreateValueFrom(
+ const std::string& t) {
+ return Value::CreateStringValue(t);
+}
+
+bool ValueConversionTraits<std::string>::SetFromValue(
+ const Value* value, std::string* t) {
+ return value->GetAsString(t);
+}
+
+bool ValueConversionTraits<std::string>::CanConvert(const Value* value) {
+ std::string t;
+ return SetFromValue(value, &t);
+}
+
+Value* ValueConversionTraits<Value*>::CreateValueFrom(const Value* t) {
+ return t->DeepCopy();
+}
+
+bool ValueConversionTraits<Value*>::SetFromValue(
+ const Value* value, Value** t) {
+ *t = value->DeepCopy();
+ return true;
+}
+
+bool ValueConversionTraits<Value*>::CanConvert(const Value* value) {
+ return true;
+}
+
+Value* ValueConversionTraits<ListValue*>::CreateValueFrom(const ListValue* t) {
+ return t->DeepCopy();
+}
+
+bool ValueConversionTraits<ListValue*>::SetFromValue(const Value* value,
+ ListValue** t) {
+ if (!value->IsType(Value::TYPE_LIST))
+ return false;
+ *t = static_cast<const ListValue*>(value)->DeepCopy();
+ return true;
+}
+
+bool ValueConversionTraits<ListValue*>::CanConvert(const Value* value) {
+ return value->IsType(Value::TYPE_LIST);
+}
+
+Value* ValueConversionTraits<DictionaryValue*>::CreateValueFrom(
+ const DictionaryValue* t) {
+ return t->DeepCopy();
+}
+
+bool ValueConversionTraits<DictionaryValue*>::SetFromValue(
+ const Value* value, DictionaryValue** t) {
+ if (!value->IsType(Value::TYPE_DICTIONARY))
+ return false;
+ *t = static_cast<const DictionaryValue*>(value)->DeepCopy();
+ return true;
+}
+
+bool ValueConversionTraits<DictionaryValue*>::CanConvert(const Value* value) {
+ return value->IsType(Value::TYPE_DICTIONARY);
+}
« no previous file with comments | « chrome/test/automation/value_conversion_traits.h ('k') | chrome/test/automation/value_conversion_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698