Use native_mate to simplify dialog api.
This commit is contained in:
parent
6e2bf824f0
commit
aa1efe70e2
10 changed files with 189 additions and 143 deletions
|
@ -28,7 +28,7 @@ int32_t IDWeakMap::Add(v8::Isolate* isolate, v8::Handle<v8::Object> object) {
|
|||
object->SetHiddenValue(mate::StringToV8(isolate, "IDWeakMapKey"),
|
||||
mate::Converter<int32_t>::ToV8(isolate, key));
|
||||
|
||||
map_[key] = new RefCountedPersistent<v8::Object>(object);
|
||||
map_[key] = new mate::RefCountedPersistent<v8::Object>(object);
|
||||
map_[key]->MakeWeak(this, WeakCallback);
|
||||
return key;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/common/v8/scoped_persistent.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "native_mate/scoped_persistent.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -40,6 +40,9 @@ class IDWeakMap : public mate::Wrappable {
|
|||
IDWeakMap* self);
|
||||
|
||||
int32_t next_id_;
|
||||
|
||||
typedef scoped_refptr<mate::RefCountedPersistent<v8::Object> >
|
||||
RefCountedV8Object;
|
||||
std::map<int32_t, RefCountedV8Object> map_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(IDWeakMap);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "atom/common/platform_util.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "atom/common/v8_converters/file_path_converter.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
|
@ -28,21 +28,6 @@ struct Converter<GURL> {
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Converter<base::FilePath> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
base::FilePath* out) {
|
||||
std::string path;
|
||||
if (Converter<std::string>::FromV8(isolate, val, &path)) {
|
||||
*out = base::FilePath::FromUTF8Unsafe(path);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue