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:
Cheng Zhao 2013-09-20 22:55:42 +08:00
parent ef5a4b5fe0
commit ef4b36d621
17 changed files with 68 additions and 60 deletions

View file

@ -6,6 +6,7 @@
#include "browser/api/atom_api_window.h"
#include "browser/ui/accelerator_util.h"
#include "common/string16_conversions.h"
#define UNWRAP_MEMNU_AND_CHECK \
Menu* self = ObjectWrap::Unwrap<Menu>(args.This()); \
@ -18,17 +19,6 @@ namespace api {
namespace {
// Converts a V8 value to a string16.
string16 V8ValueToUTF16(v8::Handle<v8::Value> value) {
v8::String::Value s(value);
return string16(reinterpret_cast<const char16*>(*s), s.length());
}
// Converts string16 to V8 String.
v8::Handle<v8::Value> UTF16ToV8Value(const string16& s) {
return v8::String::New(reinterpret_cast<const uint16_t*>(s.data()), s.size());
}
// Call method of delegate object.
v8::Handle<v8::Value> CallDelegate(v8::Handle<v8::Value> default_value,
v8::Handle<v8::Object> menu,