Use string16 instead of std::string when sending IPC messages.
The underlying V8::String is represented in UTF18, by using string16 in IPC messages we can avoid the overhead of encode conversion.
This commit is contained in:
parent
ef5a4b5fe0
commit
ef4b36d621
17 changed files with 68 additions and 60 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "base/values.h"
|
||||
#include "common/api/api_messages.h"
|
||||
#include "common/string16_conversions.h"
|
||||
#include "content/public/renderer/render_view.h"
|
||||
#include "content/public/renderer/v8_value_converter.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
|
@ -47,8 +48,7 @@ v8::Handle<v8::Value> RendererIPC::Send(const v8::Arguments &args) {
|
|||
if (!args[0]->IsString())
|
||||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
std::string channel(*v8::String::Utf8Value(args[0]));
|
||||
|
||||
string16 channel(V8ValueToUTF16(args[0]));
|
||||
RenderView* render_view = GetCurrentRenderView();
|
||||
|
||||
// Convert Arguments to Array, so we can use V8ValueConverter to convert it
|
||||
|
@ -82,7 +82,7 @@ v8::Handle<v8::Value> RendererIPC::SendSync(const v8::Arguments &args) {
|
|||
return node::ThrowTypeError("Bad argument");
|
||||
|
||||
v8::Handle<v8::Context> context = v8::Context::GetCurrent();
|
||||
std::string channel(*v8::String::Utf8Value(args[0]));
|
||||
string16 channel(V8ValueToUTF16(args[0]));
|
||||
|
||||
// Convert Arguments to Array, so we can use V8ValueConverter to convert it
|
||||
// to ListValue.
|
||||
|
@ -97,7 +97,7 @@ v8::Handle<v8::Value> RendererIPC::SendSync(const v8::Arguments &args) {
|
|||
|
||||
RenderView* render_view = GetCurrentRenderView();
|
||||
|
||||
std::string json;
|
||||
string16 json;
|
||||
IPC::SyncMessage* message = new AtomViewHostMsg_Message_Sync(
|
||||
render_view->GetRoutingID(),
|
||||
channel,
|
||||
|
@ -110,7 +110,7 @@ v8::Handle<v8::Value> RendererIPC::SendSync(const v8::Arguments &args) {
|
|||
if (!success)
|
||||
return node::ThrowError("Unable to send AtomViewHostMsg_Message_Sync");
|
||||
|
||||
return scope.Close(v8::String::New(json.data(), json.size()));
|
||||
return scope.Close(UTF16ToV8Value(json));
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue