]> khamidou — GitHub mirrors - electron.git/commitdiff
Use native_mate based Event in browser_ipc.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 17 Apr 2014 09:14:05 +0000 (17:14 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 17 Apr 2014 09:14:05 +0000 (17:14 +0800)
atom/browser/api/atom_api_browser_ipc.cc
atom/browser/api/atom_browser_bindings.cc
spec/api-ipc-spec.coffee

index b2fb31cead1adf0acede1028106580ea8fb77890..da0da3fab3027edb2fe2ae9571678dc8e9598815 100644 (file)
@@ -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) {
index 1d25fa19fe1cb3c1ad77305211cac3210d4d1b50..2a69a595c275ce9d99067cfb15356062be53fc61 100644 (file)
@@ -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));
 
index 890b7ab6fcf404c05993c7ac2bfc28cc898d24da..1116d1bce280175b58ea1721481adf891940ec75 100644 (file)
@@ -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')