2013-06-01 07:57:37 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-03-16 01:13:06 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/common/crash_reporter/crash_reporter.h"
|
2014-04-15 08:02:19 +00:00
|
|
|
#include "base/bind.h"
|
2014-04-16 07:31:59 +00:00
|
|
|
#include "native_mate/dictionary.h"
|
2013-12-11 07:48:19 +00:00
|
|
|
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/common/v8/node_common.h"
|
2013-06-01 07:57:37 +00:00
|
|
|
|
2014-04-15 08:02:19 +00:00
|
|
|
namespace mate {
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct Converter<std::map<std::string, std::string> > {
|
|
|
|
static bool FromV8(v8::Isolate* isolate,
|
|
|
|
v8::Handle<v8::Value> val,
|
|
|
|
std::map<std::string, std::string>* out) {
|
|
|
|
if (!val->IsObject())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
v8::Handle<v8::Object> dict = val->ToObject();
|
|
|
|
v8::Handle<v8::Array> keys = dict->GetOwnPropertyNames();
|
|
|
|
for (uint32_t i = 0; i < keys->Length(); ++i) {
|
|
|
|
v8::Handle<v8::Value> key = keys->Get(i);
|
|
|
|
(*out)[V8ToString(key)] = V8ToString(dict->Get(key));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mate
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
void Initialize(v8::Handle<v8::Object> exports) {
|
|
|
|
using crash_reporter::CrashReporter;
|
2014-04-16 07:31:59 +00:00
|
|
|
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
|
|
|
|
dict.SetMethod("start",
|
|
|
|
base::Bind(&CrashReporter::Start,
|
|
|
|
base::Unretained(CrashReporter::GetInstance())));
|
2013-06-01 07:57:37 +00:00
|
|
|
}
|
|
|
|
|
2014-04-15 08:02:19 +00:00
|
|
|
} // namespace
|
2013-06-01 07:57:37 +00:00
|
|
|
|
2014-04-15 08:02:19 +00:00
|
|
|
NODE_MODULE(atom_common_crash_reporter, Initialize)
|