diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-23 20:00:20 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-23 20:00:20 +0000 |
commit | 93d49d70b89b22ec46d0b00b7950297f64865d56 (patch) | |
tree | 3243e0209c738df0c18c2ba615667f757fcaec94 | |
parent | a9f607e33a91604bc63bd8c846aefbda9bf0dfa9 (diff) | |
download | chromium_src-93d49d70b89b22ec46d0b00b7950297f64865d56.zip chromium_src-93d49d70b89b22ec46d0b00b7950297f64865d56.tar.gz chromium_src-93d49d70b89b22ec46d0b00b7950297f64865d56.tar.bz2 |
Move the json-related files into a separate json directory. This hopefully also
makes the naming of string_escape more clear (it's actually JSON-specific).
Move the files into the base namespace.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/316016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29934 0039d316-1c4b-4281-b951-d872f2087c98
41 files changed, 195 insertions, 169 deletions
diff --git a/base/base.gyp b/base/base.gyp index 2ca5cfb..6f6790c 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -149,10 +149,12 @@ 'id_map.h', 'image_util.cc', 'image_util.h', - 'json_reader.cc', - 'json_reader.h', - 'json_writer.cc', - 'json_writer.h', + 'json/json_reader.cc', + 'json/json_reader.h', + 'json/json_writer.cc', + 'json/json_writer.h', + 'json/string_escape.cc', + 'json/string_escape.h', 'keyboard_code_conversion_gtk.cc', 'keyboard_code_conversion_gtk.h', 'keyboard_codes.h', @@ -279,8 +281,6 @@ 'stl_util-inl.h', 'string16.cc', 'string16.h', - 'string_escape.cc', - 'string_escape.h', 'string_piece.cc', 'string_piece.h', 'string_tokenizer.h', @@ -578,8 +578,9 @@ 'i18n/file_util_icu_unittest.cc', 'i18n/icu_string_conversions_unittest.cc', 'i18n/word_iterator_unittest.cc', - 'json_reader_unittest.cc', - 'json_writer_unittest.cc', + 'json/json_reader_unittest.cc', + 'json/json_writer_unittest.cc', + 'json/string_escape_unittest.cc', 'lazy_instance_unittest.cc', 'leak_tracker_unittest.cc', 'linked_list_unittest.cc', @@ -607,7 +608,6 @@ 'singleton_unittest.cc', 'stack_container_unittest.cc', 'stats_table_unittest.cc', - 'string_escape_unittest.cc', 'string_piece_unittest.cc', 'string_tokenizer_unittest.cc', 'string_util_unittest.cc', diff --git a/base/json_reader.cc b/base/json/json_reader.cc index ca33cb2..06d790c 100644 --- a/base/json_reader.cc +++ b/base/json/json_reader.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/json_reader.h" +#include "base/json/json_reader.h" #include "base/float_util.h" #include "base/logging.h" @@ -11,6 +11,8 @@ #include "base/utf_string_conversions.h" #include "base/values.h" +namespace base { + static const JSONReader::Token kInvalidToken(JSONReader::Token::INVALID_TOKEN, 0, 0); static const int kStackLimit = 100; @@ -636,3 +638,5 @@ void JSONReader::SetErrorMessage(const char* description, error_message_ = FormatErrorMessage(line_number, column_number, description); } + +} // namespace base diff --git a/base/json_reader.h b/base/json/json_reader.h index 9c4065b..9a82e7f 100644 --- a/base/json_reader.h +++ b/base/json/json_reader.h @@ -28,8 +28,8 @@ // only a convenience for the common uses with more complex configuration going // on the instance. -#ifndef BASE_JSON_READER_H_ -#define BASE_JSON_READER_H_ +#ifndef BASE_JSON_JSON_READER_H_ +#define BASE_JSON_JSON_READER_H_ #include <string> @@ -38,6 +38,8 @@ class Value; +namespace base { + class JSONReader { public: // A struct to hold a JS token. @@ -119,7 +121,7 @@ class JSONReader { static std::string FormatErrorMessage(int line, int column, const char* description); - DISALLOW_EVIL_CONSTRUCTORS(JSONReader); + DISALLOW_COPY_AND_ASSIGN(JSONReader); FRIEND_TEST(JSONReaderTest, Reading); FRIEND_TEST(JSONReaderTest, ErrorMessages); @@ -183,4 +185,6 @@ class JSONReader { std::string error_message_; }; -#endif // BASE_JSON_READER_H_ +} // namespace base + +#endif // BASE_JSON_JSON_READER_H_ diff --git a/base/json_reader_unittest.cc b/base/json/json_reader_unittest.cc index 7f47b8e..8ae51c5 100644 --- a/base/json_reader_unittest.cc +++ b/base/json/json_reader_unittest.cc @@ -3,11 +3,13 @@ // found in the LICENSE file. #include "testing/gtest/include/gtest/gtest.h" -#include "base/json_reader.h" +#include "base/json/json_reader.h" #include "base/scoped_ptr.h" #include "base/values.h" #include "build/build_config.h" +namespace base { + TEST(JSONReaderTest, Reading) { // some whitespace checking scoped_ptr<Value> root; @@ -514,3 +516,5 @@ TEST(JSONReaderTest, ErrorMessages) { error_message); } + +} // namespace base diff --git a/base/json_writer.cc b/base/json/json_writer.cc index 25df120..dffa3da 100644 --- a/base/json_writer.cc +++ b/base/json/json_writer.cc @@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/json_writer.h" +#include "base/json/json_writer.h" +#include "base/json/string_escape.h" #include "base/logging.h" #include "base/string_util.h" #include "base/values.h" -#include "base/string_escape.h" #include "base/utf_string_conversions.h" +namespace base { + #if defined(OS_WIN) static const char kPrettyPrintLineEnding[] = "\r\n"; #else @@ -101,11 +103,9 @@ void JSONWriter::BuildJSONString(const Value* const node, bool result = node->GetAsString(&value); DCHECK(result); if (escape) { - string_escape::JsonDoubleQuote(UTF8ToUTF16(value), - true, - json_string_); + JsonDoubleQuote(UTF8ToUTF16(value), true, json_string_); } else { - string_escape::JsonDoubleQuote(value, true, json_string_); + JsonDoubleQuote(value, true, json_string_); } break; } @@ -186,9 +186,7 @@ void JSONWriter::BuildJSONString(const Value* const node, } void JSONWriter::AppendQuotedString(const std::wstring& str) { - string_escape::JsonDoubleQuote(WideToUTF16Hack(str), - true, - json_string_); + JsonDoubleQuote(WideToUTF16Hack(str), true, json_string_); } void JSONWriter::IndentLine(int depth) { @@ -196,3 +194,5 @@ void JSONWriter::IndentLine(int depth) { // reallocating. json_string_->append(std::string(depth * 3, ' ')); } + +} // namespace base diff --git a/base/json_writer.h b/base/json/json_writer.h index f8d0241..29aa69d 100644 --- a/base/json_writer.h +++ b/base/json/json_writer.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BASE_JSON_WRITER_H_ -#define BASE_JSON_WRITER_H_ +#ifndef BASE_JSON_JSON_WRITER_H_ +#define BASE_JSON_JSON_WRITER_H_ #include <string> @@ -11,6 +11,8 @@ class Value; +namespace base { + class JSONWriter { public: // Given a root node, generates a JSON string and puts it into |json|. @@ -52,4 +54,6 @@ class JSONWriter { DISALLOW_COPY_AND_ASSIGN(JSONWriter); }; -#endif // BASE_JSON_WRITER_H_ +} // namespace base + +#endif // BASE_JSON_JSON_WRITER_H_ diff --git a/base/json_writer_unittest.cc b/base/json/json_writer_unittest.cc index 2792982..cd2a6fe 100644 --- a/base/json_writer_unittest.cc +++ b/base/json/json_writer_unittest.cc @@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "testing/gtest/include/gtest/gtest.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/values.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace base { TEST(JSONWriterTest, Writing) { // Test null @@ -75,3 +77,5 @@ TEST(JSONWriterTest, Writing) { output_js); #undef JSON_NEWLINE } + +} // namespace base diff --git a/base/string_escape.cc b/base/json/string_escape.cc index 0fecfa1..4e1418c 100644 --- a/base/string_escape.cc +++ b/base/json/string_escape.cc @@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/string_escape.h" +#include "base/json/string_escape.h" #include <string> #include "base/string_util.h" -namespace string_escape { +namespace base { + +namespace { // Try to escape |c| as a "SingleEscapeCharacter" (\n, etc). If successful, // returns true and appends the escape sequence to |dst|. This isn't required @@ -72,6 +74,8 @@ void JsonDoubleQuoteT(const STR& str, dst->push_back('"'); } +} // namespace + void JsonDoubleQuote(const std::string& str, bool put_in_quotes, std::string* dst) { @@ -84,4 +88,4 @@ void JsonDoubleQuote(const string16& str, JsonDoubleQuoteT(str, put_in_quotes, dst); } -} // namespace string_escape +} // namespace base diff --git a/base/string_escape.h b/base/json/string_escape.h index 3f0bf3f..7d74021 100644 --- a/base/string_escape.h +++ b/base/json/string_escape.h @@ -4,14 +4,14 @@ // // This file defines utility functions for escaping strings. -#ifndef BASE_STRING_ESCAPE_H__ -#define BASE_STRING_ESCAPE_H__ +#ifndef BASE_JSON_STRING_ESCAPE_H_ +#define BASE_JSON_STRING_ESCAPE_H_ #include <string> #include "base/string16.h" -namespace string_escape { +namespace base { // Escape |str| appropriately for a JSON string litereal, _appending_ the // result to |dst|. This will create unicode escape sequences (\uXXXX). @@ -27,6 +27,6 @@ void JsonDoubleQuote(const string16& str, std::string* dst); -} // namespace string_escape +} // namespace base -#endif // BASE_STRING_ESCAPE_H__ +#endif // BASE_JSON_STRING_ESCAPE_H_ diff --git a/base/string_escape_unittest.cc b/base/json/string_escape_unittest.cc index d731dc1..a3d6262 100644 --- a/base/string_escape_unittest.cc +++ b/base/json/string_escape_unittest.cc @@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "testing/gtest/include/gtest/gtest.h" -#include "base/string_escape.h" +#include "base/json/string_escape.h" #include "base/string_util.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace base { namespace { @@ -24,17 +26,17 @@ TEST(StringEscapeTest, JsonDoubleQuoteNarrow) { for (size_t i = 0; i < arraysize(json_narrow_cases); ++i) { std::string in = json_narrow_cases[i].to_escape; std::string out; - string_escape::JsonDoubleQuote(in, false, &out); + JsonDoubleQuote(in, false, &out); EXPECT_EQ(std::string(json_narrow_cases[i].escaped), out); } std::string in = json_narrow_cases[0].to_escape; std::string out; - string_escape::JsonDoubleQuote(in, false, &out); + JsonDoubleQuote(in, false, &out); // test quoting std::string out_quoted; - string_escape::JsonDoubleQuote(in, true, &out_quoted); + JsonDoubleQuote(in, true, &out_quoted); EXPECT_EQ(out.length() + 2, out_quoted.length()); EXPECT_EQ(out_quoted.find(out), 1U); @@ -45,7 +47,7 @@ TEST(StringEscapeTest, JsonDoubleQuoteNarrow) { std::string expected = "test\\u0000"; expected += json_narrow_cases[0].escaped; out.clear(); - string_escape::JsonDoubleQuote(in, false, &out); + JsonDoubleQuote(in, false, &out); EXPECT_EQ(expected, out); } @@ -69,17 +71,17 @@ TEST(StringEscapeTest, JsonDoubleQuoteWide) { for (size_t i = 0; i < arraysize(json_wide_cases); ++i) { std::string out; string16 in = WideToUTF16(json_wide_cases[i].to_escape); - string_escape::JsonDoubleQuote(in, false, &out); + JsonDoubleQuote(in, false, &out); EXPECT_EQ(std::string(json_wide_cases[i].escaped), out); } string16 in = WideToUTF16(json_wide_cases[0].to_escape); std::string out; - string_escape::JsonDoubleQuote(in, false, &out); + JsonDoubleQuote(in, false, &out); // test quoting std::string out_quoted; - string_escape::JsonDoubleQuote(in, true, &out_quoted); + JsonDoubleQuote(in, true, &out_quoted); EXPECT_EQ(out.length() + 2, out_quoted.length()); EXPECT_EQ(out_quoted.find(out), 1U); @@ -90,6 +92,8 @@ TEST(StringEscapeTest, JsonDoubleQuoteWide) { std::string expected = "test\\u0000"; expected += json_wide_cases[0].escaped; out.clear(); - string_escape::JsonDoubleQuote(in, false, &out); + JsonDoubleQuote(in, false, &out); EXPECT_EQ(expected, out); } + +} // namespace base diff --git a/chrome/browser/automation/automation_extension_function.cc b/chrome/browser/automation/automation_extension_function.cc index 70e886a..98ca3c9 100644 --- a/chrome/browser/automation/automation_extension_function.cc +++ b/chrome/browser/automation/automation_extension_function.cc @@ -6,8 +6,8 @@ #include "chrome/browser/automation/automation_extension_function.h" -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "chrome/browser/automation/extension_automation_constants.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" #include "chrome/browser/renderer_host/render_view_host.h" @@ -16,7 +16,7 @@ bool AutomationExtensionFunction::enabled_ = false; void AutomationExtensionFunction::SetArgs(const Value* args) { - JSONWriter::Write(args, false, &args_); + base::JSONWriter::Write(args, false, &args_); } const std::string AutomationExtensionFunction::GetResult() { @@ -42,7 +42,7 @@ void AutomationExtensionFunction::Run() { message_to_host.SetBoolean(keys::kAutomationHasCallbackKey, has_callback_); std::string message; - JSONWriter::Write(&message_to_host, false, &message); + base::JSONWriter::Write(&message_to_host, false, &message); dispatcher()->render_view_host_->delegate()->ProcessExternalHostMessage( message, keys::kAutomationOrigin, keys::kAutomationRequestTarget); } @@ -87,7 +87,7 @@ bool AutomationExtensionFunction::InterceptMessageFromExternalHost( target == keys::kAutomationResponseTarget) { // This is an extension API response being sent back via postMessage, // so redirect it. - scoped_ptr<Value> message_value(JSONReader::Read(message, false)); + scoped_ptr<Value> message_value(base::JSONReader::Read(message, false)); DCHECK(message_value->IsType(Value::TYPE_DICTIONARY)); if (message_value->IsType(Value::TYPE_DICTIONARY)) { DictionaryValue* message_dict = diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index c28322f..d791afb 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -9,7 +9,7 @@ #include "app/l10n_util.h" #include "app/message_box_flags.h" #include "base/file_version_info.h" -#include "base/json_reader.h" +#include "base/json/json_reader.h" #include "base/keyboard_codes.h" #include "base/message_loop.h" #include "base/path_service.h" @@ -1662,7 +1662,7 @@ bool AutomationProvider::InterceptBrowserEventMessageFromExternalHost( // The message is a JSON-encoded array with two elements, both strings. The // first is the name of the event to dispatch. The second is a JSON-encoding // of the arguments specific to that event. - scoped_ptr<Value> message_value(JSONReader::Read(message, false)); + scoped_ptr<Value> message_value(base::JSONReader::Read(message, false)); if (!message_value.get() || !message_value->IsType(Value::TYPE_LIST)) { LOG(WARNING) << "Invalid browser event specified through automation"; return false; diff --git a/chrome/browser/automation/extension_port_container.cc b/chrome/browser/automation/extension_port_container.cc index a87bd82..246723d 100644 --- a/chrome/browser/automation/extension_port_container.cc +++ b/chrome/browser/automation/extension_port_container.cc @@ -5,8 +5,8 @@ #include "chrome/browser/automation/extension_port_container.h" #include "base/logging.h" -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "base/values.h" #include "chrome/browser/automation/automation_provider.h" #include "chrome/browser/automation/extension_automation_constants.h" @@ -92,7 +92,7 @@ void ExtensionPortContainer::SendConnectionResponse(int connection_id, msg_dict->SetInteger(ext::kAutomationPortIdKey, port_id); std::string msg_json; - JSONWriter::Write(msg_dict.get(), false, &msg_json); + base::JSONWriter::Write(msg_dict.get(), false, &msg_json); PostResponseToExternalPort(msg_json); } @@ -141,7 +141,7 @@ void ExtensionPortContainer::OnExtensionHandleMessage( msg_dict.SetString(ext::kAutomationMessageDataKey, message); std::string msg_json; - JSONWriter::Write(&msg_dict, false, &msg_json); + base::JSONWriter::Write(&msg_dict, false, &msg_json); PostMessageToExternalPort(msg_json); } @@ -153,7 +153,7 @@ void ExtensionPortContainer::OnExtensionPortDisconnected(int source_port_id) { msg_dict.SetInteger(ext::kAutomationPortIdKey, port_id_); std::string msg_json; - JSONWriter::Write(&msg_dict, false, &msg_json); + base::JSONWriter::Write(&msg_dict, false, &msg_json); PostMessageToExternalPort(msg_json); } @@ -170,7 +170,7 @@ bool ExtensionPortContainer::InterceptMessageFromExternalHost( LOG(WARNING) << "Wrong origin on automation port message " << origin; } - scoped_ptr<Value> message_value(JSONReader::Read(message, false)); + scoped_ptr<Value> message_value(base::JSONReader::Read(message, false)); DCHECK(message_value->IsType(Value::TYPE_DICTIONARY)); if (!message_value->IsType(Value::TYPE_DICTIONARY)) return true; diff --git a/chrome/browser/bookmarks/bookmark_storage.cc b/chrome/browser/bookmarks/bookmark_storage.cc index a187921..fb629a9 100644 --- a/chrome/browser/bookmarks/bookmark_storage.cc +++ b/chrome/browser/bookmarks/bookmark_storage.cc @@ -7,7 +7,6 @@ #include "base/compiler_specific.h" #include "base/file_util.h" #include "base/histogram.h" -#include "base/json_writer.h" #include "base/message_loop.h" #include "base/thread.h" #include "base/time.h" diff --git a/chrome/browser/debugger/debugger_remote_service.cc b/chrome/browser/debugger/debugger_remote_service.cc index 9a46c63..8f941ca 100644 --- a/chrome/browser/debugger/debugger_remote_service.cc +++ b/chrome/browser/debugger/debugger_remote_service.cc @@ -7,8 +7,8 @@ #include "chrome/browser/debugger/debugger_remote_service.h" -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/browser_process.h" @@ -65,7 +65,7 @@ DebuggerRemoteService::~DebuggerRemoteService() {} void DebuggerRemoteService::HandleMessage( const DevToolsRemoteMessage& message) { const std::string destination = message.destination(); - scoped_ptr<Value> request(JSONReader::Read(message.content(), true)); + scoped_ptr<Value> request(base::JSONReader::Read(message.content(), true)); if (request.get() == NULL) { // Bad JSON NOTREACHED(); @@ -129,7 +129,7 @@ void DebuggerRemoteService::SendResponse(const Value& response, const std::string& tool, const std::string& destination) { std::string response_content; - JSONWriter::Write(&response, false, &response_content); + base::JSONWriter::Write(&response, false, &response_content); scoped_ptr<DevToolsRemoteMessage> response_message( DevToolsRemoteMessageBuilder::instance().Create(tool, destination, @@ -304,7 +304,7 @@ bool DebuggerRemoteService::DispatchDebuggerCommand(int tab_uid, std::string v8_command; DictionaryValue* v8_command_value; content->GetDictionary(kDataWide, &v8_command_value); - JSONWriter::Write(v8_command_value, false, &v8_command); + base::JSONWriter::Write(v8_command_value, false, &v8_command); manager->ForwardToDevToolsAgent( client_host, DevToolsAgentMsg_DebuggerCommand(v8_command)); // Do not send the response right now, as the JSON will be received from diff --git a/chrome/browser/debugger/devtools_remote_service.cc b/chrome/browser/debugger/devtools_remote_service.cc index 4308d18..3f786af9 100644 --- a/chrome/browser/debugger/devtools_remote_service.cc +++ b/chrome/browser/debugger/devtools_remote_service.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "base/scoped_ptr.h" #include "base/values.h" #include "chrome/browser/browser_process.h" @@ -32,7 +32,7 @@ DevToolsRemoteService::~DevToolsRemoteService() {} void DevToolsRemoteService::HandleMessage( const DevToolsRemoteMessage& message) { - scoped_ptr<Value> request(JSONReader::Read(message.content(), false)); + scoped_ptr<Value> request(base::JSONReader::Read(message.content(), false)); if (request.get() == NULL) { // Bad JSON NOTREACHED(); @@ -94,7 +94,7 @@ void DevToolsRemoteService::ProcessJson(DictionaryValue* json, response.SetInteger(kResultWide, Result::kUnknownCommand); } std::string response_json; - JSONWriter::Write(&response, false, &response_json); + base::JSONWriter::Write(&response, false, &response_json); scoped_ptr<DevToolsRemoteMessage> response_message( DevToolsRemoteMessageBuilder::instance().Create(message.tool(), message.destination(), diff --git a/chrome/browser/debugger/extension_ports_remote_service.cc b/chrome/browser/debugger/extension_ports_remote_service.cc index 68057bd..ed40e99 100644 --- a/chrome/browser/debugger/extension_ports_remote_service.cc +++ b/chrome/browser/debugger/extension_ports_remote_service.cc @@ -9,8 +9,8 @@ #include "chrome/browser/debugger/extension_ports_remote_service.h" -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "base/message_loop.h" #include "base/string_util.h" #include "base/values.h" @@ -147,7 +147,7 @@ void ExtensionPortsRemoteService::HandleMessage( const DevToolsRemoteMessage& message) { DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); const std::string destinationString = message.destination(); - scoped_ptr<Value> request(JSONReader::Read(message.content(), true)); + scoped_ptr<Value> request(base::JSONReader::Read(message.content(), true)); if (request.get() == NULL) { // Bad JSON NOTREACHED(); @@ -220,7 +220,7 @@ void ExtensionPortsRemoteService::SendResponse( const Value& response, const std::string& tool, const std::string& destination) { std::string response_content; - JSONWriter::Write(&response, false, &response_content); + base::JSONWriter::Write(&response, false, &response_content); scoped_ptr<DevToolsRemoteMessage> response_message( DevToolsRemoteMessageBuilder::instance().Create( tool, destination, response_content)); @@ -271,7 +271,7 @@ void ExtensionPortsRemoteService::OnExtensionMessage( content.SetString(kCommandWide, kOnMessage); content.SetInteger(kResultWide, RESULT_OK); // Turn the stringified message body back into JSON. - Value* data = JSONReader::Read(message, false); + Value* data = base::JSONReader::Read(message, false); if (!data) { NOTREACHED(); return; @@ -374,7 +374,7 @@ void ExtensionPortsRemoteService::PostMessageCommand( } std::string message; // Stringified the JSON message body. - JSONWriter::Write(data, false, &message); + base::JSONWriter::Write(data, false, &message); LOG(INFO) << "postMessage: port " << port_id << ", message: <" << message << ">"; PortIdSet::iterator portEntry = openPortIds_.find(port_id); diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc index 7f38aef..34c5956 100644 --- a/chrome/browser/dom_ui/dom_ui.cc +++ b/chrome/browser/dom_ui/dom_ui.cc @@ -5,8 +5,7 @@ #include "chrome/browser/dom_ui/dom_ui.h" #include "app/l10n_util.h" -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/stl_util-inl.h" #include "base/string_util.h" #include "base/values.h" @@ -56,7 +55,7 @@ void DOMUI::CallJavascriptFunction(const std::wstring& function_name) { void DOMUI::CallJavascriptFunction(const std::wstring& function_name, const Value& arg) { std::string json; - JSONWriter::Write(&arg, false, &json); + base::JSONWriter::Write(&arg, false, &json); std::wstring javascript = function_name + L"(" + UTF8ToWide(json) + L");"; ExecuteJavascript(javascript); @@ -66,9 +65,9 @@ void DOMUI::CallJavascriptFunction( const std::wstring& function_name, const Value& arg1, const Value& arg2) { std::string json; - JSONWriter::Write(&arg1, false, &json); + base::JSONWriter::Write(&arg1, false, &json); std::wstring javascript = function_name + L"(" + UTF8ToWide(json); - JSONWriter::Write(&arg2, false, &json); + base::JSONWriter::Write(&arg2, false, &json); javascript += L"," + UTF8ToWide(json) + L");"; ExecuteJavascript(javascript); diff --git a/chrome/browser/dom_ui/new_tab_page_sync_handler.cc b/chrome/browser/dom_ui/new_tab_page_sync_handler.cc index b4db8b3..ff63cf6 100644 --- a/chrome/browser/dom_ui/new_tab_page_sync_handler.cc +++ b/chrome/browser/dom_ui/new_tab_page_sync_handler.cc @@ -7,7 +7,6 @@ #include "chrome/browser/dom_ui/new_tab_page_sync_handler.h" #include "app/l10n_util.h" -#include "base/json_writer.h" #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/net/chrome_url_request_context.h" diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc index 0724a5a..73cb032 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.cc +++ b/chrome/browser/extensions/extension_bookmarks_module.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/extension_bookmarks_module.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/string_util.h" #include "chrome/browser/bookmarks/bookmark_codec.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -185,7 +185,7 @@ void ExtensionBookmarkEventRouter::BookmarkNodeMoved( args.Append(object_args); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(model->profile(), keys::kOnBookmarkMoved, json_args); } @@ -199,7 +199,7 @@ void ExtensionBookmarkEventRouter::BookmarkNodeAdded(BookmarkModel* model, args.Append(obj); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(model->profile(), keys::kOnBookmarkCreated, json_args); } @@ -216,7 +216,7 @@ void ExtensionBookmarkEventRouter::BookmarkNodeRemoved( args.Append(object_args); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(model->profile(), keys::kOnBookmarkRemoved, json_args); } @@ -235,7 +235,7 @@ void ExtensionBookmarkEventRouter::BookmarkNodeChanged( args.Append(object_args); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(model->profile(), keys::kOnBookmarkChanged, json_args); } @@ -260,7 +260,7 @@ void ExtensionBookmarkEventRouter::BookmarkNodeChildrenReordered( args.Append(reorder_info); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(model->profile(), keys::kOnBookmarkChildrenReordered, json_args); diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc index fceb610..b6bfebc 100644 --- a/chrome/browser/extensions/extension_browser_event_router.cc +++ b/chrome/browser/extensions/extension_browser_event_router.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/extension_browser_event_router.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/values.h" #include "chrome/browser/browser.h" #include "chrome/browser/profile.h" @@ -100,7 +100,7 @@ static void DispatchSimpleBrowserEvent(Profile* profile, args.Append(Value::CreateIntegerValue(window_id)); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(profile, event_name, json_args); } @@ -134,7 +134,7 @@ void ExtensionBrowserEventRouter::OnBrowserWindowReady(const Browser* browser) { args.Append(window_dictionary); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(browser->profile(), events::kOnWindowCreated, json_args); } @@ -164,7 +164,7 @@ void ExtensionBrowserEventRouter::TabCreatedAt(TabContents* contents, ListValue args; args.Append(ExtensionTabUtil::CreateTabValue(contents)); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(contents->profile(), events::kOnTabCreated, json_args); @@ -202,7 +202,7 @@ void ExtensionBrowserEventRouter::TabInsertedAt(TabContents* contents, args.Append(object_args); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(contents->profile(), events::kOnTabAttached, json_args); } @@ -226,7 +226,7 @@ void ExtensionBrowserEventRouter::TabDetachedAt(TabContents* contents, args.Append(object_args); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(contents->profile(), events::kOnTabDetached, json_args); } @@ -239,7 +239,7 @@ void ExtensionBrowserEventRouter::TabClosingAt(TabContents* contents, args.Append(Value::CreateIntegerValue(tab_id)); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(contents->profile(), events::kOnTabRemoved, json_args); @@ -266,7 +266,7 @@ void ExtensionBrowserEventRouter::TabSelectedAt(TabContents* old_contents, args.Append(object_args); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(new_contents->profile(), events::kOnTabSelectionChanged, json_args); @@ -289,7 +289,7 @@ void ExtensionBrowserEventRouter::TabMoved(TabContents* contents, args.Append(object_args); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(contents->profile(), events::kOnTabMoved, json_args); } @@ -315,7 +315,7 @@ void ExtensionBrowserEventRouter::TabUpdated(TabContents* contents, args.Append(changed_properties); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); DispatchEvent(contents->profile(), events::kOnTabUpdated, json_args); } @@ -368,7 +368,7 @@ void ExtensionBrowserEventRouter::PageActionExecuted( args.Append(data); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); std::string event_name = std::string("pageAction/") + extension_id; DispatchEvent(profile, event_name.c_str(), json_args); @@ -384,7 +384,7 @@ void ExtensionBrowserEventRouter::BrowserActionExecuted( ListValue args; args.Append(ExtensionTabUtil::CreateTabValue(tab_contents)); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); std::string event_name = std::string("browserAction/") + extension_id; DispatchEvent(profile, event_name.c_str(), json_args); diff --git a/chrome/browser/extensions/extension_function.cc b/chrome/browser/extensions/extension_function.cc index c15c18b..b8aaae1 100644 --- a/chrome/browser/extensions/extension_function.cc +++ b/chrome/browser/extensions/extension_function.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/extension_function.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/logging.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" @@ -17,7 +17,7 @@ const std::string AsyncExtensionFunction::GetResult() { std::string json; // Some functions might not need to return any results. if (result_.get()) - JSONWriter::Write(result_.get(), false, &json); + base::JSONWriter::Write(result_.get(), false, &json); return json; } diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc index 66587b7..9107c4b 100644 --- a/chrome/browser/extensions/extension_message_service.cc +++ b/chrome/browser/extensions/extension_message_service.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/extension_message_service.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/singleton.h" #include "base/stl_util-inl.h" #include "base/values.h" @@ -322,7 +322,7 @@ bool ExtensionMessageService::OpenChannelOnUIThreadImpl( if (source_contents) { DictionaryValue* tab_value = ExtensionTabUtil::CreateTabValue(source_contents); - JSONWriter::Write(tab_value, false, &tab_json); + base::JSONWriter::Write(tab_value, false, &tab_json); } CHECK(receiver.sender); diff --git a/chrome/browser/extensions/extension_toolstrip_api.cc b/chrome/browser/extensions/extension_toolstrip_api.cc index 58950ae..3c52b16 100644 --- a/chrome/browser/extensions/extension_toolstrip_api.cc +++ b/chrome/browser/extensions/extension_toolstrip_api.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/extension_toolstrip_api.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/string_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/extensions/extension_host.h" @@ -131,7 +131,7 @@ void ToolstripEventRouter::DispatchEvent(Profile *profile, const Value& json) { if (profile->GetExtensionMessageService()) { std::string json_args; - JSONWriter::Write(&json, false, &json_args); + base::JSONWriter::Write(&json, false, &json_args); std::string full_event_name = StringPrintf(event_name, routing_id); profile->GetExtensionMessageService()-> DispatchEventToRenderers(full_event_name, json_args); diff --git a/chrome/browser/extensions/extension_uitest.cc b/chrome/browser/extensions/extension_uitest.cc index 4a16cc8..df0b9e8b 100644 --- a/chrome/browser/extensions/extension_uitest.cc +++ b/chrome/browser/extensions/extension_uitest.cc @@ -4,8 +4,8 @@ #include "base/command_line.h" #include "base/gfx/rect.h" -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "base/values.h" #include "chrome/browser/automation/extension_automation_constants.h" #include "chrome/browser/extensions/extension_tabs_module_constants.h" @@ -146,7 +146,8 @@ TEST_F(SimpleApiCallExtensionTest, RunTest) { EXPECT_TRUE(proxy->origin() == keys::kAutomationOrigin); EXPECT_TRUE(proxy->target() == keys::kAutomationRequestTarget); - scoped_ptr<Value> message_value(JSONReader::Read(proxy->message(), false)); + scoped_ptr<Value> message_value(base::JSONReader::Read(proxy->message(), + false)); ASSERT_TRUE(message_value->IsType(Value::TYPE_DICTIONARY)); DictionaryValue* message_dict = reinterpret_cast<DictionaryValue*>(message_value.get()); @@ -231,7 +232,7 @@ class RoundtripAutomationProxy : public MultiMessageAutomationProxy { EXPECT_TRUE(origin_ == keys::kAutomationOrigin); EXPECT_TRUE(target_ == keys::kAutomationRequestTarget); - scoped_ptr<Value> message_value(JSONReader::Read(message_, false)); + scoped_ptr<Value> message_value(base::JSONReader::Read(message_, false)); ASSERT_TRUE(message_value->IsType(Value::TYPE_DICTIONARY)); DictionaryValue* request_dict = static_cast<DictionaryValue*>(message_value.get()); @@ -266,13 +267,13 @@ class RoundtripAutomationProxy : public MultiMessageAutomationProxy { extension_tabs_module_constants::kUrlKey, "http://www.google.com")); std::string tab_json; - JSONWriter::Write(&tab_dict, false, &tab_json); + base::JSONWriter::Write(&tab_dict, false, &tab_json); EXPECT_TRUE(response_dict.SetString(keys::kAutomationResponseKey, tab_json)); std::string response_json; - JSONWriter::Write(&response_dict, false, &response_json); + base::JSONWriter::Write(&response_dict, false, &response_json); tab_->HandleMessageFromExternalHost( response_json, @@ -409,7 +410,7 @@ void BrowserEventAutomationProxy::HandleMessageFromChrome() { // This should be a request for the current window. We don't need to // respond, as this is used only as an indication that the extension // page is now loaded. - scoped_ptr<Value> message_value(JSONReader::Read(message, false)); + scoped_ptr<Value> message_value(base::JSONReader::Read(message, false)); ASSERT_TRUE(message_value->IsType(Value::TYPE_DICTIONARY)); DictionaryValue* message_dict = reinterpret_cast<DictionaryValue*>(message_value.get()); @@ -441,7 +442,7 @@ void BrowserEventAutomationProxy::HandleMessageFromChrome() { // There is a special message "ACK" which means that the extension // received the port connection. This is not an event response and // should happen before all events. - scoped_ptr<Value> message_value(JSONReader::Read(message, false)); + scoped_ptr<Value> message_value(base::JSONReader::Read(message, false)); ASSERT_TRUE(message_value->IsType(Value::TYPE_DICTIONARY)); DictionaryValue* message_dict = reinterpret_cast<DictionaryValue*>(message_value.get()); diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index f2e357d..44c35c4 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -7,7 +7,7 @@ #include "base/command_line.h" #include "base/file_util.h" -#include "base/json_reader.h" +#include "base/json/json_reader.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/string_util.h" @@ -613,7 +613,7 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectoryFail) { EXPECT_TRUE(MatchPattern(GetErrors()[0], std::string("Could not load extension from '*'. * ") + - JSONReader::kBadRootElementType)) << GetErrors()[0]; + base::JSONReader::kBadRootElementType)) << GetErrors()[0]; EXPECT_TRUE(MatchPattern(GetErrors()[1], std::string("Could not load extension from '*'. ") + diff --git a/chrome/browser/history/starred_url_database.cc b/chrome/browser/history/starred_url_database.cc index 31e659c..55aa0dd 100644 --- a/chrome/browser/history/starred_url_database.cc +++ b/chrome/browser/history/starred_url_database.cc @@ -8,7 +8,7 @@ #include "app/sql/statement.h" #include "base/file_util.h" #include "base/logging.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/scoped_vector.h" #include "base/stl_util-inl.h" #include "base/string_util.h" @@ -620,7 +620,7 @@ bool StarredURLDatabase::MigrateBookmarksToFileImpl(const FilePath& path) { scoped_ptr<Value> encoded_bookmarks( encoder.Encode(&bookmark_bar_node, &other_node)); std::string content; - JSONWriter::Write(encoded_bookmarks.get(), true, &content); + base::JSONWriter::Write(encoded_bookmarks.get(), true, &content); return (file_util::WriteFile(path, content.c_str(), static_cast<int>(content.length())) != -1); diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index b59b0ce..5d3e350 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -11,7 +11,7 @@ #include "app/gfx/native_widget_types.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/json_reader.h" +#include "base/json/json_reader.h" #include "base/string_util.h" #include "base/time.h" #include "base/waitable_event.h" @@ -1220,7 +1220,7 @@ void RenderViewHost::OnMsgDOMUISend( const bool kHasCallback = false; scoped_ptr<Value> value; if (!content.empty()) { - value.reset(JSONReader::Read(content, false)); + value.reset(base::JSONReader::Read(content, false)); if (!value.get()) { // The page sent us something that we didn't understand. // This probably indicates a programming error. diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc index 4b5d241..50ab515 100644 --- a/chrome/browser/sync/sync_setup_flow.cc +++ b/chrome/browser/sync/sync_setup_flow.cc @@ -9,8 +9,8 @@ #include "app/gfx/font.h" #include "app/gfx/font_util.h" #include "base/histogram.h" -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" @@ -59,7 +59,7 @@ void FlowHandler::RegisterMessages() { static bool GetUsernameAndPassword(const std::string& json, std::string* username, std::string* password) { - scoped_ptr<Value> parsed_value(JSONReader::Read(json, false)); + scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) return false; @@ -96,7 +96,7 @@ void FlowHandler::HandleSubmitMergeAndSync(const Value* value) { // Called by SyncSetupFlow::Advance. void FlowHandler::ShowGaiaLogin(const DictionaryValue& args) { std::string json; - JSONWriter::Write(&args, false, &json); + base::JSONWriter::Write(&args, false, &json); std::wstring javascript = std::wstring(L"showGaiaLogin") + L"(" + UTF8ToWide(json) + L");"; ExecuteJavascriptInIFrame(kLoginIFrameXPath, javascript); @@ -120,7 +120,7 @@ void FlowHandler::ShowSetupDone(const std::wstring& user) { StringValue synced_to_string(WideToUTF8(l10n_util::GetStringF( IDS_SYNC_NTP_SYNCED_TO, user))); std::string json; - JSONWriter::Write(&synced_to_string, false, &json); + base::JSONWriter::Write(&synced_to_string, false, &json); std::wstring javascript = std::wstring(L"setSyncedToUser") + L"(" + UTF8ToWide(json) + L");"; ExecuteJavascriptInIFrame(kDoneIframeXPath, javascript); @@ -287,7 +287,7 @@ SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service, if (start == SyncSetupWizard::GAIA_LOGIN) SyncSetupFlow::GetArgsForGaiaLogin(service, &args); std::string json_args; - JSONWriter::Write(&args, false, &json_args); + base::JSONWriter::Write(&args, false, &json_args); Browser* b = BrowserList::GetLastActive(); if (!b) diff --git a/chrome/browser/sync/sync_setup_wizard_unittest.cc b/chrome/browser/sync/sync_setup_wizard_unittest.cc index b4cb572..847750f 100644 --- a/chrome/browser/sync/sync_setup_wizard_unittest.cc +++ b/chrome/browser/sync/sync_setup_wizard_unittest.cc @@ -5,7 +5,7 @@ #include "testing/gtest/include/gtest/gtest.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/scoped_ptr.h" #include "base/stl_util-inl.h" #include "chrome/browser/browser.h" @@ -175,7 +175,7 @@ TEST_F(SyncSetupWizardTest, InitialStepLogin) { DictionaryValue dialog_args; SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); std::string json_start_args; - JSONWriter::Write(&dialog_args, false, &json_start_args); + base::JSONWriter::Write(&dialog_args, false, &json_start_args); ListValue credentials; std::string auth = "{\"user\":\""; auth += std::string(kTestUser) + "\",\"pass\":\""; diff --git a/chrome/common/json_value_serializer.cc b/chrome/common/json_value_serializer.cc index 33f94ce..1e739e6 100644 --- a/chrome/common/json_value_serializer.cc +++ b/chrome/common/json_value_serializer.cc @@ -5,8 +5,8 @@ #include "chrome/common/json_value_serializer.h" #include "base/file_util.h" -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "base/string_util.h" JSONStringValueSerializer::~JSONStringValueSerializer() {} @@ -15,8 +15,7 @@ bool JSONStringValueSerializer::Serialize(const Value& root) { if (!json_string_ || initialized_with_const_string_) return false; - JSONWriter::Write(&root, pretty_print_, json_string_); - + base::JSONWriter::Write(&root, pretty_print_, json_string_); return true; } @@ -24,8 +23,9 @@ Value* JSONStringValueSerializer::Deserialize(std::string* error_message) { if (!json_string_) return NULL; - return JSONReader::ReadAndReturnError(*json_string_, allow_trailing_comma_, - error_message); + return base::JSONReader::ReadAndReturnError(*json_string_, + allow_trailing_comma_, + error_message); } /******* File Serializer *******/ diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc index e622458..d1475ec 100644 --- a/chrome/common/json_value_serializer_unittest.cc +++ b/chrome/common/json_value_serializer_unittest.cc @@ -4,8 +4,8 @@ #include "base/basictypes.h" #include "base/file_util.h" -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "base/path_service.h" #include "base/string_util.h" #include "base/values.h" @@ -106,7 +106,7 @@ TEST(JSONValueSerializerTest, StringEscape) { std::string output_js; DictionaryValue valueRoot; valueRoot.SetString(L"all_chars", all_chars); - JSONWriter::Write(&valueRoot, false, &output_js); + base::JSONWriter::Write(&valueRoot, false, &output_js); ASSERT_EQ(expected_output, output_js); // Test JSONValueSerializer interface (uses JSONWriter). @@ -191,7 +191,7 @@ TEST(JSONValueSerializerTest, AllowTrailingComma) { namespace { void ValidateJsonList(const std::string& json) { - scoped_ptr<Value> root(JSONReader::Read(json, false)); + scoped_ptr<Value> root(base::JSONReader::Read(json, false)); ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST)); ListValue* list = static_cast<ListValue*>(root.get()); ASSERT_EQ(1U, list->GetSize()); @@ -215,7 +215,7 @@ TEST(JSONValueSerializerTest, JSONReaderComments) { scoped_ptr<Value> root; // It's ok to have a comment in a string. - root.reset(JSONReader::Read("[\"// ok\\n /* foo */ \"]", false)); + root.reset(base::JSONReader::Read("[\"// ok\\n /* foo */ \"]", false)); ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST)); ListValue* list = static_cast<ListValue*>(root.get()); ASSERT_EQ(1U, list->GetSize()); @@ -226,11 +226,11 @@ TEST(JSONValueSerializerTest, JSONReaderComments) { ASSERT_EQ(L"// ok\n /* foo */ ", value); // You can't nest comments. - root.reset(JSONReader::Read("/* /* inner */ outer */ [ 1 ]", false)); + root.reset(base::JSONReader::Read("/* /* inner */ outer */ [ 1 ]", false)); ASSERT_FALSE(root.get()); // Not a open comment token. - root.reset(JSONReader::Read("/ * * / [1]", false)); + root.reset(base::JSONReader::Read("/ * * / [1]", false)); ASSERT_FALSE(root.get()); } diff --git a/chrome/common/sandbox_mac.mm b/chrome/common/sandbox_mac.mm index 5ffe0d4..ae55b52 100644 --- a/chrome/common/sandbox_mac.mm +++ b/chrome/common/sandbox_mac.mm @@ -13,11 +13,11 @@ extern "C" { #include "base/basictypes.h" #include "base/command_line.h" +#include "base/json/string_escape.h" #include "base/mac_util.h" #include "base/scoped_cftyperef.h" #include "base/scoped_nsautorelease_pool.h" #include "base/string16.h" -#include "base/string_escape.h" #include "base/sys_info.h" #include "base/sys_string_conversions.h" #include "chrome/common/chrome_switches.h" @@ -125,7 +125,7 @@ bool EnableSandbox() { // surrounding sandbox syntax. string16 home_dir = base::SysNSStringToUTF16(NSHomeDirectory()); std::string home_dir_escaped; - string_escape::JsonDoubleQuote(home_dir, false, &home_dir_escaped); + base::JsonDoubleQuote(home_dir, false, &home_dir_escaped); NSString* home_dir_escaped_ns = base::SysUTF8ToNSString(home_dir_escaped); sandbox_data = [sandbox_data stringByReplacingOccurrencesOfString:@"USER_HOMEDIR" diff --git a/chrome/common/web_resource/web_resource_unpacker.cc b/chrome/common/web_resource/web_resource_unpacker.cc index 7f0ced4..bbb14cf 100644 --- a/chrome/common/web_resource/web_resource_unpacker.cc +++ b/chrome/common/web_resource/web_resource_unpacker.cc @@ -4,7 +4,7 @@ #include "chrome/common/web_resource/web_resource_unpacker.h" -#include "base/json_reader.h" +#include "base/json/json_reader.h" #include "base/values.h" const char* WebResourceUnpacker::kInvalidDataTypeError = @@ -19,7 +19,7 @@ const char* WebResourceUnpacker::kUnexpectedJSONFormatError = bool WebResourceUnpacker::Run() { scoped_ptr<Value> value; if (!resource_data_.empty()) { - value.reset(JSONReader::Read(resource_data_, false)); + value.reset(base::JSONReader::Read(resource_data_, false)); if (!value.get()) { // Page information not properly read, or corrupted. error_message_ = kInvalidDataTypeError; diff --git a/chrome/renderer/dom_ui_bindings.cc b/chrome/renderer/dom_ui_bindings.cc index ff9ef18..1183ceb 100644 --- a/chrome/renderer/dom_ui_bindings.cc +++ b/chrome/renderer/dom_ui_bindings.cc @@ -4,7 +4,7 @@ #include "chrome/renderer/dom_ui_bindings.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/stl_util-inl.h" #include "base/values.h" #include "chrome/common/render_messages.h" @@ -40,7 +40,7 @@ void DOMUIBindings::send(const CppArgumentList& args, CppVariant* result) { for (size_t i = 0; i < strings.size(); ++i) { value.Append(Value::CreateStringValue(strings[i])); } - JSONWriter::Write(&value, /* pretty_print= */ false, &content); + base::JSONWriter::Write(&value, /* pretty_print= */ false, &content); } // Send the message up to the browser. diff --git a/chrome/renderer/extensions/extension_api_client_unittest.cc b/chrome/renderer/extensions/extension_api_client_unittest.cc index 0900803..ac06153 100644 --- a/chrome/renderer/extensions/extension_api_client_unittest.cc +++ b/chrome/renderer/extensions/extension_api_client_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "base/file_util.h" -#include "base/json_reader.h" +#include "base/json/json_reader.h" #include "base/path_service.h" #include "base/string_util.h" #include "chrome/common/chrome_paths.h" @@ -59,7 +59,7 @@ class ExtensionAPIClientTest : public RenderViewTest { ASSERT_TRUE(params.b.IsType(Value::TYPE_LIST)); ASSERT_TRUE(static_cast<const ListValue*>(¶ms.b)->Get(0, &args)); - JSONReader reader; + base::JSONReader reader; scoped_ptr<Value> arg1_value(reader.JsonToValue(arg1, false, false)); ASSERT_TRUE(args->Equals(arg1_value.get())) << js; render_thread_.sink().ClearMessages(); diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc index 9641c23..2e8d036 100644 --- a/chrome/renderer/extensions/extension_process_bindings.cc +++ b/chrome/renderer/extensions/extension_process_bindings.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/renderer/extensions/extension_process_bindings.h" + #include <map> #include <set> #include <string> #include <vector> -#include "chrome/renderer/extensions/extension_process_bindings.h" - -#include "base/json_reader.h" +#include "base/json/json_reader.h" #include "base/singleton.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_message_bundle.h" @@ -397,7 +397,7 @@ class ExtensionImpl : public ExtensionBase { // callback will be dispatched to EventBindings::HandleResponse. static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) { std::string str_args = *v8::String::Utf8Value(args[1]); - JSONReader reader; + base::JSONReader reader; Value* value_args = reader.JsonToValue(str_args, false, false); // Since we do the serialization in the v8 extension, we should always get diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc index fca8beb..4a0ef2a 100644 --- a/chrome/test/ui_test_utils.cc +++ b/chrome/test/ui_test_utils.cc @@ -6,7 +6,7 @@ #include <vector> -#include "base/json_reader.h" +#include "base/json/json_reader.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/process_util.h" @@ -397,7 +397,7 @@ Value* ExecuteJavaScript(RenderViewHost* render_view_host, json.insert(0, "["); json.append("]"); - scoped_ptr<Value> root_val(JSONReader::Read(json, true)); + scoped_ptr<Value> root_val(base::JSONReader::Read(json, true)); if (!root_val->IsType(Value::TYPE_LIST)) return NULL; diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc index 06408b4..acb2452 100644 --- a/ipc/ipc_message_utils.cc +++ b/ipc/ipc_message_utils.cc @@ -4,7 +4,7 @@ #include "ipc/ipc_message_utils.h" -#include "base/json_writer.h" +#include "base/json/json_writer.h" #include "base/scoped_ptr.h" #include "base/time.h" #include "base/values.h" @@ -216,7 +216,7 @@ bool ParamTraits<DictionaryValue>::Read( void ParamTraits<DictionaryValue>::Log(const param_type& p, std::wstring* l) { std::string json; - JSONWriter::Write(&p, false, &json); + base::JSONWriter::Write(&p, false, &json); l->append(UTF8ToWide(json)); } @@ -235,7 +235,7 @@ bool ParamTraits<ListValue>::Read( void ParamTraits<ListValue>::Log(const param_type& p, std::wstring* l) { std::string json; - JSONWriter::Write(&p, false, &json); + base::JSONWriter::Write(&p, false, &json); l->append(UTF8ToWide(json)); } } // namespace IPC diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 49ded14..5d2089d 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -32,13 +32,13 @@ #include "base/i18n/file_util_icu.h" #include "base/i18n/icu_string_conversions.h" #include "base/i18n/time_formatting.h" +#include "base/json/string_escape.h" #include "base/lock.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/singleton.h" #include "base/stl_util-inl.h" -#include "base/string_escape.h" #include "base/string_piece.h" #include "base/string_tokenizer.h" #include "base/string_util.h" @@ -945,7 +945,7 @@ std::string GetDirectoryListingHeader(const string16& title) { result.assign(header.data(), header.size()); result.append("<script>start("); - string_escape::JsonDoubleQuote(title, true, &result); + base::JsonDoubleQuote(title, true, &result); result.append(");</script>\n"); return result; @@ -1006,13 +1006,13 @@ std::string GetDirectoryListingEntry(const string16& name, Time modified) { std::string result; result.append("<script>addRow("); - string_escape::JsonDoubleQuote(name, true, &result); + base::JsonDoubleQuote(name, true, &result); result.append(","); if (raw_bytes.empty()) { - string_escape::JsonDoubleQuote(EscapePath(UTF16ToUTF8(name)), + base::JsonDoubleQuote(EscapePath(UTF16ToUTF8(name)), true, &result); } else { - string_escape::JsonDoubleQuote(EscapePath(raw_bytes), true, &result); + base::JsonDoubleQuote(EscapePath(raw_bytes), true, &result); } if (is_dir) { result.append(",1,"); @@ -1020,7 +1020,7 @@ std::string GetDirectoryListingEntry(const string16& name, result.append(",0,"); } - string_escape::JsonDoubleQuote( + base::JsonDoubleQuote( WideToUTF16Hack(FormatBytes(size, GetByteDisplayUnits(size), true)), true, &result); @@ -1031,7 +1031,7 @@ std::string GetDirectoryListingEntry(const string16& name, if (!modified.is_null()) { modified_str = WideToUTF16Hack(base::TimeFormatShortDateAndTime(modified)); } - string_escape::JsonDoubleQuote(modified_str, true, &result); + base::JsonDoubleQuote(modified_str, true, &result); result.append(");</script>\n"); diff --git a/net/base/strict_transport_security_state.cc b/net/base/strict_transport_security_state.cc index fc267c5..8318185 100644 --- a/net/base/strict_transport_security_state.cc +++ b/net/base/strict_transport_security_state.cc @@ -4,8 +4,8 @@ #include "net/base/strict_transport_security_state.h" -#include "base/json_reader.h" -#include "base/json_writer.h" +#include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "base/logging.h" #include "base/scoped_ptr.h" #include "base/sha2.h" @@ -228,7 +228,7 @@ bool StrictTransportSecurityState::Serialise(std::string* output) { toplevel.Set(HashedDomainToExternalString(i->first), state); } - JSONWriter::Write(&toplevel, true /* pretty print */, output); + base::JSONWriter::Write(&toplevel, true /* pretty print */, output); return true; } @@ -238,7 +238,7 @@ bool StrictTransportSecurityState::Deserialise(const std::string& input) { enabled_hosts_.clear(); scoped_ptr<Value> value( - JSONReader::Read(input, false /* do not allow trailing commas */)); + base::JSONReader::Read(input, false /* do not allow trailing commas */)); if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) return false; |