Simplify atom_browser_bindings.

This commit is contained in:
Cheng Zhao 2014-04-22 11:06:13 +08:00
parent 3b8f959ddf
commit ef5342b86e
2 changed files with 8 additions and 11 deletions

View file

@ -6,10 +6,12 @@
#include <vector> #include <vector>
#include "base/logging.h"
#include "atom/browser/api/event.h" #include "atom/browser/api/event.h"
#include "atom/common/v8/native_type_conversions.h" #include "atom/common/native_mate_converters/string16_converter.h"
#include "content/public/browser/browser_thread.h" #include "atom/common/native_mate_converters/v8_value_converter.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "atom/common/node_includes.h" #include "atom/common/node_includes.h"
@ -18,9 +20,6 @@ namespace atom {
AtomBrowserBindings::AtomBrowserBindings() { AtomBrowserBindings::AtomBrowserBindings() {
} }
AtomBrowserBindings::~AtomBrowserBindings() {
}
void AtomBrowserBindings::OnRendererMessage(int process_id, void AtomBrowserBindings::OnRendererMessage(int process_id,
int routing_id, int routing_id,
const string16& channel, const string16& channel,
@ -33,7 +32,7 @@ void AtomBrowserBindings::OnRendererMessage(int process_id,
// process.emit(channel, 'message', process_id, routing_id); // process.emit(channel, 'message', process_id, routing_id);
std::vector<v8::Handle<v8::Value>> arguments; std::vector<v8::Handle<v8::Value>> arguments;
arguments.reserve(3 + args.GetSize()); arguments.reserve(3 + args.GetSize());
arguments.push_back(ToV8Value(channel)); arguments.push_back(mate::ConvertToV8(node_isolate, channel));
const base::Value* value; const base::Value* value;
if (args.Get(0, &value)) if (args.Get(0, &value))
arguments.push_back(converter->ToV8Value(value, global_env->context())); arguments.push_back(converter->ToV8Value(value, global_env->context()));
@ -71,7 +70,7 @@ void AtomBrowserBindings::OnRendererMessageSync(
// process.emit(channel, 'sync-message', event, process_id, routing_id); // process.emit(channel, 'sync-message', event, process_id, routing_id);
std::vector<v8::Handle<v8::Value>> arguments; std::vector<v8::Handle<v8::Value>> arguments;
arguments.reserve(3 + args.GetSize()); arguments.reserve(3 + args.GetSize());
arguments.push_back(ToV8Value(channel)); arguments.push_back(mate::ConvertToV8(node_isolate, channel));
const base::Value* value; const base::Value* value;
if (args.Get(0, &value)) if (args.Get(0, &value))
arguments.push_back(converter->ToV8Value(value, global_env->context())); arguments.push_back(converter->ToV8Value(value, global_env->context()));

View file

@ -5,9 +5,8 @@
#ifndef ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_H_ #ifndef ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_H_
#define ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_H_ #define ATOM_BROWSER_API_ATOM_BROWSER_BINDINGS_H_
#include "base/strings/string16.h"
#include "atom/common/api/atom_bindings.h" #include "atom/common/api/atom_bindings.h"
#include "atom/common/v8/scoped_persistent.h" #include "base/strings/string16.h"
namespace base { namespace base {
class ListValue; class ListValue;
@ -26,7 +25,6 @@ namespace atom {
class AtomBrowserBindings : public AtomBindings { class AtomBrowserBindings : public AtomBindings {
public: public:
AtomBrowserBindings(); AtomBrowserBindings();
virtual ~AtomBrowserBindings();
// Called when received a message from renderer. // Called when received a message from renderer.
void OnRendererMessage(int process_id, void OnRendererMessage(int process_id,