Commit 3f588aa9 authored by Sky Malice's avatar Sky Malice Committed by Commit Bot

Replaced ExtractIntegerValueAtIndex with ListValue::GetInteger.

ExtractIntegerValueAtIndex's main piece of functionality was that it
would first try to read the number as a string, and if the failed, it
would fallback to reading it as a double/integer. However, the string
read is not needed, as the javascript side always passes a number.

Bug: 
Change-Id: I189e96865ec834bb8753f0d9f418cb3cd9925d17
Reviewed-on: https://chromium-review.googlesource.com/569848
Commit-Queue: Sky Malice <skym@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488321}
parent 86245656
......@@ -6,6 +6,8 @@
#include <stddef.h>
#include <set>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/i18n/rtl.h"
......@@ -16,7 +18,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/favicon/large_icon_service_factory.h"
#include "chrome/browser/profiles/profile.h"
......@@ -265,19 +266,6 @@ void BrowsingHistoryHandler::RegisterMessages() {
base::Unretained(this)));
}
bool BrowsingHistoryHandler::ExtractIntegerValueAtIndex(
const base::ListValue* value,
int index,
int* out_int) {
double double_value;
if (value->GetDouble(index, &double_value)) {
*out_int = static_cast<int>(double_value);
return true;
}
NOTREACHED();
return false;
}
void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) {
history::QueryOptions options;
......@@ -297,7 +285,7 @@ void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) {
if (end_time)
options.end_time = base::Time::FromJsTime(end_time);
if (!ExtractIntegerValueAtIndex(args, 2, &options.max_count)) {
if (!args->GetInteger(2, &options.max_count)) {
NOTREACHED() << "Failed to convert argument 2.";
return;
}
......
......@@ -8,13 +8,11 @@
#include <stdint.h>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/time/clock.h"
#include "base/values.h"
#include "chrome/browser/history/browsing_history_service_handler.h"
......@@ -63,9 +61,6 @@ class BrowsingHistoryHandler :
ObservingWebHistoryDeletions);
FRIEND_TEST_ALL_PREFIXES(BrowsingHistoryHandlerTest, MdTruncatesTitles);
bool ExtractIntegerValueAtIndex(
const base::ListValue* value, int index, int* out_int);
// The clock used to vend times.
std::unique_ptr<base::Clock> clock_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment