diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 08:46:45 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 08:46:45 +0000 |
commit | 007b3f812fc9c989fb99d4a668d8bd9c7807ad81 (patch) | |
tree | 43e69dd0f4e4dbbe68afb6319fa18cee07a4be64 /ppapi | |
parent | 2bde7e94eb8f402839145e48924391a5c645a554 (diff) | |
download | chromium_src-007b3f812fc9c989fb99d4a668d8bd9c7807ad81.zip chromium_src-007b3f812fc9c989fb99d4a668d8bd9c7807ad81.tar.gz chromium_src-007b3f812fc9c989fb99d4a668d8bd9c7807ad81.tar.bz2 |
Rewrite std::string("") to std::string(), Linux edition.
This patch was generated by running the empty_string clang tool
across the Chromium Linux compilation database. Implicitly or
explicitly constructing std::string() with a "" argument is
inefficient as the caller needs to emit extra instructions to
pass an argument, and the constructor needlessly copies a byte
into internal storage. Rewriting these instances to simply call
the default constructor appears to save ~14-18 kilobytes on an
optimized release build.
BUG=none
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=193020
Review URL: https://codereview.chromium.org/13145003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/cpp/dev/text_input_dev.cc | 2 | ||||
-rw-r--r-- | ppapi/examples/ime/ime.cc | 12 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/plugin.cc | 2 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/plugin_error.h | 2 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc | 4 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/service_runtime.cc | 2 | ||||
-rw-r--r-- | ppapi/proxy/audio_input_resource.cc | 5 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_audio_shared.cc | 7 | ||||
-rw-r--r-- | ppapi/tests/test_file_ref.cc | 2 | ||||
-rw-r--r-- | ppapi/tests/test_flash_clipboard.cc | 2 | ||||
-rw-r--r-- | ppapi/tests/test_flash_file.cc | 13 | ||||
-rw-r--r-- | ppapi/tests/test_ime_input_event.cc | 6 | ||||
-rw-r--r-- | ppapi/tests/test_url_loader.cc | 19 | ||||
-rw-r--r-- | ppapi/tests/test_websocket.cc | 82 | ||||
-rw-r--r-- | ppapi/tests/test_x509_certificate_private.cc | 28 |
15 files changed, 103 insertions, 85 deletions
diff --git a/ppapi/cpp/dev/text_input_dev.cc b/ppapi/cpp/dev/text_input_dev.cc index 3b38df8..657a0b3 100644 --- a/ppapi/cpp/dev/text_input_dev.cc +++ b/ppapi/cpp/dev/text_input_dev.cc @@ -54,7 +54,7 @@ TextInput_Dev::~TextInput_Dev() { void TextInput_Dev::RequestSurroundingText(uint32_t) { // Default implementation. Send a null range. - UpdateSurroundingText("", 0, 0); + UpdateSurroundingText(std::string(), 0, 0); } void TextInput_Dev::SetTextInputType(PP_TextInput_Type type) { diff --git a/ppapi/examples/ime/ime.cc b/ppapi/examples/ime/ime.cc index f5e2e44..6f3e655 100644 --- a/ppapi/examples/ime/ime.cc +++ b/ppapi/examples/ime/ime.cc @@ -245,7 +245,7 @@ class MyTextField { int32_t target_segment, const std::pair<uint32_t, uint32_t>& selection) { if (HasSelection() && !text.empty()) - InsertText(""); + InsertText(std::string()); composition_ = text; segments_ = segments; target_segment_ = target_segment; @@ -344,7 +344,7 @@ class MyTextField { if (!Focused()) return; if (HasSelection()) { - InsertText(""); + InsertText(std::string()); } else { size_t i = GetNextCharOffsetUtf8(utf8_text_, caret_pos_); utf8_text_.erase(caret_pos_, i - caret_pos_); @@ -356,7 +356,7 @@ class MyTextField { if (!Focused()) return; if (HasSelection()) { - InsertText(""); + InsertText(std::string()); } else if (caret_pos_ != 0) { size_t i = GetPrevCharOffsetUtf8(utf8_text_, caret_pos_); utf8_text_.erase(i, caret_pos_ - i); @@ -565,8 +565,10 @@ class MyInstance : public pp::Instance { it != textfield_.end(); ++it) { if (it->Focused()) { - it->SetComposition("", std::vector< std::pair<uint32_t, uint32_t> >(), - 0, std::make_pair(0, 0)); + it->SetComposition(std::string(), + std::vector<std::pair<uint32_t, uint32_t> >(), + 0, + std::make_pair(0, 0)); return true; } } diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc index e1f3ad9..7b2f0a9 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -677,7 +677,6 @@ bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) { return status; } - Plugin::Plugin(PP_Instance pp_instance) : pp::InstancePrivate(pp_instance), scriptable_plugin_(NULL), @@ -688,7 +687,6 @@ Plugin::Plugin(PP_Instance pp_instance) nacl_ready_state_(UNSENT), nexe_error_reported_(false), wrapper_factory_(NULL), - last_error_string_(""), enable_dev_interfaces_(false), is_installed_(false), init_time_(0), diff --git a/ppapi/native_client/src/trusted/plugin/plugin_error.h b/ppapi/native_client/src/trusted/plugin/plugin_error.h index 90c0284..f02ef83 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin_error.h +++ b/ppapi/native_client/src/trusted/plugin/plugin_error.h @@ -109,7 +109,7 @@ class ErrorInfo { } void Reset() { - SetReport(ERROR_UNKNOWN, ""); + SetReport(ERROR_UNKNOWN, std::string()); } void SetReport(PluginErrorCode error_code, const std::string& message) { diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc index a7d3f24..ff0982e 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc +++ b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc @@ -224,9 +224,7 @@ void PnaclTranslateThread::DoTranslate() { } PLUGIN_PRINTF(("PnaclTranslateThread done with chunks\n")); // Finish llc. - if(!llc_subprocess_->InvokeSrpcMethod("StreamEnd", - "", - ¶ms)) { + if (!llc_subprocess_->InvokeSrpcMethod("StreamEnd", std::string(), ¶ms)) { PLUGIN_PRINTF(("PnaclTranslateThread StreamEnd failed\n")); if (llc_subprocess_->srpc_client()->GetLastError() == NACL_SRPC_RESULT_APP_ERROR) { diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/ppapi/native_client/src/trusted/plugin/service_runtime.cc index 00f64c7..68a50d3 100644 --- a/ppapi/native_client/src/trusted/plugin/service_runtime.cc +++ b/ppapi/native_client/src/trusted/plugin/service_runtime.cc @@ -846,7 +846,7 @@ nacl::string ServiceRuntime::GetCrashLogOutput() { if (NULL != subprocess_.get()) { return subprocess_->GetCrashLogOutput(); } else { - return ""; + return std::string(); } } diff --git a/ppapi/proxy/audio_input_resource.cc b/ppapi/proxy/audio_input_resource.cc index 5f700ec..4f321c2 100644 --- a/ppapi/proxy/audio_input_resource.cc +++ b/ppapi/proxy/audio_input_resource.cc @@ -217,7 +217,10 @@ void AudioInputResource::SetStreamInfo( shared_memory_size_ = shared_memory_size; if (!shared_memory_->Map(shared_memory_size_)) { - PpapiGlobals::Get()->LogWithSource(pp_instance(), PP_LOGLEVEL_WARNING, "", + PpapiGlobals::Get()->LogWithSource( + pp_instance(), + PP_LOGLEVEL_WARNING, + std::string(), "Failed to map shared memory for PPB_AudioInput_Shared."); } diff --git a/ppapi/shared_impl/ppb_audio_shared.cc b/ppapi/shared_impl/ppb_audio_shared.cc index f275559..f6d0cac 100644 --- a/ppapi/shared_impl/ppb_audio_shared.cc +++ b/ppapi/shared_impl/ppb_audio_shared.cc @@ -80,8 +80,11 @@ void PPB_Audio_Shared::SetStreamInfo( if (!shared_memory_->Map( media::TotalSharedMemorySizeInBytes(shared_memory_size_))) { - PpapiGlobals::Get()->LogWithSource(instance, PP_LOGLEVEL_WARNING, "", - "Failed to map shared memory for PPB_Audio_Shared."); + PpapiGlobals::Get()->LogWithSource( + instance, + PP_LOGLEVEL_WARNING, + std::string(), + "Failed to map shared memory for PPB_Audio_Shared."); } else { audio_bus_ = media::AudioBus::WrapMemory( kChannels, sample_frame_count, shared_memory_->memory()); diff --git a/ppapi/tests/test_file_ref.cc b/ppapi/tests/test_file_ref.cc index 2dfea85..f3217f9 100644 --- a/ppapi/tests/test_file_ref.cc +++ b/ppapi/tests/test_file_ref.cc @@ -85,7 +85,7 @@ void TestFileRef::RunTests(const std::string& filter) { std::string TestFileRef::TestCreate() { std::vector<std::string> invalid_paths; invalid_paths.push_back("invalid_path"); // no '/' at the first character - invalid_paths.push_back(""); // empty path + invalid_paths.push_back(std::string()); // empty path // The following are directory traversal checks invalid_paths.push_back(".."); invalid_paths.push_back("/../invalid_path"); diff --git a/ppapi/tests/test_flash_clipboard.cc b/ppapi/tests/test_flash_clipboard.cc index e38c145..8eb756b 100644 --- a/ppapi/tests/test_flash_clipboard.cc +++ b/ppapi/tests/test_flash_clipboard.cc @@ -253,7 +253,7 @@ std::string TestFlashClipboard::TestInvalidFormat() { std::string TestFlashClipboard::TestRegisterCustomFormat() { // Test an empty name is rejected. uint32_t format_id = - pp::flash::Clipboard::RegisterCustomFormat(instance_, ""); + pp::flash::Clipboard::RegisterCustomFormat(instance_, std::string()); ASSERT_EQ(format_id, PP_FLASH_CLIPBOARD_FORMAT_INVALID); // Test a valid format name. diff --git a/ppapi/tests/test_flash_file.cc b/ppapi/tests/test_flash_file.cc index 86100d9..e5a8ee9 100644 --- a/ppapi/tests/test_flash_file.cc +++ b/ppapi/tests/test_flash_file.cc @@ -285,12 +285,10 @@ std::string TestFlashFile::TestGetDirContents() { CloseFileHandle(file_handle); ASSERT_TRUE(FileModuleLocal::CreateDir(instance_, dirname)); - ASSERT_TRUE(FileModuleLocal::GetDirContents(instance_, "", &result)); - FileModuleLocal::DirEntry expected[] = - { {"..", true}, - {filename, false}, - {dirname, true} - }; + ASSERT_TRUE( + FileModuleLocal::GetDirContents(instance_, std::string(), &result)); + FileModuleLocal::DirEntry expected[] = { { "..", true }, { filename, false }, + { dirname, true } }; size_t expected_size = sizeof(expected) / sizeof(expected[0]); std::sort(expected, expected + expected_size, DirEntryLessThan); @@ -329,7 +327,8 @@ std::string TestFlashFile::TestCreateTemporaryFile() { std::string TestFlashFile::GetItemCountUnderModuleLocalRoot( size_t* item_count) { std::vector<FileModuleLocal::DirEntry> contents; - ASSERT_TRUE(FileModuleLocal::GetDirContents(instance_, "", &contents)); + ASSERT_TRUE( + FileModuleLocal::GetDirContents(instance_, std::string(), &contents)); *item_count = contents.size(); PASS(); } diff --git a/ppapi/tests/test_ime_input_event.cc b/ppapi/tests/test_ime_input_event.cc index 804e17d7a..500fcbb 100644 --- a/ppapi/tests/test_ime_input_event.cc +++ b/ppapi/tests/test_ime_input_event.cc @@ -357,11 +357,11 @@ std::string TestImeInputEvent::TestImeCancel() { expected_events_.clear(); expected_events_.push_back(CreateImeCompositionStartEvent()); expected_events_.push_back(update_event); - expected_events_.push_back(CreateImeCompositionEndEvent("")); + expected_events_.push_back(CreateImeCompositionEndEvent(std::string())); // Simulate the case when IME canceled composition. ASSERT_TRUE(SimulateInputEvent(update_event)); - ASSERT_TRUE(SimulateInputEvent(CreateImeCompositionEndEvent(""))); + ASSERT_TRUE(SimulateInputEvent(CreateImeCompositionEndEvent(std::string()))); ASSERT_TRUE(expected_events_.empty()); PASS(); @@ -417,7 +417,7 @@ std::string TestImeInputEvent::TestImeUnawareCancel() { // Test for IME-unaware plugins. Cancel won't issue any events. ASSERT_TRUE(SimulateInputEvent(update_event)); - ASSERT_TRUE(SimulateInputEvent(CreateImeCompositionEndEvent(""))); + ASSERT_TRUE(SimulateInputEvent(CreateImeCompositionEndEvent(std::string()))); ASSERT_TRUE(expected_events_.empty()); PASS(); diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc index 112a483..320167a 100644 --- a/ppapi/tests/test_url_loader.cc +++ b/ppapi/tests/test_url_loader.cc @@ -375,7 +375,7 @@ std::string TestURLLoader::TestEmptyDataPOST() { request.SetURL("/echo"); request.SetMethod("POST"); request.AppendDataToBody("", 0); - return LoadAndCompareBody(request, ""); + return LoadAndCompareBody(request, std::string()); } std::string TestURLLoader::TestBinaryDataPOST() { @@ -558,11 +558,12 @@ std::string TestURLLoader::TestUntrustedHttpRequests() { // valid token (containing special characters like CR, LF). // http://www.w3.org/TR/XMLHttpRequest/ { - ASSERT_EQ(OpenUntrusted("cOnNeCt", ""), PP_ERROR_NOACCESS); - ASSERT_EQ(OpenUntrusted("tRaCk", ""), PP_ERROR_NOACCESS); - ASSERT_EQ(OpenUntrusted("tRaCe", ""), PP_ERROR_NOACCESS); - ASSERT_EQ(OpenUntrusted("POST\x0d\x0ax-csrf-token:\x20test1234", ""), - PP_ERROR_NOACCESS); + ASSERT_EQ(OpenUntrusted("cOnNeCt", std::string()), PP_ERROR_NOACCESS); + ASSERT_EQ(OpenUntrusted("tRaCk", std::string()), PP_ERROR_NOACCESS); + ASSERT_EQ(OpenUntrusted("tRaCe", std::string()), PP_ERROR_NOACCESS); + ASSERT_EQ( + OpenUntrusted("POST\x0d\x0ax-csrf-token:\x20test1234", std::string()), + PP_ERROR_NOACCESS); } // HTTP methods are restricted only for untrusted loaders. Try all headers // that are forbidden by http://www.w3.org/TR/XMLHttpRequest/. @@ -619,9 +620,9 @@ std::string TestURLLoader::TestUntrustedHttpRequests() { std::string TestURLLoader::TestTrustedHttpRequests() { // Trusted requests can use restricted methods. { - ASSERT_EQ(OpenTrusted("cOnNeCt", ""), PP_OK); - ASSERT_EQ(OpenTrusted("tRaCk", ""), PP_OK); - ASSERT_EQ(OpenTrusted("tRaCe", ""), PP_OK); + ASSERT_EQ(OpenTrusted("cOnNeCt", std::string()), PP_OK); + ASSERT_EQ(OpenTrusted("tRaCk", std::string()), PP_OK); + ASSERT_EQ(OpenTrusted("tRaCe", std::string()), PP_OK); } // Trusted requests can use restricted headers. { diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc index e61185d..61a8e19 100644 --- a/ppapi/tests/test_websocket.cc +++ b/ppapi/tests/test_websocket.cc @@ -350,18 +350,18 @@ std::string TestWebSocket::TestUninitializedPropertiesAccess() { ASSERT_EQ(0U, close_code); PP_Var close_reason = websocket_interface_->GetCloseReason(ws); - ASSERT_TRUE(AreEqualWithString(close_reason, "")); + ASSERT_TRUE(AreEqualWithString(close_reason, std::string())); ReleaseVar(close_reason); PP_Bool close_was_clean = websocket_interface_->GetCloseWasClean(ws); ASSERT_EQ(PP_FALSE, close_was_clean); PP_Var extensions = websocket_interface_->GetExtensions(ws); - ASSERT_TRUE(AreEqualWithString(extensions, "")); + ASSERT_TRUE(AreEqualWithString(extensions, std::string())); ReleaseVar(extensions); PP_Var protocol = websocket_interface_->GetProtocol(ws); - ASSERT_TRUE(AreEqualWithString(protocol, "")); + ASSERT_TRUE(AreEqualWithString(protocol, std::string())); ReleaseVar(protocol); PP_WebSocketReadyState ready_state = @@ -369,7 +369,7 @@ std::string TestWebSocket::TestUninitializedPropertiesAccess() { ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID, ready_state); PP_Var url = websocket_interface_->GetURL(ws); - ASSERT_TRUE(AreEqualWithString(url, "")); + ASSERT_TRUE(AreEqualWithString(url, std::string())); ReleaseVar(url); core_interface_->ReleaseResource(ws); @@ -398,7 +398,7 @@ std::string TestWebSocket::TestInvalidConnect() { for (int i = 0; kInvalidURLs[i]; ++i) { int32_t result; - ws = Connect(kInvalidURLs[i], &result, ""); + ws = Connect(kInvalidURLs[i], &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_ERROR_BADARGUMENT, result); @@ -448,7 +448,7 @@ std::string TestWebSocket::TestProtocols() { std::string TestWebSocket::TestGetURL() { for (int i = 0; kInvalidURLs[i]; ++i) { int32_t result; - PP_Resource ws = Connect(kInvalidURLs[i], &result, ""); + PP_Resource ws = Connect(kInvalidURLs[i], &result, std::string()); ASSERT_TRUE(ws); PP_Var url = websocket_interface_->GetURL(ws); ASSERT_TRUE(AreEqualWithString(url, kInvalidURLs[i])); @@ -463,11 +463,11 @@ std::string TestWebSocket::TestGetURL() { std::string TestWebSocket::TestValidConnect() { int32_t result; - PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); PP_Var extensions = websocket_interface_->GetExtensions(ws); - ASSERT_TRUE(AreEqualWithString(extensions, "")); + ASSERT_TRUE(AreEqualWithString(extensions, std::string())); core_interface_->ReleaseResource(ws); ReleaseVar(extensions); @@ -489,7 +489,7 @@ std::string TestWebSocket::TestInvalidClose() { // Close with bad arguments. int32_t result; - ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); callback.WaitForResult(websocket_interface_->Close( @@ -498,7 +498,7 @@ std::string TestWebSocket::TestInvalidClose() { core_interface_->ReleaseResource(ws); // Close with PP_VARTYPE_NULL. - ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); callback.WaitForResult(websocket_interface_->Close( @@ -508,7 +508,7 @@ std::string TestWebSocket::TestInvalidClose() { core_interface_->ReleaseResource(ws); // Close with PP_VARTYPE_NULL and ongoing receive message. - ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); PP_Var receive_message_var; @@ -532,7 +532,7 @@ std::string TestWebSocket::TestInvalidClose() { core_interface_->ReleaseResource(ws); // Close twice. - ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); result = websocket_interface_->Close( @@ -569,7 +569,7 @@ std::string TestWebSocket::TestValidClose() { // Close. int32_t result; - PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); callback.WaitForResult(websocket_interface_->Close( @@ -580,7 +580,7 @@ std::string TestWebSocket::TestValidClose() { core_interface_->ReleaseResource(ws); // Close without code and reason. - ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); callback.WaitForResult(websocket_interface_->Close( @@ -590,7 +590,7 @@ std::string TestWebSocket::TestValidClose() { core_interface_->ReleaseResource(ws); // Close with PP_VARTYPE_UNDEFINED. - ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); callback.WaitForResult(websocket_interface_->Close( @@ -620,7 +620,7 @@ std::string TestWebSocket::TestValidClose() { // Close in closing. // The first close will be done successfully, then the second one failed with // with PP_ERROR_INPROGRESS immediately. - ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); result = websocket_interface_->Close( @@ -636,7 +636,7 @@ std::string TestWebSocket::TestValidClose() { core_interface_->ReleaseResource(ws); // Close with ongoing receive message. - ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); PP_Var receive_message_var; @@ -655,7 +655,7 @@ std::string TestWebSocket::TestValidClose() { core_interface_->ReleaseResource(ws); // Close with PP_VARTYPE_UNDEFINED and ongoing receive message. - ws = Connect(GetFullURL(kEchoServerURL), &result, ""); + ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); result = websocket_interface_->ReceiveMessage( @@ -673,7 +673,8 @@ std::string TestWebSocket::TestValidClose() { core_interface_->ReleaseResource(ws); // Server initiated closing handshake. - ws = Connect(GetFullURL(kCloseWithCodeAndReasonServerURL), &result, ""); + ws = Connect( + GetFullURL(kCloseWithCodeAndReasonServerURL), &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); // Text messsage "1000 bye" requests the server to initiate closing handshake @@ -720,7 +721,8 @@ std::string TestWebSocket::TestGetProtocol() { std::string TestWebSocket::TestTextSendReceive() { // Connect to test echo server. int32_t connect_result; - PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &connect_result, ""); + PP_Resource ws = + Connect(GetFullURL(kEchoServerURL), &connect_result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, connect_result); @@ -747,7 +749,8 @@ std::string TestWebSocket::TestTextSendReceive() { std::string TestWebSocket::TestBinarySendReceive() { // Connect to test echo server. int32_t connect_result; - PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &connect_result, ""); + PP_Resource ws = + Connect(GetFullURL(kEchoServerURL), &connect_result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, connect_result); @@ -776,7 +779,8 @@ std::string TestWebSocket::TestBinarySendReceive() { std::string TestWebSocket::TestStressedSendReceive() { // Connect to test echo server. int32_t connect_result; - PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &connect_result, ""); + PP_Resource ws = + Connect(GetFullURL(kEchoServerURL), &connect_result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, connect_result); @@ -836,7 +840,8 @@ std::string TestWebSocket::TestStressedSendReceive() { std::string TestWebSocket::TestBufferedAmount() { // Connect to test echo server. int32_t connect_result; - PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &connect_result, ""); + PP_Resource ws = + Connect(GetFullURL(kEchoServerURL), &connect_result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, connect_result); @@ -876,7 +881,7 @@ std::string TestWebSocket::TestBufferedAmount() { // After connection closure, all sending requests fail and just increase // the bufferedAmount property. - PP_Var empty_string = CreateVarString(""); + PP_Var empty_string = CreateVarString(std::string()); result = websocket_interface_->SendMessage(ws, empty_string); ASSERT_EQ(PP_ERROR_FAILED, result); buffered_amount = websocket_interface_->GetBufferedAmount(ws); @@ -919,7 +924,7 @@ std::string TestWebSocket::TestAbortCallsWithCallback() { ASSERT_EQ(PP_ERROR_ABORTED, connect_callback.result()); // Test the behavior for Close(). - ws = Connect(url, &result, ""); + ws = Connect(url, &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); PP_Var reason_var = CreateVarString("abort"); @@ -936,7 +941,7 @@ std::string TestWebSocket::TestAbortCallsWithCallback() { // Test the behavior for ReceiveMessage(). // Make sure the simplest case to wait for data which never arrives, here. - ws = Connect(url, &result, ""); + ws = Connect(url, &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); PP_Var receive_var; @@ -952,7 +957,7 @@ std::string TestWebSocket::TestAbortCallsWithCallback() { // Release the resource in the aborting receive completion callback which is // introduced by calling Close(). - ws = Connect(url, &result, ""); + ws = Connect(url, &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); result = websocket_interface_->ReceiveMessage( @@ -986,7 +991,7 @@ std::string TestWebSocket::TestAbortSendMessageCall() { int32_t result; std::string url = GetFullURL(kEchoServerURL); - PP_Resource ws = Connect(url, &result, ""); + PP_Resource ws = Connect(url, &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); result = websocket_interface_->SendMessage(ws, large_var); @@ -1001,7 +1006,7 @@ std::string TestWebSocket::TestAbortCloseCall() { // Release the resource in the close completion callback. int32_t result; std::string url = GetFullURL(kEchoServerURL); - PP_Resource ws = Connect(url, &result, ""); + PP_Resource ws = Connect(url, &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); TestCompletionCallback close_callback( @@ -1034,7 +1039,7 @@ std::string TestWebSocket::TestAbortReceiveMessageCall() { // released while the next message is going to be received. const int trial_count = 8; for (int trial = 1; trial <= trial_count; trial++) { - ws = Connect(url, &result, ""); + ws = Connect(url, &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); for (int i = 0; i <= trial_count; ++i) { @@ -1060,7 +1065,7 @@ std::string TestWebSocket::TestAbortReceiveMessageCall() { } // Same test, but the last receiving message is large message over 64KiB. for (int trial = 1; trial <= trial_count; trial++) { - ws = Connect(url, &result, ""); + ws = Connect(url, &result, std::string()); ASSERT_TRUE(ws); ASSERT_EQ(PP_OK, result); for (int i = 0; i <= trial_count; ++i) { @@ -1102,12 +1107,12 @@ std::string TestWebSocket::TestCcInterfaces() { // Check uninitialized properties access. ASSERT_EQ(0, ws.GetBufferedAmount()); ASSERT_EQ(0, ws.GetCloseCode()); - ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), "")); + ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), std::string())); ASSERT_EQ(false, ws.GetCloseWasClean()); - ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); - ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); + ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), std::string())); + ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), std::string())); ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID, ws.GetReadyState()); - ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), "")); + ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), std::string())); // Check communication interfaces (connect, send, receive, and close). TestCompletionCallback connect_callback( @@ -1163,7 +1168,7 @@ std::string TestWebSocket::TestCcInterfaces() { ASSERT_TRUE( AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); ASSERT_EQ(true, ws.GetCloseWasClean()); - ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); + ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), std::string())); ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED, ws.GetReadyState()); ASSERT_TRUE(AreEqualWithString( ws.GetURL().pp_var(), GetFullURL(kCloseServerURL).c_str())); @@ -1268,7 +1273,8 @@ std::string TestWebSocket::TestUtilityValidConnect() { const std::vector<WebSocketEvent>& events = websocket.GetSeenEvents(); ASSERT_EQ(1U, events.size()); ASSERT_EQ(WebSocketEvent::EVENT_OPEN, events[0].event_type); - ASSERT_TRUE(AreEqualWithString(websocket.GetExtensions().pp_var(), "")); + ASSERT_TRUE( + AreEqualWithString(websocket.GetExtensions().pp_var(), std::string())); PASS(); } @@ -1496,7 +1502,7 @@ std::string TestWebSocket::TestUtilityBufferedAmount() { // After connection closure, all sending requests fail and just increase // the bufferedAmount property. - result = websocket.Send(pp::Var(std::string(""))); + result = websocket.Send(pp::Var(std::string())); ASSERT_EQ(PP_ERROR_FAILED, result); buffered_amount = websocket.GetBufferedAmount(); ASSERT_EQ(base_buffered_amount + kMessageFrameOverhead, buffered_amount); diff --git a/ppapi/tests/test_x509_certificate_private.cc b/ppapi/tests/test_x509_certificate_private.cc index 6aee30f..fab2f21 100644 --- a/ppapi/tests/test_x509_certificate_private.cc +++ b/ppapi/tests/test_x509_certificate_private.cc @@ -166,22 +166,30 @@ std::string TestX509CertificatePrivate::TestValidCertificate() { PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME, "US")); ASSERT_TRUE(FieldMatchesString(certificate, PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME, "Google Inc")); - ASSERT_TRUE(FieldMatchesString(certificate, - PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME, "")); + ASSERT_TRUE(FieldMatchesString( + certificate, + PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME, + std::string())); ASSERT_TRUE(FieldMatchesString(certificate, PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME, "Thawte SGC CA")); - ASSERT_TRUE(FieldMatchesString(certificate, - PP_X509CERTIFICATE_PRIVATE_ISSUER_LOCALITY_NAME, "")); - ASSERT_TRUE(FieldMatchesString(certificate, - PP_X509CERTIFICATE_PRIVATE_ISSUER_STATE_OR_PROVINCE_NAME, "")); - ASSERT_TRUE(FieldMatchesString(certificate, - PP_X509CERTIFICATE_PRIVATE_ISSUER_COUNTRY_NAME, "ZA")); + ASSERT_TRUE( + FieldMatchesString(certificate, + PP_X509CERTIFICATE_PRIVATE_ISSUER_LOCALITY_NAME, + std::string())); + ASSERT_TRUE(FieldMatchesString( + certificate, + PP_X509CERTIFICATE_PRIVATE_ISSUER_STATE_OR_PROVINCE_NAME, + std::string())); + ASSERT_TRUE(FieldMatchesString( + certificate, PP_X509CERTIFICATE_PRIVATE_ISSUER_COUNTRY_NAME, "ZA")); ASSERT_TRUE(FieldMatchesString(certificate, PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME, "Thawte Consulting (Pty) Ltd.")); - ASSERT_TRUE(FieldMatchesString(certificate, - PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME, "")); + ASSERT_TRUE(FieldMatchesString( + certificate, + PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME, + std::string())); ASSERT_FALSE(FieldIsNull(certificate, PP_X509CERTIFICATE_PRIVATE_SERIAL_NUMBER)); |