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

Unified Diff: chrome/common/json_schema_validator.cc

Issue 6901084: Use new APIs in base/values.h: Value::GetAsNumber and DictionaryValue::GetNumber. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, 2010->2011 Created 9 years, 8 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/common/extensions/extension.cc ('k') | chrome/test/webdriver/cookie.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/json_schema_validator.cc
diff --git a/chrome/common/json_schema_validator.cc b/chrome/common/json_schema_validator.cc
index 7da218f825ed68519ccdab7a44c3eb4426d371b3..0662fcf553482ba826549204269ab28932d30071 100644
--- a/chrome/common/json_schema_validator.cc
+++ b/chrome/common/json_schema_validator.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.
@@ -16,30 +16,9 @@ namespace {
double GetNumberValue(Value* value) {
double result = 0;
- if (value->GetAsDouble(&result))
- return result;
-
- int int_result = 0;
- if (value->GetAsInteger(&int_result)) {
- return int_result;
- }
-
- CHECK(false) << "Unexpected value type: " << value->GetType();
- return 0;
-}
-
-bool GetNumberFromDictionary(DictionaryValue* value, const std::string& key,
- double* number) {
- if (value->GetDouble(key, number))
- return true;
-
- int int_value = 0;
- if (value->GetInteger(key, &int_value)) {
- *number = int_value;
- return true;
- }
-
- return false;
+ CHECK(value->GetAsDouble(&result))
+ << "Unexpected value type: " << value->GetType();
+ return result;
}
} // namespace
@@ -459,14 +438,14 @@ void JSONSchemaValidator::ValidateNumber(Value* instance,
// but isnan and isinf aren't defined on Windows.
double minimum = 0;
- if (GetNumberFromDictionary(schema, "minimum", &minimum)) {
+ if (schema->GetDouble("minimum", &minimum)) {
if (value < minimum)
errors_.push_back(Error(path, FormatErrorMessage(
kNumberMinimum, base::DoubleToString(minimum))));
}
double maximum = 0;
- if (GetNumberFromDictionary(schema, "maximum", &maximum)) {
+ if (schema->GetDouble("maximum", &maximum)) {
if (value > maximum)
errors_.push_back(Error(path, FormatErrorMessage(
kNumberMaximum, base::DoubleToString(maximum))));
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/test/webdriver/cookie.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698