fix: fall back to default logs path in getPath('logs') (#19653)

This commit is contained in:
Shelley Vohr 2019-08-19 15:16:00 -07:00 committed by GitHub
parent 0851697cb7
commit 1dc02e6dbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 89 additions and 19 deletions

View file

@ -7,6 +7,8 @@
#include "native_mate/converter.h"
#include "base/optional.h"
namespace base {
class DictionaryValue;
class ListValue;
@ -33,6 +35,29 @@ struct Converter<base::Value> {
const base::Value& val);
};
template <typename T>
struct Converter<base::Optional<T>> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::Optional<T>* out) {
if (val->IsNull() || val->IsUndefined()) {
return true;
}
T converted;
if (Converter<T>::FromV8(isolate, val, &converted)) {
return true;
}
out->emplace(converted);
return true;
}
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const base::Optional<T>& val) {
if (val.has_value())
return Converter<T>::ToV8(val.value());
return v8::Undefined(isolate);
}
};
template <>
struct Converter<base::ListValue> {
static bool FromV8(v8::Isolate* isolate,