Use native_mate based Event in browser_ipc.

This commit is contained in:
Cheng Zhao 2014-04-17 17:14:05 +08:00
Родитель da483ba7f3
Коммит f36569c3b9
3 изменённых файлов: 7 добавлений и 8 удалений

Просмотреть файл

@ -6,6 +6,7 @@
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "content/public/browser/render_view_host.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
@ -14,7 +15,7 @@ using content::RenderViewHost;
namespace {
bool Send(const string16& channel, int process_id, int routing_id,
const base:ListValue& arguments) {
const base::ListValue& arguments) {
RenderViewHost* render_view_host(RenderViewHost::FromID(
process_id, routing_id));
if (!render_view_host) {

Просмотреть файл

@ -7,7 +7,7 @@
#include <vector>
#include "base/logging.h"
#include "atom/browser/api/atom_api_event.h"
#include "atom/browser/api/event.h"
#include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/browser_thread.h"
@ -65,8 +65,8 @@ void AtomBrowserBindings::OnRendererMessageSync(
scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
// Create the event object.
v8::Handle<v8::Object> event = api::Event::CreateV8Object();
api::Event::Unwrap<api::Event>(event)->SetSenderAndMessage(sender, message);
mate::Handle<mate::Event> event = mate::Event::Create(node_isolate);
event->SetSenderAndMessage(sender, message);
// process.emit(channel, 'sync-message', event, process_id, routing_id);
std::vector<v8::Handle<v8::Value>> arguments;
@ -75,7 +75,7 @@ void AtomBrowserBindings::OnRendererMessageSync(
const base::Value* value;
if (args.Get(0, &value))
arguments.push_back(converter->ToV8Value(value, global_env->context()));
arguments.push_back(event);
arguments.push_back(event.ToV8());
arguments.push_back(v8::Integer::New(process_id));
arguments.push_back(v8::Integer::New(routing_id));

Просмотреть файл

@ -61,12 +61,10 @@ describe 'ipc module', ->
msg = ipc.sendChannelSync 'echo', 'test'
assert.equal msg, 'test'
it 'does not crash when reply is not sent and both browser and event are destroyed', (done) ->
it 'does not crash when reply is not sent and browser is destroyed', (done) ->
w = new BrowserWindow(show: false)
remote.require('ipc').once 'send-sync-message', (event) ->
event.returnValue = null
w.destroy()
event.destroy()
done()
w.loadUrl 'file://' + path.join(fixtures, 'api', 'send-sync-message.html')