0

Convert JsonWriter::Write to taking a const ref for the in-param

Clearer API; flushes out a lot of unnecessary heap allocations.

depends on https://codereview.chromium.org/1129083003/

BUG=none

Review URL: https://codereview.chromium.org/1131113004

Cr-Commit-Position: refs/heads/master@{#330255}
This commit is contained in:
estade
2015-05-15 18:02:34 -07:00
committed by Commit bot
parent f39e5aff5a
commit 8d04646294
213 changed files with 594 additions and 629 deletions
android_webview/browser
base
cc
chrome
browser
caps
chromeos
component_updater
content_settings
devtools
extensions
local_discovery
policy
profile_resetter
safe_browsing
safe_json_parser_browsertest.cc
speech
spellchecker
supervised_user
sync
task_profiler
ui
renderer
service
test
chromeos
cloud_print
components
content
dbus
extensions
google_apis
gpu/tools/compositor_model_bench
ios/web
ipc
jingle/glue
media
net
pdf
printing
remoting
sync
ui
compositor
events

@ -35,7 +35,7 @@ std::string GetViewDescription(WebContents* web_contents) {
description.SetInteger("height", screen_rect.height());
}
std::string json;
base::JSONWriter::Write(&description, &json);
base::JSONWriter::Write(description, &json);
return json;
}

@ -37,7 +37,7 @@ bool JSONStringValueSerializer::SerializeInternal(const Value& root,
if (pretty_print_)
options |= base::JSONWriter::OPTIONS_PRETTY_PRINT;
return base::JSONWriter::WriteWithOptions(&root, options, json_string_);
return base::JSONWriter::WriteWithOptions(root, options, json_string_);
}
JSONStringValueDeserializer::JSONStringValueDeserializer(

@ -302,7 +302,7 @@ TEST(JSONValueSerializerTest, StringEscape) {
std::string output_js;
DictionaryValue valueRoot;
valueRoot.SetString("all_chars", all_chars);
JSONWriter::Write(&valueRoot, &output_js);
JSONWriter::Write(valueRoot, &output_js);
ASSERT_EQ(expected_output, output_js);
// Test JSONValueSerializer interface (uses JSONWriter).

@ -21,12 +21,13 @@ const char kPrettyPrintLineEnding[] = "\n";
#endif
// static
bool JSONWriter::Write(const Value* const node, std::string* json) {
bool JSONWriter::Write(const Value& node, std::string* json) {
return WriteWithOptions(node, 0, json);
}
// static
bool JSONWriter::WriteWithOptions(const Value* const node, int options,
bool JSONWriter::WriteWithOptions(const Value& node,
int options,
std::string* json) {
json->clear();
// Is there a better way to estimate the size of the output?
@ -50,8 +51,8 @@ JSONWriter::JSONWriter(int options, std::string* json)
DCHECK(json);
}
bool JSONWriter::BuildJSONString(const Value* const node, size_t depth) {
switch (node->GetType()) {
bool JSONWriter::BuildJSONString(const Value& node, size_t depth) {
switch (node.GetType()) {
case Value::TYPE_NULL: {
json_string_->append("null");
return true;
@ -59,7 +60,7 @@ bool JSONWriter::BuildJSONString(const Value* const node, size_t depth) {
case Value::TYPE_BOOLEAN: {
bool value;
bool result = node->GetAsBoolean(&value);
bool result = node.GetAsBoolean(&value);
DCHECK(result);
json_string_->append(value ? "true" : "false");
return result;
@ -67,7 +68,7 @@ bool JSONWriter::BuildJSONString(const Value* const node, size_t depth) {
case Value::TYPE_INTEGER: {
int value;
bool result = node->GetAsInteger(&value);
bool result = node.GetAsInteger(&value);
DCHECK(result);
json_string_->append(IntToString(value));
return result;
@ -75,7 +76,7 @@ bool JSONWriter::BuildJSONString(const Value* const node, size_t depth) {
case Value::TYPE_DOUBLE: {
double value;
bool result = node->GetAsDouble(&value);
bool result = node.GetAsDouble(&value);
DCHECK(result);
if (omit_double_type_preservation_ &&
value <= kint64max &&
@ -107,7 +108,7 @@ bool JSONWriter::BuildJSONString(const Value* const node, size_t depth) {
case Value::TYPE_STRING: {
std::string value;
bool result = node->GetAsString(&value);
bool result = node.GetAsString(&value);
DCHECK(result);
EscapeJSONString(value, true, json_string_);
return result;
@ -120,7 +121,7 @@ bool JSONWriter::BuildJSONString(const Value* const node, size_t depth) {
const ListValue* list = NULL;
bool first_value_has_been_output = false;
bool result = node->GetAsList(&list);
bool result = node.GetAsList(&list);
DCHECK(result);
for (ListValue::const_iterator it = list->begin(); it != list->end();
++it) {
@ -134,7 +135,7 @@ bool JSONWriter::BuildJSONString(const Value* const node, size_t depth) {
json_string_->push_back(' ');
}
if (!BuildJSONString(value, depth))
if (!BuildJSONString(*value, depth))
result = false;
first_value_has_been_output = true;
@ -153,7 +154,7 @@ bool JSONWriter::BuildJSONString(const Value* const node, size_t depth) {
const DictionaryValue* dict = NULL;
bool first_value_has_been_output = false;
bool result = node->GetAsDictionary(&dict);
bool result = node.GetAsDictionary(&dict);
DCHECK(result);
for (DictionaryValue::Iterator itr(*dict); !itr.IsAtEnd();
itr.Advance()) {
@ -176,7 +177,7 @@ bool JSONWriter::BuildJSONString(const Value* const node, size_t depth) {
if (pretty_print_)
json_string_->push_back(' ');
if (!BuildJSONString(&itr.value(), depth + 1U))
if (!BuildJSONString(itr.value(), depth + 1U))
result = false;
first_value_has_been_output = true;

@ -38,11 +38,12 @@ class BASE_EXPORT JSONWriter {
// TODO(tc): Should we generate json if it would be invalid json (e.g.,
// |node| is not a DictionaryValue/ListValue or if there are inf/-inf float
// values)? Return true on success and false on failure.
static bool Write(const Value* const node, std::string* json);
static bool Write(const Value& node, std::string* json);
// Same as above but with |options| which is a bunch of JSONWriter::Options
// bitwise ORed together. Return true on success and false on failure.
static bool WriteWithOptions(const Value* const node, int options,
static bool WriteWithOptions(const Value& node,
int options,
std::string* json);
private:
@ -50,7 +51,7 @@ class BASE_EXPORT JSONWriter {
// Called recursively to build the JSON string. When completed,
// |json_string_| will contain the JSON.
bool BuildJSONString(const Value* const node, size_t depth);
bool BuildJSONString(const Value& node, size_t depth);
// Adds space to json_string_ for the indent level.
void IndentLine(size_t depth);

@ -12,47 +12,39 @@ TEST(JSONWriterTest, BasicTypes) {
std::string output_js;
// Test null.
EXPECT_TRUE(JSONWriter::Write(Value::CreateNullValue().get(), &output_js));
EXPECT_TRUE(JSONWriter::Write(*Value::CreateNullValue(), &output_js));
EXPECT_EQ("null", output_js);
// Test empty dict.
DictionaryValue dict;
EXPECT_TRUE(JSONWriter::Write(&dict, &output_js));
EXPECT_TRUE(JSONWriter::Write(DictionaryValue(), &output_js));
EXPECT_EQ("{}", output_js);
// Test empty list.
ListValue list;
EXPECT_TRUE(JSONWriter::Write(&list, &output_js));
EXPECT_TRUE(JSONWriter::Write(ListValue(), &output_js));
EXPECT_EQ("[]", output_js);
// Test integer values.
FundamentalValue int_value(42);
EXPECT_TRUE(JSONWriter::Write(&int_value, &output_js));
EXPECT_TRUE(JSONWriter::Write(FundamentalValue(42), &output_js));
EXPECT_EQ("42", output_js);
// Test boolean values.
FundamentalValue bool_value(true);
EXPECT_TRUE(JSONWriter::Write(&bool_value, &output_js));
EXPECT_TRUE(JSONWriter::Write(FundamentalValue(true), &output_js));
EXPECT_EQ("true", output_js);
// Test Real values should always have a decimal or an 'e'.
FundamentalValue double_value(1.0);
EXPECT_TRUE(JSONWriter::Write(&double_value, &output_js));
EXPECT_TRUE(JSONWriter::Write(FundamentalValue(1.0), &output_js));
EXPECT_EQ("1.0", output_js);
// Test Real values in the the range (-1, 1) must have leading zeros
FundamentalValue double_value2(0.2);
EXPECT_TRUE(JSONWriter::Write(&double_value2, &output_js));
EXPECT_TRUE(JSONWriter::Write(FundamentalValue(0.2), &output_js));
EXPECT_EQ("0.2", output_js);
// Test Real values in the the range (-1, 1) must have leading zeros
FundamentalValue double_value3(-0.8);
EXPECT_TRUE(JSONWriter::Write(&double_value3, &output_js));
EXPECT_TRUE(JSONWriter::Write(FundamentalValue(-0.8), &output_js));
EXPECT_EQ("-0.8", output_js);
// Test String values.
StringValue string_value("foo");
EXPECT_TRUE(JSONWriter::Write(&string_value, &output_js));
EXPECT_TRUE(JSONWriter::Write(StringValue("foo"), &output_js));
EXPECT_EQ("\"foo\"", output_js);
}
@ -71,11 +63,10 @@ TEST(JSONWriterTest, NestedTypes) {
root_dict.Set("list", list.Pass());
// Test the pretty-printer.
EXPECT_TRUE(JSONWriter::Write(&root_dict, &output_js));
EXPECT_TRUE(JSONWriter::Write(root_dict, &output_js));
EXPECT_EQ("{\"list\":[{\"inner int\":10},[],true]}", output_js);
EXPECT_TRUE(JSONWriter::WriteWithOptions(&root_dict,
JSONWriter::OPTIONS_PRETTY_PRINT,
&output_js));
EXPECT_TRUE(JSONWriter::WriteWithOptions(
root_dict, JSONWriter::OPTIONS_PRETTY_PRINT, &output_js));
// The pretty-printer uses a different newline style on Windows than on
// other platforms.
@ -102,13 +93,13 @@ TEST(JSONWriterTest, KeysWithPeriods) {
scoped_ptr<DictionaryValue> period_dict2(new DictionaryValue());
period_dict2->SetIntegerWithoutPathExpansion("g.h.i.j", 1);
period_dict.SetWithoutPathExpansion("d.e.f", period_dict2.Pass());
EXPECT_TRUE(JSONWriter::Write(&period_dict, &output_js));
EXPECT_TRUE(JSONWriter::Write(period_dict, &output_js));
EXPECT_EQ("{\"a.b\":3,\"c\":2,\"d.e.f\":{\"g.h.i.j\":1}}", output_js);
DictionaryValue period_dict3;
period_dict3.SetInteger("a.b", 2);
period_dict3.SetIntegerWithoutPathExpansion("a.b", 1);
EXPECT_TRUE(JSONWriter::Write(&period_dict3, &output_js));
EXPECT_TRUE(JSONWriter::Write(period_dict3, &output_js));
EXPECT_EQ("{\"a\":{\"b\":2},\"a.b\":1}", output_js);
}
@ -118,9 +109,9 @@ TEST(JSONWriterTest, BinaryValues) {
// Binary values should return errors unless suppressed via the
// OPTIONS_OMIT_BINARY_VALUES flag.
scoped_ptr<Value> root(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
EXPECT_FALSE(JSONWriter::Write(root.get(), &output_js));
EXPECT_FALSE(JSONWriter::Write(*root, &output_js));
EXPECT_TRUE(JSONWriter::WriteWithOptions(
root.get(), JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js));
*root, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js));
EXPECT_TRUE(output_js.empty());
ListValue binary_list;
@ -129,9 +120,9 @@ TEST(JSONWriterTest, BinaryValues) {
binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
binary_list.Append(make_scoped_ptr(new FundamentalValue(2)));
binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
EXPECT_FALSE(JSONWriter::Write(&binary_list, &output_js));
EXPECT_FALSE(JSONWriter::Write(binary_list, &output_js));
EXPECT_TRUE(JSONWriter::WriteWithOptions(
&binary_list, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js));
binary_list, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js));
EXPECT_EQ("[5,2]", output_js);
DictionaryValue binary_dict;
@ -143,9 +134,9 @@ TEST(JSONWriterTest, BinaryValues) {
binary_dict.SetInteger("d", 2);
binary_dict.Set(
"e", make_scoped_ptr(BinaryValue::CreateWithCopiedBuffer("asdf", 4)));
EXPECT_FALSE(JSONWriter::Write(&binary_dict, &output_js));
EXPECT_FALSE(JSONWriter::Write(binary_dict, &output_js));
EXPECT_TRUE(JSONWriter::WriteWithOptions(
&binary_dict, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js));
binary_dict, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js));
EXPECT_EQ("{\"b\":5,\"d\":2}", output_js);
}
@ -155,8 +146,7 @@ TEST(JSONWriterTest, DoublesAsInts) {
// Test allowing a double with no fractional part to be written as an integer.
FundamentalValue double_value(1e10);
EXPECT_TRUE(JSONWriter::WriteWithOptions(
&double_value,
JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION,
double_value, JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION,
&output_js));
EXPECT_EQ("10000000000", output_js);
}

@ -108,7 +108,7 @@ ListValue* TracedValue::GetCurrentArray() {
void TracedValue::AppendAsTraceFormat(std::string* out) const {
std::string tmp;
JSONWriter::Write(stack_.front(), &tmp);
JSONWriter::Write(*stack_.front(), &tmp);
*out += tmp;
DCHECK_EQ(1u, stack_.size()) << tmp;
}

@ -125,7 +125,7 @@ bool TraceEventSystemStatsMonitor::IsTimerRunningForTest() const {
void AppendSystemProfileAsTraceFormat(const SystemMetrics& system_metrics,
std::string* output) {
std::string tmp;
base::JSONWriter::Write(system_metrics.ToValue().get(), &tmp);
base::JSONWriter::Write(*system_metrics.ToValue(), &tmp);
*output += tmp;
}

@ -1168,9 +1168,7 @@ ValueDeserializer::~ValueDeserializer() {
std::ostream& operator<<(std::ostream& out, const Value& value) {
std::string json;
JSONWriter::WriteWithOptions(&value,
JSONWriter::OPTIONS_PRETTY_PRINT,
&json);
JSONWriter::WriteWithOptions(value, JSONWriter::OPTIONS_PRETTY_PRINT, &json);
return out << json;
}

@ -40,18 +40,16 @@ void TracedPicture::AppendPictureAlias(std::string* out) const {
scoped_ptr<base::DictionaryValue> alias(new base::DictionaryValue());
alias->SetString("id_ref", base::StringPrintf("%p", picture_.get()));
scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
res->Set("alias", alias.release());
base::DictionaryValue res;
res.Set("alias", alias.release());
std::string tmp;
base::JSONWriter::Write(res.get(), &tmp);
base::JSONWriter::Write(res, &tmp);
out->append(tmp);
}
void TracedPicture::AppendPicture(std::string* out) const {
scoped_ptr<base::Value> value = picture_->AsValue();
std::string tmp;
base::JSONWriter::Write(value.get(), &tmp);
base::JSONWriter::Write(*picture_->AsValue(), &tmp);
out->append(tmp);
}

@ -3124,7 +3124,7 @@ std::string LayerTreeHostImpl::LayerTreeAsJson() const {
if (active_tree_->root_layer()) {
scoped_ptr<base::Value> json(active_tree_->root_layer()->LayerTreeAsJson());
base::JSONWriter::WriteWithOptions(
json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &str);
*json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str);
}
return str;
}

@ -90,7 +90,7 @@ class TaskManagerDataDumper :
std::string json;
auto options = base::JSONWriter::OPTIONS_PRETTY_PRINT;
if (!base::JSONWriter::WriteWithOptions(&dict, options, &json))
if (!base::JSONWriter::WriteWithOptions(dict, options, &json))
return;
file_.WriteAtCurrentPos(json.c_str(), json.size());

@ -76,7 +76,7 @@ bool IsValidKioskAppManifest(const extensions::Manifest& manifest) {
return false;
}
std::string ValueToString(const base::Value* value) {
std::string ValueToString(const base::Value& value) {
std::string json;
base::JSONWriter::Write(value, &json);
return json;
@ -602,7 +602,7 @@ void KioskAppData::OnWebstoreResponseParseSuccess(
icon_url_string);
if (!icon_url.is_valid()) {
LOG(ERROR) << "Webstore response error (icon url): "
<< ValueToString(webstore_data.get());
<< ValueToString(*webstore_data);
OnWebstoreResponseParseFailure(kInvalidWebstoreResponseError);
return;
}
@ -626,7 +626,7 @@ bool KioskAppData::CheckResponseKeyValue(const base::DictionaryValue* response,
std::string* value) {
if (!response->GetString(key, value)) {
LOG(ERROR) << "Webstore response error (" << key
<< "): " << ValueToString(response);
<< "): " << ValueToString(*response);
OnWebstoreResponseParseFailure(kInvalidWebstoreResponseError);
return false;
}

@ -76,7 +76,7 @@ void BluetoothPairingDialog::GetDialogSize(gfx::Size* size) const {
std::string BluetoothPairingDialog::GetDialogArgs() const {
std::string data;
base::JSONWriter::Write(&device_data_, &data);
base::JSONWriter::Write(device_data_, &data);
return data;
}

@ -152,7 +152,7 @@ std::string BootTimesRecorder::Stats::SerializeToString() const {
dictionary.SetString(kDisk, disk_);
std::string result;
if (!base::JSONWriter::Write(&dictionary, &result)) {
if (!base::JSONWriter::Write(dictionary, &result)) {
LOG(WARNING) << "BootTimesRecorder::Stats::SerializeToString(): failed.";
return std::string();
}

@ -158,7 +158,7 @@ class AccessibilityFeaturesApiTest : public ExtensionApiTest,
disabled_list->AppendString(disabled_features[i]);
test_arg.Set(kDisabledFeaturesKey, disabled_list.release());
return base::JSONWriter::Write(&test_arg, result);
return base::JSONWriter::Write(test_arg, result);
}
};

@ -681,13 +681,15 @@ void FileManagerBrowserTestBase::OnMessage(const std::string& name,
if (name == "getRootPaths") {
// Pass the root paths.
const scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
res->SetString("downloads",
"/" + util::GetDownloadsMountPointName(profile()));
res->SetString("drive",
"/" + drive::util::GetDriveMountPointPath(profile()
).BaseName().AsUTF8Unsafe() + "/root");
base::JSONWriter::Write(res.get(), output);
base::DictionaryValue res;
res.SetString("downloads",
"/" + util::GetDownloadsMountPointName(profile()));
res.SetString("drive", "/" +
drive::util::GetDriveMountPointPath(profile())
.BaseName()
.AsUTF8Unsafe() +
"/root");
base::JSONWriter::Write(res, output);
return;
}
@ -707,10 +709,10 @@ void FileManagerBrowserTestBase::OnMessage(const std::string& name,
if (*origin.rbegin() == '/')
origin.resize(origin.length() - 1);
const scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
res->SetString("url", url.spec());
res->SetString("origin", origin);
base::JSONWriter::Write(res.get(), output);
base::DictionaryValue res;
res.SetString("url", url.spec());
res.SetString("origin", origin);
base::JSONWriter::Write(res, output);
return;
}

@ -111,7 +111,7 @@ GURL GetFileManagerMainPageUrlWithParams(
!file_types || !file_types->support_drive);
std::string json_args;
base::JSONWriter::Write(&arg_value, &json_args);
base::JSONWriter::Write(arg_value, &json_args);
std::string url = GetFileManagerMainPageUrl().spec() + '?' +
net::EscapeUrlEncodedData(json_args,

@ -23,9 +23,8 @@ std::string PrettyPrintEscapedJson(const std::string& query) {
query, net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS);
scoped_ptr<base::Value> value(base::JSONReader::Read(json));
std::string pretty_json;
base::JSONWriter::WriteWithOptions(value.get(),
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&pretty_json);
base::JSONWriter::WriteWithOptions(
*value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &pretty_json);
return pretty_json;
}

@ -656,10 +656,12 @@ class UserImageManagerPolicyTest : public UserImageManagerTest,
ADD_FAILURE();
}
std::string policy;
base::JSONWriter::Write(policy::test::ConstructExternalDataReference(
embedded_test_server()->GetURL(std::string("/") + relative_path).spec(),
image_data).get(),
&policy);
base::JSONWriter::Write(*policy::test::ConstructExternalDataReference(
embedded_test_server()
->GetURL(std::string("/") + relative_path)
.spec(),
image_data),
&policy);
return policy;
}

@ -220,10 +220,12 @@ class WallpaperManagerPolicyTest
ADD_FAILURE();
}
std::string policy;
base::JSONWriter::Write(policy::test::ConstructExternalDataReference(
embedded_test_server()->GetURL(std::string("/") + relative_path).spec(),
image_data).get(),
&policy);
base::JSONWriter::Write(*policy::test::ConstructExternalDataReference(
embedded_test_server()
->GetURL(std::string("/") + relative_path)
.spec(),
image_data),
&policy);
return policy;
}

@ -228,7 +228,7 @@ void ImportNetworksForUser(const user_manager::User* user,
base::DictionaryValue ui_data_dict;
ui_data->FillDictionary(&ui_data_dict);
std::string ui_data_json;
base::JSONWriter::Write(&ui_data_dict, &ui_data_json);
base::JSONWriter::Write(ui_data_dict, &ui_data_json);
shill_dict->SetStringWithoutPathExpansion(shill::kUIDataProperty,
ui_data_json);

@ -112,7 +112,7 @@ void SetProxyConfigForNetwork(const ProxyConfigDictionary& proxy_config,
network_handler::ErrorCallback()));
} else {
std::string proxy_config_str;
base::JSONWriter::Write(&proxy_config.GetDictionary(), &proxy_config_str);
base::JSONWriter::Write(proxy_config.GetDictionary(), &proxy_config_str);
shill_service_client->SetProperty(
dbus::ObjectPath(network.path()),
shill::kProxyConfigProperty,

@ -82,8 +82,7 @@ void ConstructAvatarPolicy(const std::string& file_name,
test_data_dir.Append("chromeos").Append(file_name),
policy_data));
base::JSONWriter::Write(
test::ConstructExternalDataReference(url, *policy_data).get(),
policy);
*test::ConstructExternalDataReference(url, *policy_data), policy);
}
} // namespace

@ -298,9 +298,8 @@ base::Value* NetworkConfigurationPolicyHandler::SanitizeNetworkConfig(
*toplevel_dict,
kPlaceholder);
base::JSONWriter::WriteWithOptions(toplevel_dict.get(),
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&json_string);
base::JSONWriter::WriteWithOptions(
*toplevel_dict, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_string);
return new base::StringValue(json_string);
}

@ -1279,7 +1279,7 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExternalData) {
scoped_ptr<base::DictionaryValue> metadata =
test::ConstructExternalDataReference(kExternalDataURL, kExternalData);
std::string policy;
base::JSONWriter::Write(metadata.get(), &policy);
base::JSONWriter::Write(*metadata, &policy);
device_local_account_policy_.payload().mutable_useravatarimage()->set_value(
policy);
UploadAndInstallDeviceLocalAccountPolicy();
@ -1362,10 +1362,13 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, UserAvatarImage) {
&image_data));
std::string policy;
base::JSONWriter::Write(test::ConstructExternalDataReference(
embedded_test_server()->GetURL(std::string("/") +
chromeos::test::kUserAvatarImage1RelativePath).spec(),
image_data).get(),
base::JSONWriter::Write(
*test::ConstructExternalDataReference(
embedded_test_server()
->GetURL(std::string("/") +
chromeos::test::kUserAvatarImage1RelativePath)
.spec(),
image_data),
&policy);
device_local_account_policy_.payload().mutable_useravatarimage()->set_value(
policy);

@ -54,10 +54,10 @@ std::string GetPolicy(scoped_ptr<base::DictionaryValue> mandatory,
root_dict.SetString("policy_user", account);
root_dict.SetInteger("current_key_index", 0);
std::string jsonPolicy;
std::string json_policy;
base::JSONWriter::WriteWithOptions(
&root_dict, base::JSONWriter::OPTIONS_PRETTY_PRINT, &jsonPolicy);
return jsonPolicy;
root_dict, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_policy);
return json_policy;
}
} // namespace

@ -81,8 +81,8 @@ class DeviceCommandScreenshotJob::Payload
DeviceCommandScreenshotJob::Payload::Payload(ResultCode result_code) {
base::DictionaryValue root_dict;
if (result_code != SUCCESS)
root_dict.Set(kResultFieldName, new base::FundamentalValue(result_code));
base::JSONWriter::Write(&root_dict, &payload_);
root_dict.SetInteger(kResultFieldName, result_code);
base::JSONWriter::Write(root_dict, &payload_);
}
scoped_ptr<std::string> DeviceCommandScreenshotJob::Payload::Serialize() {

@ -49,8 +49,8 @@ em::RemoteCommand GenerateScreenshotCommandProto(
command_proto.set_age_of_command(age_of_command.InMilliseconds());
std::string payload;
base::DictionaryValue root_dict;
root_dict.Set(kUploadUrlFieldName, new base::StringValue(upload_url));
base::JSONWriter::Write(&root_dict, &payload);
root_dict.SetString(kUploadUrlFieldName, upload_url);
base::JSONWriter::Write(root_dict, &payload);
command_proto.set_payload(payload);
return command_proto;
}
@ -246,7 +246,7 @@ std::string DeviceCommandScreenshotTest::CreatePayloadFromResultCode(
base::DictionaryValue root_dict;
if (result_code != DeviceCommandScreenshotJob::SUCCESS)
root_dict.Set(kResultFieldName, new base::FundamentalValue(result_code));
base::JSONWriter::Write(&root_dict, &payload);
base::JSONWriter::Write(root_dict, &payload);
return payload;
}

@ -333,7 +333,7 @@ class ProxyConfigServiceImplTest : public testing::Test {
void SetUserConfigInShill(base::DictionaryValue* pref_proxy_config_dict) {
std::string proxy_config;
if (pref_proxy_config_dict)
base::JSONWriter::Write(pref_proxy_config_dict, &proxy_config);
base::JSONWriter::Write(*pref_proxy_config_dict, &proxy_config);
NetworkStateHandler* network_state_handler =
NetworkHandler::Get()->network_state_handler();

@ -51,7 +51,7 @@ std::string CrxIdToHashToCrxId(const std::string& kCrxId) {
return GetCrxComponentID(component);
}
std::string JsonToString(const base::DictionaryValue* dict) {
std::string JsonToString(const base::DictionaryValue& dict) {
std::string json;
base::JSONWriter::Write(dict, &json);
return json;
@ -310,8 +310,8 @@ TEST_F(SupervisedUserWhitelistInstallerTest, InstallNewWhitelist) {
ASSERT_TRUE(base::ReadFileToString(whitelist_path_, &whitelist_contents));
EXPECT_EQ(kWhitelistContents, whitelist_contents);
EXPECT_EQ(JsonToString(&pref_),
JsonToString(local_state_.GetDictionary(
EXPECT_EQ(JsonToString(pref_),
JsonToString(*local_state_.GetDictionary(
prefs::kRegisteredSupervisedUserWhitelists)));
}

@ -720,8 +720,8 @@ TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeAndPunycode) {
// Initialize the content map.
profile.GetHostContentSettingsMap();
const base::DictionaryValue* content_setting_prefs =
profile.GetPrefs()->GetDictionary(
const base::DictionaryValue& content_setting_prefs =
*profile.GetPrefs()->GetDictionary(
prefs::kContentSettingsImagesPatternPairs);
std::string prefs_as_json;
base::JSONWriter::Write(content_setting_prefs, &prefs_as_json);

@ -22,7 +22,7 @@ const char kCommandTimeoutMs[] = "20000";
SendCommandRequest::SendCommandRequest(const base::DictionaryValue* request,
Delegate* delegate)
: delegate_(delegate) {
base::JSONWriter::Write(request, &upload_data_);
base::JSONWriter::Write(*request, &upload_data_);
DCHECK(delegate_);
}

@ -37,7 +37,7 @@ std::string DevToolsProtocol::SerializeCommand(
command.Set(kParamsParam, params.release());
std::string json_command;
base::JSONWriter::Write(&command, &json_command);
base::JSONWriter::Write(command, &json_command);
return json_command;
}

@ -1016,13 +1016,13 @@ void DevToolsUIBindings::CallClientFunction(const std::string& function_name,
std::string javascript = function_name + "(";
if (arg1) {
std::string json;
base::JSONWriter::Write(arg1, &json);
base::JSONWriter::Write(*arg1, &json);
javascript.append(json);
if (arg2) {
base::JSONWriter::Write(arg2, &json);
base::JSONWriter::Write(*arg2, &json);
javascript.append(", ").append(json);
if (arg3) {
base::JSONWriter::Write(arg3, &json);
base::JSONWriter::Write(*arg3, &json);
javascript.append(", ").append(json);
}
}

@ -385,7 +385,7 @@ void ExtensionDevToolsClientHost::SendMessageToBackend(
}
std::string json_args;
base::JSONWriter::Write(&protocol_request, &json_args);
base::JSONWriter::Write(protocol_request, &json_args);
agent_host_->DispatchProtocolMessage(json_args);
}
@ -666,7 +666,7 @@ void DebuggerSendCommandFunction::SendResponseBody(
base::DictionaryValue* response) {
base::Value* error_body;
if (response->Get("error", &error_body)) {
base::JSONWriter::Write(error_body, &error_);
base::JSONWriter::Write(*error_body, &error_);
SendResponse(false);
return;
}

@ -146,15 +146,15 @@ class ExtensionInfoGeneratorUnitTest : public ExtensionServiceTestBase {
std::string actual_string;
for (base::DictionaryValue::Iterator field(*expected_output_data);
!field.IsAtEnd(); field.Advance()) {
const base::Value* expected_value = &field.value();
const base::Value& expected_value = field.value();
base::Value* actual_value = nullptr;
EXPECT_TRUE(actual_output_data->Get(field.key(), &actual_value)) <<
field.key() + " is missing" + paths_details;
if (!actual_value)
continue;
if (!actual_value->Equals(expected_value)) {
if (!actual_value->Equals(&expected_value)) {
base::JSONWriter::Write(expected_value, &expected_string);
base::JSONWriter::Write(actual_value, &actual_string);
base::JSONWriter::Write(*actual_value, &actual_string);
EXPECT_EQ(expected_string, actual_string) <<
field.key() << paths_details;
}

@ -1860,7 +1860,7 @@ void ExtensionDownloadsEventRouter::DispatchEvent(
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(arg);
std::string json_args;
base::JSONWriter::Write(args.get(), &json_args);
base::JSONWriter::Write(*args, &json_args);
scoped_ptr<Event> event(new Event(event_name, args.Pass()));
// The downloads system wants to share on-record events with off-record
// extension renderers even in incognito_split_mode because that's how

@ -164,7 +164,7 @@ class MediaGalleriesPlatformAppBrowserTest : public PlatformAppBrowserTest {
const char* custom_arg = NULL;
std::string json_string;
if (!custom_arg_value.empty()) {
base::JSONWriter::Write(&custom_arg_value, &json_string);
base::JSONWriter::Write(custom_arg_value, &json_string);
custom_arg = json_string.c_str();
}

@ -100,7 +100,7 @@ void MessagePropertyProvider::GotChannelID(
return;
}
std::string jwk_str;
base::JSONWriter::Write(&jwk_value, &jwk_str);
base::JSONWriter::Write(jwk_value, &jwk_str);
original_task_runner->PostTask(FROM_HERE, base::Bind(reply, jwk_str));
}

@ -70,12 +70,12 @@ class EchoHost : public NativeMessageHost {
private:
void ProcessEcho(const base::DictionaryValue& request) {
scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue());
response->SetInteger("id", ++message_number_);
response->Set("echo", request.DeepCopy());
response->SetString("caller_url", kEchoHostOrigins[0]);
base::DictionaryValue response;
response.SetInteger("id", ++message_number_);
response.Set("echo", request.CreateDeepCopy());
response.SetString("caller_url", kEchoHostOrigins[0]);
std::string response_string;
base::JSONWriter::Write(response.get(), &response_string);
base::JSONWriter::Write(response, &response_string);
client_->PostMessageFromNativeHost(response_string);
}

@ -51,7 +51,7 @@ scoped_ptr<Permissions> PackPermissionSet(const PermissionSet* set) {
} else {
std::string name(i->name());
std::string json;
base::JSONWriter::Write(value.get(), &json);
base::JSONWriter::Write(*value, &json);
permissions->permissions->push_back(name + kDelimiter + json);
}
}

@ -174,12 +174,12 @@ class ExtensionSettingsApiTest : public ExtensionApiTest {
Namespace settings_namespace,
const std::string& action,
bool is_final_action) {
scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue());
message->SetString("namespace", ToString(settings_namespace));
message->SetString("action", action);
message->SetBoolean("isFinalAction", is_final_action);
base::DictionaryValue message;
message.SetString("namespace", ToString(settings_namespace));
message.SetString("action", action);
message.SetBoolean("isFinalAction", is_final_action);
std::string message_json;
base::JSONWriter::Write(message.get(), &message_json);
base::JSONWriter::Write(message, &message_json);
return message_json;
}

@ -45,9 +45,8 @@ const ValueStore::WriteOptions DEFAULTS = ValueStore::DEFAULTS;
// Gets the pretty-printed JSON for a value.
static std::string GetJson(const base::Value& value) {
std::string json;
base::JSONWriter::WriteWithOptions(&value,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&json);
base::JSONWriter::WriteWithOptions(
value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
return json;
}

@ -30,7 +30,7 @@ void PopulateExtensionSettingSpecifics(
specifics->set_key(key);
{
std::string value_as_json;
base::JSONWriter::Write(&value, &value_as_json);
base::JSONWriter::Write(value, &value_as_json);
specifics->set_value(value_as_json);
}
}

@ -94,7 +94,7 @@ class WebrtcAudioPrivateTest : public AudioWaitingExtensionTest {
base::ListValue parameters;
AppendTabIdToRequestInfo(&parameters, tab_id);
std::string parameter_string;
JSONWriter::Write(&parameters, &parameter_string);
JSONWriter::Write(parameters, &parameter_string);
scoped_refptr<WebrtcAudioPrivateGetActiveSinkFunction> function =
new WebrtcAudioPrivateGetActiveSinkFunction();
@ -180,7 +180,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, GetSinks) {
scoped_ptr<base::Value> result = InvokeGetSinks(&sink_list);
std::string result_string;
JSONWriter::Write(result.get(), &result_string);
JSONWriter::Write(*result, &result_string);
VLOG(2) << result_string;
EXPECT_EQ(devices.size(), sink_list->GetSize());
@ -229,7 +229,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, GetActiveSinkNoMediaStream) {
base::ListValue parameters;
AppendTabIdToRequestInfo(&parameters, tab_id);
std::string parameter_string;
JSONWriter::Write(&parameters, &parameter_string);
JSONWriter::Write(parameters, &parameter_string);
scoped_refptr<WebrtcAudioPrivateGetActiveSinkFunction> function =
new WebrtcAudioPrivateGetActiveSinkFunction();
@ -240,7 +240,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, GetActiveSinkNoMediaStream) {
browser()));
std::string result_string;
JSONWriter::Write(result.get(), &result_string);
JSONWriter::Write(*result, &result_string);
EXPECT_EQ("\"\"", result_string);
}
@ -253,7 +253,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, SetActiveSinkNoMediaStream) {
AppendTabIdToRequestInfo(&parameters, tab_id);
parameters.AppendString("no such id");
std::string parameter_string;
JSONWriter::Write(&parameters, &parameter_string);
JSONWriter::Write(parameters, &parameter_string);
scoped_refptr<WebrtcAudioPrivateSetActiveSinkFunction> function =
new WebrtcAudioPrivateSetActiveSinkFunction();
@ -299,7 +299,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, GetAndSetWithMediaStream) {
AppendTabIdToRequestInfo(&parameters, tab_id);
parameters.AppendString(target_device);
std::string parameter_string;
JSONWriter::Write(&parameters, &parameter_string);
JSONWriter::Write(parameters, &parameter_string);
scoped_refptr<WebrtcAudioPrivateSetActiveSinkFunction> function =
new WebrtcAudioPrivateSetActiveSinkFunction();
@ -345,14 +345,14 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, GetAssociatedSink) {
parameters.AppendString(origin.spec());
parameters.AppendString(source_id_in_origin);
std::string parameter_string;
JSONWriter::Write(&parameters, &parameter_string);
JSONWriter::Write(parameters, &parameter_string);
scoped_ptr<base::Value> result(
RunFunctionAndReturnSingleResult(function.get(),
parameter_string,
browser()));
std::string result_string;
JSONWriter::Write(result.get(), &result_string);
JSONWriter::Write(*result, &result_string);
VLOG(2) << "Results: " << result_string;
}
}

@ -35,7 +35,7 @@ static const char kTestLoggingUrl[] = "dummy url string";
std::string ParamsToString(const base::ListValue& parameters) {
std::string parameter_string;
EXPECT_TRUE(base::JSONWriter::Write(&parameters, &parameter_string));
EXPECT_TRUE(base::JSONWriter::Write(parameters, &parameter_string));
return parameter_string;
}

@ -994,7 +994,7 @@ class ExternallyConnectableMessagingWithTlsChannelIdTest :
base::DictionaryValue jwk_value;
net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value);
std::string tls_channel_id_value;
base::JSONWriter::Write(&jwk_value, &tls_channel_id_value);
base::JSONWriter::Write(jwk_value, &tls_channel_id_value);
return tls_channel_id_value;
}

@ -388,7 +388,7 @@ void InstallSigner::GetSignature(const SignatureCallback& callback) {
}
dictionary.Set(kIdsKey, id_list.release());
std::string json;
base::JSONWriter::Write(&dictionary, &json);
base::JSONWriter::Write(dictionary, &json);
if (json.empty()) {
ReportErrorViaCallback();
return;

@ -41,7 +41,7 @@ scoped_ptr<base::DictionaryValue> MakeExtensionManifest(
manifest->MergeDictionary(manifest_extra_dict);
} else {
std::string manifest_json;
base::JSONWriter::Write(&manifest_extra, &manifest_json);
base::JSONWriter::Write(manifest_extra, &manifest_json);
ADD_FAILURE() << "Expected dictionary; got \"" << manifest_json << "\"";
}
return manifest;

@ -222,7 +222,7 @@ std::string NormalizeJson(const std::string& json) {
std::string result = json;
scoped_ptr<base::Value> value(base::JSONReader::Read(result));
DCHECK(value);
base::JSONWriter::Write(value.get(), &result);
base::JSONWriter::Write(*value, &result);
return result;
}

@ -410,7 +410,7 @@ void PrivetV3Session::StartPostRequest(const std::string& api,
on_post_data_.Run(input);
std::string json;
base::JSONWriter::WriteWithOptions(
&input, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
input, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
PrivetURLFetcher* fetcher =
CreateFetcher(api, net::URLFetcher::RequestType::POST, callback);
fetcher->SetUploadData(cloud_print::kContentTypeJSON, json);

@ -240,7 +240,7 @@ bool LocalPolicyTestServer::GenerateAdditionalArguments(
if (!clients_.empty()) {
std::string json;
base::JSONWriter::Write(&clients_, &json);
base::JSONWriter::Write(clients_, &json);
base::FilePath client_state_file =
server_data_dir_.path().Append(kClientStateFileName);
if (base::WriteFile(client_state_file, json.c_str(), json.size()) !=

@ -215,7 +215,7 @@ std::string SerializeSettingsReport(const ResettableSettingsSnapshot& snapshot,
"new field needs to be serialized here");
std::string json;
base::JSONWriter::Write(&dict, &json);
base::JSONWriter::Write(dict, &json);
return json;
}

@ -62,7 +62,7 @@ void PreferenceValidationDelegate::OnAtomicPreferenceValidation(
incident->set_path(pref_path);
if (!value ||
(!value->GetAsString(incident->mutable_atomic_value()) &&
!base::JSONWriter::Write(value, incident->mutable_atomic_value()))) {
!base::JSONWriter::Write(*value, incident->mutable_atomic_value()))) {
incident->clear_atomic_value();
}
incident->set_value_state(proto_value_state);

@ -19,7 +19,7 @@ std::string MaybeToJson(const base::Value* value) {
return "(null)";
std::string json;
if (!base::JSONWriter::Write(value, &json))
if (!base::JSONWriter::Write(*value, &json))
return "(invalid value)";
return json;

@ -191,7 +191,7 @@ void TtsExtensionEngine::Speak(Utterance* utterance,
args->AppendInteger(utterance->id());
std::string json;
base::JSONWriter::Write(args.get(), &json);
base::JSONWriter::Write(*args, &json);
scoped_ptr<extensions::Event> event(new extensions::Event(
tts_engine_events::kOnSpeak, args.Pass()));

@ -403,7 +403,7 @@ void FeedbackSender::SendFeedback(const std::vector<Misspelling>& feedback_data,
country_),
api_version_));
std::string feedback;
base::JSONWriter::Write(feedback_value.get(), &feedback);
base::JSONWriter::Write(*feedback_value, &feedback);
// The tests use this identifier to mock the URL fetcher.
static const int kUrlFetcherId = 0;

@ -49,7 +49,7 @@ std::string BuildGetFamilyProfileResponse(
family_dict->SetWithoutPathExpansion("profile", profile_dict);
dict.SetWithoutPathExpansion("family", family_dict);
std::string result;
base::JSONWriter::Write(&dict, &result);
base::JSONWriter::Write(dict, &result);
return result;
}
@ -58,7 +58,7 @@ std::string BuildEmptyGetFamilyProfileResponse() {
base::DictionaryValue* family_dict = new base::DictionaryValue;
dict.SetWithoutPathExpansion("family", family_dict);
std::string result;
base::JSONWriter::Write(&dict, &result);
base::JSONWriter::Write(dict, &result);
return result;
}
@ -97,7 +97,7 @@ std::string BuildGetFamilyMembersResponse(
}
dict.SetWithoutPathExpansion("members", list);
std::string result;
base::JSONWriter::Write(&dict, &result);
base::JSONWriter::Write(dict, &result);
return result;
}

@ -190,7 +190,7 @@ void PermissionRequestCreatorApiary::OnGetTokenSuccess(
dict.SetStringWithoutPathExpansion(kStateKey, kState);
std::string body;
base::JSONWriter::Write(&dict, &body);
base::JSONWriter::Write(dict, &body);
(*it)->url_fetcher->SetUploadData("application/json", body);
(*it)->url_fetcher->Start();

@ -24,7 +24,7 @@ std::string BuildResponse() {
permission_dict->SetStringWithoutPathExpansion("id", "requestid");
dict.SetWithoutPathExpansion("permissionRequest", permission_dict);
std::string result;
base::JSONWriter::Write(&dict, &result);
base::JSONWriter::Write(dict, &result);
return result;
}

@ -53,7 +53,7 @@ std::string BuildResponse(const GURL& url) {
dict.SetWithoutPathExpansion("items", results_list);
}
std::string result;
base::JSONWriter::Write(&dict, &result);
base::JSONWriter::Write(dict, &result);
return result;
}

@ -174,7 +174,7 @@ SyncData SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
const Value& value,
bool acknowledged) {
std::string json_value;
base::JSONWriter::Write(&value, &json_value);
base::JSONWriter::Write(value, &json_value);
::sync_pb::EntitySpecifics specifics;
specifics.mutable_managed_user_shared_setting()->set_mu_id(su_id);
specifics.mutable_managed_user_shared_setting()->set_key(key);

@ -69,7 +69,7 @@ std::string ToJson(const Value* value) {
return std::string();
std::string json_value;
base::JSONWriter::Write(value, &json_value);
base::JSONWriter::Write(*value, &json_value);
return json_value;
}

@ -163,7 +163,7 @@ SyncData SupervisedUserSettingsService::CreateSyncDataForSetting(
const std::string& name,
const base::Value& value) {
std::string json_value;
base::JSONWriter::Write(&value, &json_value);
base::JSONWriter::Write(value, &json_value);
::sync_pb::EntitySpecifics specifics;
specifics.mutable_managed_user_setting()->set_name(name);
specifics.mutable_managed_user_setting()->set_value(json_value);

@ -441,7 +441,7 @@ ScopedJavaLocalRef<jstring> ProfileSyncServiceAndroid::GetAboutInfoForTest(
scoped_ptr<base::DictionaryValue> about_info =
sync_ui_util::ConstructAboutInformation(sync_service_);
std::string about_info_json;
base::JSONWriter::Write(about_info.get(), &about_info_json);
base::JSONWriter::Write(*about_info, &about_info_json);
return ConvertUTF8ToJavaString(env, about_info_json);
}

@ -31,9 +31,8 @@ namespace {
std::string ToJson(const base::Value& value) {
std::string json;
base::JSONWriter::WriteWithOptions(&value,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&json);
base::JSONWriter::WriteWithOptions(
value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
return json;
}

@ -469,8 +469,7 @@ std::string ProfileSyncServiceHarness::GetServiceStatus() {
scoped_ptr<base::DictionaryValue> value(
sync_ui_util::ConstructAboutInformation(service()));
std::string service_status;
base::JSONWriter::WriteWithOptions(value.get(),
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&service_status);
base::JSONWriter::WriteWithOptions(
*value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status);
return service_status;
}

@ -26,7 +26,7 @@ void ExpectSerialization(
process_data_phase, process_id, process_type, &serialized_value);
std::string serialized_json;
base::JSONWriter::Write(&serialized_value, &serialized_json);
base::JSONWriter::Write(serialized_value, &serialized_json);
EXPECT_EQ(expected_json, serialized_json);
}

@ -187,7 +187,7 @@ std::string CertificateViewerModalDialog::GetDialogArgs() const {
// Set the last node as the top of the certificate hierarchy.
cert_info.Set("hierarchy", children);
base::JSONWriter::Write(&cert_info, &data);
base::JSONWriter::Write(cert_info, &data);
return data;
}

@ -68,7 +68,7 @@ bool operator==(const base::Value& first, const base::Value& second) {
// Helper for pretty-printing the contents of base::Value in case of failures.
void PrintTo(const base::Value& value, std::ostream* stream) {
std::string json;
JSONWriter::Write(&value, &json);
JSONWriter::Write(value, &json);
*stream << json;
}
@ -192,7 +192,7 @@ void PreferencesBrowserTest::SetUpInProcessBrowserTestFixture() {
.WillRepeatedly(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(
&policy_provider_);
};
}
void PreferencesBrowserTest::SetUserPolicies(
const std::vector<std::string>& names,
@ -376,9 +376,8 @@ void PreferencesBrowserTest::VerifyClearPref(const std::string& name,
ExpectClearCommit(name);
else
ExpectNoCommit(name);
scoped_ptr<base::Value> commit_ptr(new base::FundamentalValue(commit));
std::string commit_json;
base::JSONWriter::Write(commit_ptr.get(), &commit_json);
base::JSONWriter::Write(base::FundamentalValue(commit), &commit_json);
std::stringstream javascript;
javascript << "testEnv.runAndReply(function() {"
<< " Preferences.clearPref("

@ -93,7 +93,7 @@ std::string GetConfiguration(const base::DictionaryValue* extra_values,
result.SetBoolean("wifiCredentialsSynced",
types.Has(syncer::WIFI_CREDENTIALS));
std::string args;
base::JSONWriter::Write(&result, &args);
base::JSONWriter::Write(result, &args);
return args;
}

@ -217,7 +217,7 @@ void ExtractDomainFromUsername(base::DictionaryValue* dict) {
// Utility function that returns a JSON serialization of the given |dict|.
scoped_ptr<base::StringValue> DictionaryToJSONString(
const base::DictionaryValue* dict) {
const base::DictionaryValue& dict) {
std::string json_string;
base::JSONWriter::WriteWithOptions(dict,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
@ -230,14 +230,14 @@ scoped_ptr<base::StringValue> DictionaryToJSONString(
scoped_ptr<base::Value> CopyAndConvert(const base::Value* value) {
const base::DictionaryValue* dict = NULL;
if (value->GetAsDictionary(&dict))
return DictionaryToJSONString(dict);
return DictionaryToJSONString(*dict);
scoped_ptr<base::Value> copy(value->DeepCopy());
base::ListValue* list = NULL;
if (copy->GetAsList(&list)) {
for (size_t i = 0; i < list->GetSize(); ++i) {
if (list->GetDictionary(i, &dict))
list->Set(i, DictionaryToJSONString(dict).release());
list->Set(i, DictionaryToJSONString(*dict).release());
}
}

@ -173,7 +173,7 @@ std::string ProfileSigninConfirmationDialog::GetDialogArgs() const {
#if defined(OS_WIN)
dict.SetBoolean("hideTitle", true);
#endif
base::JSONWriter::Write(&dict, &data);
base::JSONWriter::Write(dict, &data);
return data;
}

@ -230,7 +230,7 @@ void NetErrorHelper::UpdateErrorPage(const blink::WebURLError& error,
&error_strings);
std::string json;
JSONWriter::Write(&error_strings, &json);
JSONWriter::Write(error_strings, &json);
std::string js = "if (window.updateForDnsProbe) "
"updateForDnsProbe(" + json + ");";

@ -545,7 +545,7 @@ class PrinterCapsHandler : public ServiceUtilityProcessHost::Client {
PrinterSemanticCapsAndDefaultsToCdd(semantic_info));
if (description) {
base::JSONWriter::WriteWithOptions(
description.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT,
*description, base::JSONWriter::OPTIONS_PRETTY_PRINT,
&printer_info.printer_capabilities);
}
}

@ -93,7 +93,7 @@ Status ConsoleLogger::OnEvent(
// Don't know how to format, log full JSON.
std::string message_json;
base::JSONWriter::Write(&params, &message_json);
base::JSONWriter::Write(params, &message_json);
log_->AddEntry(Log::kWarning, message_json);
return Status(kOk);
}

@ -496,7 +496,7 @@ bool ParseInspectorMessage(
if (message_dict->GetDictionary("result", &unscoped_result))
command_response->result.reset(unscoped_result->DeepCopy());
else if (message_dict->GetDictionary("error", &unscoped_error))
base::JSONWriter::Write(unscoped_error, &command_response->error);
base::JSONWriter::Write(*unscoped_error, &command_response->error);
else
command_response->result.reset(new base::DictionaryValue());
return true;

@ -70,7 +70,7 @@ class MockSyncWebSocket : public SyncWebSocket {
base::DictionaryValue result;
result.SetInteger("param", 1);
response.Set("result", result.DeepCopy());
base::JSONWriter::Write(&response, message);
base::JSONWriter::Write(response, message);
--queued_messages_;
return SyncWebSocket::kOk;
}
@ -120,7 +120,7 @@ TEST_F(DevToolsClientImplTest, SendCommandAndGetResult) {
Status status = client.SendCommandAndGetResult("method", params, &result);
ASSERT_EQ(kOk, status.code());
std::string json;
base::JSONWriter::Write(result.get(), &json);
base::JSONWriter::Write(*result, &json);
ASSERT_STREQ("{\"param\":1}", json.c_str());
}
@ -725,7 +725,7 @@ class OnConnectedSyncWebSocket : public SyncWebSocket {
response.SetInteger("id", id);
response.Set("result", new base::DictionaryValue());
std::string json_response;
base::JSONWriter::Write(&response, &json_response);
base::JSONWriter::Write(response, &json_response);
queued_response_.push_back(json_response);
// Push one event.
@ -733,7 +733,7 @@ class OnConnectedSyncWebSocket : public SyncWebSocket {
event.SetString("method", "updateEvent");
event.Set("params", new base::DictionaryValue());
std::string json_event;
base::JSONWriter::Write(&event, &json_event);
base::JSONWriter::Write(event, &json_event);
queued_response_.push_back(json_event);
return true;

@ -43,7 +43,7 @@ Status DomTracker::OnEvent(DevToolsClient* client,
if (!ProcessNodeList(nodes)) {
std::string json;
base::JSONWriter::Write(nodes, &json);
base::JSONWriter::Write(*nodes, &json);
return Status(kUnknownError,
"DOM.setChildNodes has invalid 'nodes': " + json);
}
@ -54,7 +54,7 @@ Status DomTracker::OnEvent(DevToolsClient* client,
if (!ProcessNode(node)) {
std::string json;
base::JSONWriter::Write(node, &json);
base::JSONWriter::Write(*node, &json);
return Status(kUnknownError,
"DOM.childNodeInserted has invalid 'node': " + json);
}

@ -52,7 +52,7 @@ Status FrameTracker::OnEvent(DevToolsClient* client,
if (!context->GetInteger("id", &context_id) ||
!context->GetString("frameId", &frame_id)) {
std::string json;
base::JSONWriter::Write(context, &json);
base::JSONWriter::Write(*context, &json);
return Status(
kUnknownError,
"Runtime.executionContextCreated has invalid 'context': " + json);

@ -85,7 +85,7 @@ bool IsVLogOn(int vlog_level) {
std::string PrettyPrintValue(const base::Value& value) {
std::string json;
base::JSONWriter::WriteWithOptions(
&value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
#if defined(OS_WIN)
base::RemoveChars(json, "\r", &json);
#endif

@ -9,6 +9,6 @@
std::string SerializeValue(const base::Value* value) {
std::string json;
base::JSONWriter::Write(value, &json);
base::JSONWriter::Write(*value, &json);
return json;
}

@ -237,7 +237,7 @@ Status WebViewImpl::CallFunction(const std::string& frame,
const base::ListValue& args,
scoped_ptr<base::Value>* result) {
std::string json;
base::JSONWriter::Write(&args, &json);
base::JSONWriter::Write(args, &json);
// TODO(zachconrad): Second null should be array of shadow host ids.
std::string expression = base::StringPrintf(
"(%s).apply(null, [null, %s, %s])",
@ -763,7 +763,7 @@ Status GetNodeIdFromFunction(DevToolsClient* client,
bool* found_node,
int* node_id) {
std::string json;
base::JSONWriter::Write(&args, &json);
base::JSONWriter::Write(args, &json);
// TODO(zachconrad): Second null should be array of shadow host ids.
std::string expression = base::StringPrintf(
"(%s).apply(null, [null, %s, %s, true])",

@ -692,7 +692,7 @@ Status ProcessExtension(const std::string& extension,
}
} else {
manifest->SetString("key", public_key_base64);
base::JSONWriter::Write(manifest, &manifest_data);
base::JSONWriter::Write(*manifest, &manifest_data);
if (base::WriteFile(
manifest_path, manifest_data.c_str(), manifest_data.size()) !=
static_cast<int>(manifest_data.size())) {
@ -788,7 +788,7 @@ Status WritePrefsFile(
}
std::string prefs_str;
base::JSONWriter::Write(prefs, &prefs_str);
base::JSONWriter::Write(*prefs, &prefs_str);
VLOG(0) << "Populating " << path.BaseName().value()
<< " file: " << PrettyPrintValue(*prefs);
if (static_cast<int>(prefs_str.length()) != base::WriteFile(

@ -123,7 +123,7 @@ void PerformanceLogger::AddLogEntry(
log_message_dict.SetString("message.method", method);
log_message_dict.Set("message.params", params.DeepCopy());
std::string log_message_json;
base::JSONWriter::Write(&log_message_dict, &log_message_json);
base::JSONWriter::Write(log_message_dict, &log_message_json);
// TODO(klm): extract timestamp from params?
// Look at where it is for Page, Network, Timeline, and trace events.

@ -709,7 +709,7 @@ scoped_ptr<net::HttpServerResponseInfo> HttpHandler::PrepareResponseHelper(
body_params.SetString("sessionId", session_id);
std::string body;
base::JSONWriter::WriteWithOptions(
&body_params, base::JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION,
body_params, base::JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION,
&body);
scoped_ptr<net::HttpServerResponseInfo> response(
new net::HttpServerResponseInfo(net::HTTP_OK));

@ -74,7 +74,7 @@ TEST(HttpHandlerTest, HandleNewSession) {
body.SetInteger("value", 1);
body.SetString("sessionId", "session_id");
std::string json;
base::JSONWriter::Write(&body, &json);
base::JSONWriter::Write(body, &json);
ASSERT_EQ(json, response.body());
}
@ -119,7 +119,7 @@ TEST(HttpHandlerTest, HandleCommand) {
body.SetInteger("value", 1);
body.SetString("sessionId", "session_id");
std::string json;
base::JSONWriter::Write(&body, &json);
base::JSONWriter::Write(body, &json);
ASSERT_EQ(json, response.body());
}

@ -54,7 +54,7 @@ bool ValueMatcher::MatchAndExplain(const base::Value& value,
void ValueMatcher::DescribeTo(::std::ostream* os) const {
std::string expected_value_str;
base::JSONWriter::WriteWithOptions(expected_value_.get(),
base::JSONWriter::WriteWithOptions(*expected_value_,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&expected_value_str);
*os << "value equals " << expected_value_str;
@ -62,7 +62,7 @@ void ValueMatcher::DescribeTo(::std::ostream* os) const {
void ValueMatcher::DescribeNegationTo(::std::ostream* os) const {
std::string expected_value_str;
base::JSONWriter::WriteWithOptions(expected_value_.get(),
base::JSONWriter::WriteWithOptions(*expected_value_,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&expected_value_str);
*os << "value does not equal " << expected_value_str;
@ -393,9 +393,9 @@ void ShillClientUnittestBase::ExpectDictionaryValueResultWithoutStatus(
const base::DictionaryValue* expected_result,
const base::DictionaryValue& result) {
std::string expected_result_string;
base::JSONWriter::Write(expected_result, &expected_result_string);
base::JSONWriter::Write(*expected_result, &expected_result_string);
std::string result_string;
base::JSONWriter::Write(&result, &result_string);
base::JSONWriter::Write(result, &result_string);
EXPECT_EQ(expected_result_string, result_string);
}

@ -65,7 +65,7 @@ void LogConfigProperties(const std::string& desc,
iter.Advance()) {
std::string v = "******";
if (shill_property_util::IsLoggableShillProperty(iter.key()))
base::JSONWriter::Write(&iter.value(), &v);
base::JSONWriter::Write(iter.value(), &v);
NET_LOG(USER) << desc << ": " << path + "." + iter.key() + "=" + v;
}
}

@ -46,7 +46,7 @@ namespace {
static std::string PrettyJson(const base::DictionaryValue& value) {
std::string pretty;
base::JSONWriter::WriteWithOptions(
&value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &pretty);
value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &pretty);
return pretty;
}

@ -56,7 +56,7 @@ std::string GetLogName(const ManagedState* state) {
std::string ValueAsString(const base::Value& value) {
std::string vstr;
base::JSONWriter::WriteWithOptions(
&value, base::JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &vstr);
value, base::JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &vstr);
return vstr.empty() ? "''" : vstr;
}

@ -31,7 +31,7 @@ namespace {
scoped_ptr<base::StringValue> ConvertValueToString(const base::Value& value) {
std::string str;
if (!value.GetAsString(&str))
base::JSONWriter::Write(&value, &str);
base::JSONWriter::Write(value, &str);
return make_scoped_ptr(new base::StringValue(str));
}

@ -221,7 +221,7 @@ void SetUIData(const NetworkUIData& ui_data,
base::DictionaryValue ui_data_dict;
ui_data.FillDictionary(&ui_data_dict);
std::string ui_data_blob;
base::JSONWriter::Write(&ui_data_dict, &ui_data_blob);
base::JSONWriter::Write(ui_data_dict, &ui_data_blob);
shill_dictionary->SetStringWithoutPathExpansion(shill::kUIDataProperty,
ui_data_blob);
}

@ -86,10 +86,10 @@ std::string LocalSettingsToJson(const LocalSettings& settings) {
current->SetBoolean("printer/local_printing_enabled",
settings.local_printing_enabled);
current->SetInteger("xmpp_timeout_value", settings.xmpp_timeout_value);
dictionary.Set("current", current.release());
dictionary.Set("current", current.Pass());
std::string local_settings;
base::JSONWriter::Write(&dictionary, &local_settings);
base::JSONWriter::Write(dictionary, &local_settings);
return local_settings;
}

@ -193,7 +193,7 @@ void Printer::Stop() {
std::string Printer::GetRawCdd() {
std::string json_str;
base::JSONWriter::WriteWithOptions(&GetCapabilities(),
base::JSONWriter::WriteWithOptions(GetCapabilities(),
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&json_str);
return json_str;

@ -71,7 +71,7 @@ bool SaveToFile(const base::FilePath& path, const PrinterState& state) {
json.Set(kCdd, state.cdd->DeepCopy());
std::string json_str;
base::JSONWriter::WriteWithOptions(&json,
base::JSONWriter::WriteWithOptions(json,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&json_str);
int size = base::checked_cast<int>(json_str.size());

@ -234,7 +234,7 @@ net::HttpStatusCode PrivetHttpServer::ProcessHttpRequest(
return status_code;
}
base::JSONWriter::WriteWithOptions(json_response.get(),
base::JSONWriter::WriteWithOptions(*json_response,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
response);
return status_code;

@ -134,8 +134,6 @@ bool ServiceState::IsValid() const {
}
std::string ServiceState::ToString() {
scoped_ptr<base::DictionaryValue> services(new base::DictionaryValue());
scoped_ptr<base::DictionaryValue> cloud_print(new base::DictionaryValue());
cloud_print->SetBoolean(kEnabledOptionName, true);
@ -147,12 +145,12 @@ std::string ServiceState::ToString() {
SetNotEmptyJsonString(cloud_print.get(), kXmppAuthTokenOptionName,
xmpp_auth_token_);
services->Set(kCloudPrintJsonName, cloud_print.release());
base::DictionaryValue services;
services.Set(kCloudPrintJsonName, cloud_print.Pass());
std::string json;
base::JSONWriter::WriteWithOptions(services.get(),
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&json);
base::JSONWriter::WriteWithOptions(
services, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
return json;
}

@ -133,7 +133,7 @@ std::string ReadAndUpdateServiceState(const base::FilePath& directory,
if (!proxy_id.empty()) // Reuse proxy id if we already had one.
dictionary->SetString(prefs::kCloudPrintProxyId, proxy_id);
std::string result;
base::JSONWriter::WriteWithOptions(dictionary,
base::JSONWriter::WriteWithOptions(*dictionary,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&result);
return result;
@ -276,7 +276,7 @@ std::string ChromeLauncher::CreateServiceStateFile(
base::ListValue printer_list;
printer_list.AppendStrings(printers);
std::string printers_json;
base::JSONWriter::Write(&printer_list, &printers_json);
base::JSONWriter::Write(printer_list, &printers_json);
size_t written = base::WriteFile(printers_file,
printers_json.c_str(),
printers_json.size());

Some files were not shown because too many files have changed in this diff Show More