diff options
-rw-r--r-- | base/json/json_parser.cc | 5 | ||||
-rw-r--r-- | base/json/json_parser.h | 2 | ||||
-rw-r--r-- | base/json/json_reader.cc | 6 | ||||
-rw-r--r-- | base/json/json_reader.h | 7 | ||||
-rw-r--r-- | chrome/browser/plugin_finder.cc | 2 | ||||
-rw-r--r-- | chrome/common/extensions/api/extension_api.cc | 2 | ||||
-rw-r--r-- | chrome/common/web_apps.cc | 2 | ||||
-rw-r--r-- | net/base/crl_set.cc | 2 |
8 files changed, 15 insertions, 13 deletions
diff --git a/base/json/json_parser.cc b/base/json/json_parser.cc index 0fd5202..738da47 100644 --- a/base/json/json_parser.cc +++ b/base/json/json_parser.cc @@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/string_number_conversions.h" +#include "base/string_piece.h" #include "base/string_util.h" #include "base/stringprintf.h" #include "base/third_party/icu/icu_utf.h" @@ -204,7 +205,7 @@ JSONParser::JSONParser(int options) JSONParser::~JSONParser() { } -Value* JSONParser::Parse(const std::string& input) { +Value* JSONParser::Parse(const StringPiece& input) { // TODO(rsesek): Windows has problems with StringPiece/hidden roots. Fix // <http://crbug.com/126107> when my Windows box arrives. #if defined(OS_WIN) @@ -216,7 +217,7 @@ Value* JSONParser::Parse(const std::string& input) { // be used, so do not bother copying the input because StringPiece will not // be used anywhere. if (!(options_ & JSON_DETACHABLE_CHILDREN)) { - input_copy = input; + input_copy = input.as_string(); start_pos_ = input_copy.data(); } else { start_pos_ = input.data(); diff --git a/base/json/json_parser.h b/base/json/json_parser.h index 901e679..56e49a2 100644 --- a/base/json/json_parser.h +++ b/base/json/json_parser.h @@ -66,7 +66,7 @@ class BASE_EXPORT_PRIVATE JSONParser { // Parses the input string according to the set options and returns the // result as a Value owned by the caller. - Value* Parse(const std::string& input); + Value* Parse(const StringPiece& input); // Returns the error code. JSONReader::JsonParseError error_code() const; diff --git a/base/json/json_reader.cc b/base/json/json_reader.cc index fb1459b..593273e 100644 --- a/base/json/json_reader.cc +++ b/base/json/json_reader.cc @@ -38,20 +38,20 @@ JSONReader::~JSONReader() { } // static -Value* JSONReader::Read(const std::string& json) { +Value* JSONReader::Read(const StringPiece& json) { internal::JSONParser parser(JSON_PARSE_RFC); return parser.Parse(json); } // static -Value* JSONReader::Read(const std::string& json, +Value* JSONReader::Read(const StringPiece& json, int options) { internal::JSONParser parser(options); return parser.Parse(json); } // static -Value* JSONReader::ReadAndReturnError(const std::string& json, +Value* JSONReader::ReadAndReturnError(const StringPiece& json, int options, int* error_code_out, std::string* error_msg_out) { diff --git a/base/json/json_reader.h b/base/json/json_reader.h index e081175..a11102f 100644 --- a/base/json/json_reader.h +++ b/base/json/json_reader.h @@ -33,6 +33,7 @@ #include "base/base_export.h" #include "base/basictypes.h" +#include "base/string_piece.h" #include "base/memory/scoped_ptr.h" namespace base { @@ -95,18 +96,18 @@ class BASE_EXPORT JSONReader { // Reads and parses |json|, returning a Value. The caller owns the returned // instance. If |json| is not a properly formed JSON string, returns NULL. - static Value* Read(const std::string& json); + static Value* Read(const StringPiece& json); // Reads and parses |json|, returning a Value owned by the caller. The // parser respects the given |options|. If the input is not properly formed, // returns NULL. - static Value* Read(const std::string& json, int options); + static Value* Read(const StringPiece& json, int options); // Reads and parses |json| like Read(). |error_code_out| and |error_msg_out| // are optional. If specified and NULL is returned, they will be populated // an error code and a formatted error message (including error location if // appropriate). Otherwise, they will be unmodified. - static Value* ReadAndReturnError(const std::string& json, + static Value* ReadAndReturnError(const StringPiece& json, int options, // JSONParserOptions int* error_code_out, std::string* error_msg_out); diff --git a/chrome/browser/plugin_finder.cc b/chrome/browser/plugin_finder.cc index d91d1e5..ad8301f 100644 --- a/chrome/browser/plugin_finder.cc +++ b/chrome/browser/plugin_finder.cc @@ -48,7 +48,7 @@ DictionaryValue* PluginFinder::LoadPluginList() { IDR_PLUGIN_DB_JSON, ui::SCALE_FACTOR_NONE)); std::string error_str; scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError( - json_resource.as_string(), + json_resource, base::JSON_PARSE_RFC, NULL, &error_str)); diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index 70ff413..47cdb95 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -71,7 +71,7 @@ scoped_ptr<ListValue> LoadSchemaList(const std::string& name, std::string error_message; scoped_ptr<Value> result( base::JSONReader::ReadAndReturnError( - schema.as_string(), + schema, base::JSON_PARSE_RFC | base::JSON_DETACHABLE_CHILDREN, // options NULL, // error code &error_message)); diff --git a/chrome/common/web_apps.cc b/chrome/common/web_apps.cc index 1564754..8a2cdcc 100644 --- a/chrome/common/web_apps.cc +++ b/chrome/common/web_apps.cc @@ -218,7 +218,7 @@ bool ParseWebAppFromDefinitionFile(Value* definition_value, base::JSONReader::ReadAndReturnError( ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_WEB_APP_SCHEMA, - ui::SCALE_FACTOR_NONE).as_string(), + ui::SCALE_FACTOR_NONE), base::JSON_PARSE_RFC, // options &error_code, &error_message)); diff --git a/net/base/crl_set.cc b/net/base/crl_set.cc index 2e424e5..1a8bdf1 100644 --- a/net/base/crl_set.cc +++ b/net/base/crl_set.cc @@ -138,7 +138,7 @@ static base::DictionaryValue* ReadHeader(base::StringPiece* data) { data->remove_prefix(header_len); scoped_ptr<Value> header(base::JSONReader::Read( - header_bytes.as_string(), base::JSON_ALLOW_TRAILING_COMMAS)); + header_bytes, base::JSON_ALLOW_TRAILING_COMMAS)); if (header.get() == NULL) return NULL; |