Skip to content

Commit a755ede

Browse files
committed
Simplify atom_bindings
1 parent 76fc628 commit a755ede

File tree

2 files changed

+5
-34
lines changed

2 files changed

+5
-34
lines changed

atom/common/api/atom_bindings.cc

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "atom/common/chrome_version.h"
1212
#include "atom/common/native_mate_converters/string16_converter.h"
1313
#include "base/logging.h"
14-
#include "native_mate/callback.h"
14+
#include "base/debug/debugger.h"
1515
#include "native_mate/dictionary.h"
1616

1717
#include "atom/common/node_includes.h"
@@ -20,22 +20,8 @@ namespace atom {
2020

2121
namespace {
2222

23-
// Async handle to execute the stored v8 callback.
24-
uv_async_t g_callback_uv_handle;
25-
26-
// Stored v8 callback, to be called by the async handler.
27-
base::Closure g_v8_callback;
28-
29-
// Dummy class type that used for crashing the program.
30-
struct DummyClass { bool crash; };
31-
32-
// Async handler to execute the stored v8 callback.
33-
void UvOnCallback(uv_async_t* handle) {
34-
g_v8_callback.Run();
35-
}
36-
3723
void Crash() {
38-
static_cast<DummyClass*>(NULL)->crash = true;
24+
base::debug::BreakDebugger();
3925
}
4026

4127
// Called when there is a fatal error in V8, we just crash the process here so
@@ -49,19 +35,12 @@ void Log(const base::string16& message) {
4935
logging::LogMessage("CONSOLE", 0, 0).stream() << message;
5036
}
5137

52-
void ScheduleCallback(const base::Closure& callback) {
53-
g_v8_callback = callback;
54-
uv_async_send(&g_callback_uv_handle);
55-
}
56-
5738
} // namespace
5839

5940

6041
AtomBindings::AtomBindings() {
6142
uv_async_init(uv_default_loop(), &call_next_tick_async_, OnCallNextTick);
6243
call_next_tick_async_.data = this;
63-
64-
uv_async_init(uv_default_loop(), &g_callback_uv_handle, UvOnCallback);
6544
}
6645

6746
AtomBindings::~AtomBindings() {
@@ -74,16 +53,13 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
7453
mate::Dictionary dict(isolate, process);
7554
dict.SetMethod("crash", &Crash);
7655
dict.SetMethod("log", &Log);
77-
dict.SetMethod("scheduleCallback", &ScheduleCallback);
7856
dict.SetMethod("activateUvLoop",
7957
base::Bind(&AtomBindings::ActivateUVLoop, base::Unretained(this)));
8058

81-
v8::Handle<v8::Object> versions;
59+
mate::Dictionary versions;
8260
if (dict.Get("versions", &versions)) {
83-
versions->Set(mate::StringToV8(isolate, "atom-shell"),
84-
mate::StringToV8(isolate, ATOM_VERSION_STRING));
85-
versions->Set(mate::StringToV8(isolate, "chrome"),
86-
mate::StringToV8(isolate, CHROME_VERSION_STRING));
61+
versions.Set("atom-shell", ATOM_VERSION_STRING);
62+
versions.Set("chrome", CHROME_VERSION_STRING);
8763
}
8864
}
8965

spec/node-spec.coffee

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ describe 'node feature', ->
5454
fs.readFile __filename, ->
5555
setTimeout done, 0
5656

57-
describe 'setTimeout in pure uv callback', ->
58-
it 'does not crash', (done) ->
59-
process.scheduleCallback ->
60-
setTimeout done, 0
61-
6257
describe 'throw error in node context', ->
6358
it 'gets caught', (done) ->
6459
error = new Error('boo!')

0 commit comments

Comments
 (0)