also format missing .cc files
This commit is contained in:
parent
53bdf22c85
commit
c6f4bbd143
181 changed files with 4102 additions and 4254 deletions
|
@ -22,15 +22,15 @@ namespace {
|
|||
class Archive : public mate::Wrappable<Archive> {
|
||||
public:
|
||||
static v8::Local<v8::Value> Create(v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
const base::FilePath& path) {
|
||||
std::unique_ptr<asar::Archive> archive(new asar::Archive(path));
|
||||
if (!archive->Init())
|
||||
return v8::False(isolate);
|
||||
return (new Archive(isolate, std::move(archive)))->GetWrapper();
|
||||
}
|
||||
|
||||
static void BuildPrototype(
|
||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "Archive"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetProperty("path", &Archive::GetPath)
|
||||
|
@ -50,13 +50,11 @@ class Archive : public mate::Wrappable<Archive> {
|
|||
}
|
||||
|
||||
// Returns the path of the file.
|
||||
base::FilePath GetPath() {
|
||||
return archive_->path();
|
||||
}
|
||||
base::FilePath GetPath() { return archive_->path(); }
|
||||
|
||||
// Reads the offset and size of file.
|
||||
v8::Local<v8::Value> GetFileInfo(v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
const base::FilePath& path) {
|
||||
asar::Archive::FileInfo info;
|
||||
if (!archive_ || !archive_->GetFileInfo(path, &info))
|
||||
return v8::False(isolate);
|
||||
|
@ -68,8 +66,7 @@ class Archive : public mate::Wrappable<Archive> {
|
|||
}
|
||||
|
||||
// Returns a fake result of fs.stat(path).
|
||||
v8::Local<v8::Value> Stat(v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
v8::Local<v8::Value> Stat(v8::Isolate* isolate, const base::FilePath& path) {
|
||||
asar::Archive::Stats stats;
|
||||
if (!archive_ || !archive_->Stat(path, &stats))
|
||||
return v8::False(isolate);
|
||||
|
@ -84,7 +81,7 @@ class Archive : public mate::Wrappable<Archive> {
|
|||
|
||||
// Returns all files under a directory.
|
||||
v8::Local<v8::Value> Readdir(v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
const base::FilePath& path) {
|
||||
std::vector<base::FilePath> files;
|
||||
if (!archive_ || !archive_->Readdir(path, &files))
|
||||
return v8::False(isolate);
|
||||
|
@ -93,7 +90,7 @@ class Archive : public mate::Wrappable<Archive> {
|
|||
|
||||
// Returns the path of file with symbol link resolved.
|
||||
v8::Local<v8::Value> Realpath(v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
const base::FilePath& path) {
|
||||
base::FilePath realpath;
|
||||
if (!archive_ || !archive_->Realpath(path, &realpath))
|
||||
return v8::False(isolate);
|
||||
|
@ -102,7 +99,7 @@ class Archive : public mate::Wrappable<Archive> {
|
|||
|
||||
// Copy the file out into a temporary file and returns the new path.
|
||||
v8::Local<v8::Value> CopyFileOut(v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
const base::FilePath& path) {
|
||||
base::FilePath new_path;
|
||||
if (!archive_ || !archive_->CopyFileOut(path, &new_path))
|
||||
return v8::False(isolate);
|
||||
|
@ -117,9 +114,7 @@ class Archive : public mate::Wrappable<Archive> {
|
|||
}
|
||||
|
||||
// Free the resources used by archive.
|
||||
void Destroy() {
|
||||
archive_.reset();
|
||||
}
|
||||
void Destroy() { archive_.reset(); }
|
||||
|
||||
private:
|
||||
std::unique_ptr<asar::Archive> archive_;
|
||||
|
@ -138,14 +133,18 @@ void InitAsarSupport(v8::Isolate* isolate,
|
|||
// Initialize asar support.
|
||||
if (result->IsFunction()) {
|
||||
v8::Local<v8::Value> args[] = {
|
||||
process, require, node::asar_value.ToStringChecked(isolate),
|
||||
process,
|
||||
require,
|
||||
node::asar_value.ToStringChecked(isolate),
|
||||
};
|
||||
result.As<v8::Function>()->Call(result, 3, args);
|
||||
}
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("createArchive", &Archive::Create);
|
||||
dict.SetMethod("initAsarSupport", &InitAsarSupport);
|
||||
|
|
|
@ -16,12 +16,13 @@ using crash_reporter::CrashReporter;
|
|||
|
||||
namespace mate {
|
||||
|
||||
template<>
|
||||
template <>
|
||||
struct Converter<CrashReporter::UploadReportResult> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const CrashReporter::UploadReportResult& reports) {
|
||||
mate::Dictionary dict(isolate, v8::Object::New(isolate));
|
||||
dict.Set("date", v8::Date::New(isolate, reports.first*1000.0));
|
||||
dict.Set("date", v8::Date::New(isolate, reports.first * 1000.0));
|
||||
dict.Set("id", reports.second);
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
@ -43,8 +44,10 @@ std::map<std::string, std::string> GetParameters() {
|
|||
return CrashReporter::GetInstance()->GetParameters();
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
auto reporter = base::Unretained(CrashReporter::GetInstance());
|
||||
dict.SetMethod("start", base::Bind(&CrashReporter::Start, reporter));
|
||||
|
|
|
@ -50,18 +50,10 @@ struct ScaleFactorPair {
|
|||
};
|
||||
|
||||
ScaleFactorPair kScaleFactorPairs[] = {
|
||||
// The "@2x" is put as first one to make scale matching faster.
|
||||
{ "@2x" , 2.0f },
|
||||
{ "@3x" , 3.0f },
|
||||
{ "@1x" , 1.0f },
|
||||
{ "@4x" , 4.0f },
|
||||
{ "@5x" , 5.0f },
|
||||
{ "@1.25x" , 1.25f },
|
||||
{ "@1.33x" , 1.33f },
|
||||
{ "@1.4x" , 1.4f },
|
||||
{ "@1.5x" , 1.5f },
|
||||
{ "@1.8x" , 1.8f },
|
||||
{ "@2.5x" , 2.5f },
|
||||
// The "@2x" is put as first one to make scale matching faster.
|
||||
{"@2x", 2.0f}, {"@3x", 3.0f}, {"@1x", 1.0f}, {"@4x", 4.0f},
|
||||
{"@5x", 5.0f}, {"@1.25x", 1.25f}, {"@1.33x", 1.33f}, {"@1.4x", 1.4f},
|
||||
{"@1.5x", 1.5f}, {"@1.8x", 1.8f}, {"@2.5x", 2.5f},
|
||||
};
|
||||
|
||||
float GetScaleFactorFromPath(const base::FilePath& path) {
|
||||
|
@ -117,7 +109,7 @@ bool AddImageSkiaRep(gfx::ImageSkia* image,
|
|||
decoded.reset(new SkBitmap);
|
||||
decoded->allocN32Pixels(width, height, false);
|
||||
decoded->setPixels(
|
||||
const_cast<void*>(reinterpret_cast<const void*>(data)));
|
||||
const_cast<void*>(reinterpret_cast<const void*>(data)));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -154,9 +146,8 @@ bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image,
|
|||
succeed |= AddImageSkiaRep(image, path, 1.0f);
|
||||
|
||||
for (const ScaleFactorPair& pair : kScaleFactorPairs)
|
||||
succeed |= AddImageSkiaRep(image,
|
||||
path.InsertBeforeExtensionASCII(pair.name),
|
||||
pair.scale);
|
||||
succeed |= AddImageSkiaRep(
|
||||
image, path.InsertBeforeExtensionASCII(pair.name), pair.scale);
|
||||
return succeed;
|
||||
}
|
||||
|
||||
|
@ -195,9 +186,9 @@ base::win::ScopedHICON ReadICOFromPath(int size, const base::FilePath& path) {
|
|||
}
|
||||
|
||||
// Load the icon from file.
|
||||
return base::win::ScopedHICON(static_cast<HICON>(
|
||||
LoadImage(NULL, image_path.value().c_str(), IMAGE_ICON, size, size,
|
||||
LR_LOADFROMFILE)));
|
||||
return base::win::ScopedHICON(
|
||||
static_cast<HICON>(LoadImage(NULL, image_path.value().c_str(), IMAGE_ICON,
|
||||
size, size, LR_LOADFROMFILE)));
|
||||
}
|
||||
|
||||
bool ReadImageSkiaFromICO(gfx::ImageSkia* image, HICON icon) {
|
||||
|
@ -211,8 +202,7 @@ bool ReadImageSkiaFromICO(gfx::ImageSkia* image, HICON icon) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void Noop(char*, void*) {
|
||||
}
|
||||
void Noop(char*, void*) {}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -221,7 +211,7 @@ NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
|
|||
Init(isolate);
|
||||
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
|
||||
isolate->AdjustAmountOfExternalAllocatedMemory(
|
||||
image_.ToImageSkia()->bitmap()->computeByteSize());
|
||||
image_.ToImageSkia()->bitmap()->computeByteSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,15 +225,15 @@ NativeImage::NativeImage(v8::Isolate* isolate, const base::FilePath& hicon_path)
|
|||
Init(isolate);
|
||||
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
|
||||
isolate->AdjustAmountOfExternalAllocatedMemory(
|
||||
image_.ToImageSkia()->bitmap()->computeByteSize());
|
||||
image_.ToImageSkia()->bitmap()->computeByteSize());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
NativeImage::~NativeImage() {
|
||||
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
|
||||
isolate()->AdjustAmountOfExternalAllocatedMemory(
|
||||
-static_cast<int64_t>(image_.ToImageSkia()->bitmap()->computeByteSize()));
|
||||
isolate()->AdjustAmountOfExternalAllocatedMemory(-static_cast<int64_t>(
|
||||
image_.ToImageSkia()->bitmap()->computeByteSize()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,8 +252,8 @@ HICON NativeImage::GetHICON(int size) {
|
|||
// Then convert the image to ICO.
|
||||
if (image_.IsEmpty())
|
||||
return NULL;
|
||||
hicons_[size] = std::move(
|
||||
IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap()));
|
||||
hicons_[size] =
|
||||
std::move(IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap()));
|
||||
return hicons_[size].get();
|
||||
}
|
||||
#endif
|
||||
|
@ -300,7 +290,8 @@ v8::Local<v8::Value> NativeImage::ToBitmap(mate::Arguments* args) {
|
|||
return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
|
||||
return node::Buffer::Copy(args->isolate(),
|
||||
reinterpret_cast<const char*>(ref->pixels()),
|
||||
bitmap.computeByteSize()).ToLocalChecked();
|
||||
bitmap.computeByteSize())
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
|
||||
|
@ -308,10 +299,10 @@ v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
|
|||
gfx::JPEG1xEncodedDataFromImage(image_, quality, &output);
|
||||
if (output.empty())
|
||||
return node::Buffer::New(isolate, 0).ToLocalChecked();
|
||||
return node::Buffer::Copy(
|
||||
isolate,
|
||||
reinterpret_cast<const char*>(&output.front()),
|
||||
output.size()).ToLocalChecked();
|
||||
return node::Buffer::Copy(isolate,
|
||||
reinterpret_cast<const char*>(&output.front()),
|
||||
output.size())
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
std::string NativeImage::ToDataURL(mate::Arguments* args) {
|
||||
|
@ -338,21 +329,20 @@ v8::Local<v8::Value> NativeImage::GetBitmap(mate::Arguments* args) {
|
|||
return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
|
||||
return node::Buffer::New(args->isolate(),
|
||||
reinterpret_cast<char*>(ref->pixels()),
|
||||
bitmap.computeByteSize(),
|
||||
&Noop,
|
||||
nullptr).ToLocalChecked();
|
||||
bitmap.computeByteSize(), &Noop, nullptr)
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NativeImage::GetNativeHandle(v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
#if defined(OS_MACOSX)
|
||||
if (IsEmpty()) return node::Buffer::New(isolate, 0).ToLocalChecked();
|
||||
if (IsEmpty())
|
||||
return node::Buffer::New(isolate, 0).ToLocalChecked();
|
||||
|
||||
NSImage* ptr = image_.AsNSImage();
|
||||
return node::Buffer::Copy(
|
||||
isolate,
|
||||
reinterpret_cast<char*>(ptr),
|
||||
sizeof(void*)).ToLocalChecked();
|
||||
return node::Buffer::Copy(isolate, reinterpret_cast<char*>(ptr),
|
||||
sizeof(void*))
|
||||
.ToLocalChecked();
|
||||
#else
|
||||
args->ThrowError("Not implemented");
|
||||
return v8::Undefined(isolate);
|
||||
|
@ -376,7 +366,8 @@ float NativeImage::GetAspectRatio() {
|
|||
}
|
||||
|
||||
mate::Handle<NativeImage> NativeImage::Resize(
|
||||
v8::Isolate* isolate, const base::DictionaryValue& options) {
|
||||
v8::Isolate* isolate,
|
||||
const base::DictionaryValue& options) {
|
||||
gfx::Size size = GetSize();
|
||||
int width = size.width();
|
||||
int height = size.height();
|
||||
|
@ -411,8 +402,8 @@ mate::Handle<NativeImage> NativeImage::Resize(
|
|||
|
||||
mate::Handle<NativeImage> NativeImage::Crop(v8::Isolate* isolate,
|
||||
const gfx::Rect& rect) {
|
||||
gfx::ImageSkia cropped = gfx::ImageSkiaOperations::ExtractSubset(
|
||||
image_.AsImageSkia(), rect);
|
||||
gfx::ImageSkia cropped =
|
||||
gfx::ImageSkiaOperations::ExtractSubset(image_.AsImageSkia(), rect);
|
||||
return mate::CreateHandle(isolate,
|
||||
new NativeImage(isolate, gfx::Image(cropped)));
|
||||
}
|
||||
|
@ -434,18 +425,15 @@ void NativeImage::AddRepresentation(const mate::Dictionary& options) {
|
|||
AddImageSkiaRep(
|
||||
&image_skia,
|
||||
reinterpret_cast<unsigned char*>(node::Buffer::Data(buffer)),
|
||||
node::Buffer::Length(buffer),
|
||||
width, height, scale_factor);
|
||||
node::Buffer::Length(buffer), width, height, scale_factor);
|
||||
skia_rep_added = true;
|
||||
} else if (options.Get("dataURL", &url)) {
|
||||
std::string mime_type, charset, data;
|
||||
if (net::DataURL::Parse(url, &mime_type, &charset, &data)) {
|
||||
if (mime_type == "image/png" || mime_type == "image/jpeg") {
|
||||
AddImageSkiaRep(
|
||||
&image_skia,
|
||||
reinterpret_cast<const unsigned char*>(data.c_str()),
|
||||
data.size(),
|
||||
width, height, scale_factor);
|
||||
AddImageSkiaRep(&image_skia,
|
||||
reinterpret_cast<const unsigned char*>(data.c_str()),
|
||||
data.size(), width, height, scale_factor);
|
||||
skia_rep_added = true;
|
||||
}
|
||||
}
|
||||
|
@ -459,8 +447,7 @@ void NativeImage::AddRepresentation(const mate::Dictionary& options) {
|
|||
}
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
void NativeImage::SetTemplateImage(bool setAsTemplate) {
|
||||
}
|
||||
void NativeImage::SetTemplateImage(bool setAsTemplate) {}
|
||||
|
||||
bool NativeImage::IsTemplateImage() {
|
||||
return false;
|
||||
|
@ -473,22 +460,24 @@ mate::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) {
|
|||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::Create(
|
||||
v8::Isolate* isolate, const gfx::Image& image) {
|
||||
mate::Handle<NativeImage> NativeImage::Create(v8::Isolate* isolate,
|
||||
const gfx::Image& image) {
|
||||
return mate::CreateHandle(isolate, new NativeImage(isolate, image));
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromPNG(
|
||||
v8::Isolate* isolate, const char* buffer, size_t length) {
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromPNG(v8::Isolate* isolate,
|
||||
const char* buffer,
|
||||
size_t length) {
|
||||
gfx::Image image = gfx::Image::CreateFrom1xPNGBytes(
|
||||
reinterpret_cast<const unsigned char*>(buffer), length);
|
||||
return Create(isolate, image);
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromJPEG(
|
||||
v8::Isolate* isolate, const char* buffer, size_t length) {
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromJPEG(v8::Isolate* isolate,
|
||||
const char* buffer,
|
||||
size_t length) {
|
||||
gfx::Image image = gfx::ImageFrom1xJPEGEncodedData(
|
||||
reinterpret_cast<const unsigned char*>(buffer), length);
|
||||
return Create(isolate, image);
|
||||
|
@ -496,12 +485,12 @@ mate::Handle<NativeImage> NativeImage::CreateFromJPEG(
|
|||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromPath(
|
||||
v8::Isolate* isolate, const base::FilePath& path) {
|
||||
v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
base::FilePath image_path = NormalizePath(path);
|
||||
#if defined(OS_WIN)
|
||||
if (image_path.MatchesExtension(FILE_PATH_LITERAL(".ico"))) {
|
||||
return mate::CreateHandle(isolate,
|
||||
new NativeImage(isolate, image_path));
|
||||
return mate::CreateHandle(isolate, new NativeImage(isolate, image_path));
|
||||
}
|
||||
#endif
|
||||
gfx::ImageSkia image_skia;
|
||||
|
@ -517,7 +506,8 @@ mate::Handle<NativeImage> NativeImage::CreateFromPath(
|
|||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromBuffer(
|
||||
mate::Arguments* args, v8::Local<v8::Value> buffer) {
|
||||
mate::Arguments* args,
|
||||
v8::Local<v8::Value> buffer) {
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
double scale_factor = 1.;
|
||||
|
@ -535,16 +525,13 @@ mate::Handle<NativeImage> NativeImage::CreateFromBuffer(
|
|||
gfx::ImageSkia image_skia;
|
||||
AddImageSkiaRep(&image_skia,
|
||||
reinterpret_cast<unsigned char*>(node::Buffer::Data(buffer)),
|
||||
node::Buffer::Length(buffer),
|
||||
width,
|
||||
height,
|
||||
scale_factor);
|
||||
node::Buffer::Length(buffer), width, height, scale_factor);
|
||||
return Create(args->isolate(), gfx::Image(image_skia));
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromDataURL(
|
||||
v8::Isolate* isolate, const GURL& url) {
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromDataURL(v8::Isolate* isolate,
|
||||
const GURL& url) {
|
||||
std::string mime_type, charset, data;
|
||||
if (net::DataURL::Parse(url, &mime_type, &charset, &data)) {
|
||||
if (mime_type == "image/png")
|
||||
|
@ -558,14 +545,15 @@ mate::Handle<NativeImage> NativeImage::CreateFromDataURL(
|
|||
|
||||
#if !defined(OS_MACOSX)
|
||||
mate::Handle<NativeImage> NativeImage::CreateFromNamedImage(
|
||||
mate::Arguments* args, const std::string& name) {
|
||||
mate::Arguments* args,
|
||||
const std::string& name) {
|
||||
return CreateEmpty(args->isolate());
|
||||
}
|
||||
#endif
|
||||
|
||||
// static
|
||||
void NativeImage::BuildPrototype(
|
||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
||||
void NativeImage::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "NativeImage"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("toPNG", &NativeImage::ToPNG)
|
||||
|
@ -597,7 +585,8 @@ v8::Local<v8::Value> Converter<mate::Handle<atom::api::NativeImage>>::ToV8(
|
|||
}
|
||||
|
||||
bool Converter<mate::Handle<atom::api::NativeImage>>::FromV8(
|
||||
v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
mate::Handle<atom::api::NativeImage>* out) {
|
||||
// Try converting from file path.
|
||||
base::FilePath path;
|
||||
|
@ -607,8 +596,8 @@ bool Converter<mate::Handle<atom::api::NativeImage>>::FromV8(
|
|||
return !(*out)->image().IsEmpty();
|
||||
}
|
||||
|
||||
WrappableBase* wrapper = static_cast<WrappableBase*>(internal::FromV8Impl(
|
||||
isolate, val));
|
||||
WrappableBase* wrapper =
|
||||
static_cast<WrappableBase*>(internal::FromV8Impl(isolate, val));
|
||||
if (!wrapper)
|
||||
return false;
|
||||
|
||||
|
@ -620,8 +609,10 @@ bool Converter<mate::Handle<atom::api::NativeImage>>::FromV8(
|
|||
|
||||
namespace {
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("createEmpty", &atom::api::NativeImage::CreateEmpty);
|
||||
dict.SetMethod("createFromPath", &atom::api::NativeImage::CreateFromPath);
|
||||
|
|
|
@ -18,12 +18,13 @@
|
|||
|
||||
namespace mate {
|
||||
|
||||
template<>
|
||||
template <>
|
||||
struct Converter<base::win::ShortcutOperation> {
|
||||
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
base::win::ShortcutOperation* out) {
|
||||
std::string operation;
|
||||
if (!ConvertFromV8(isolate, val, & operation))
|
||||
if (!ConvertFromV8(isolate, val, &operation))
|
||||
return false;
|
||||
if (operation.empty() || operation == "create")
|
||||
*out = base::win::SHORTCUT_CREATE_ALWAYS;
|
||||
|
@ -109,8 +110,8 @@ bool WriteShortcutLink(const base::FilePath& shortcut_path,
|
|||
properties.set_app_id(str);
|
||||
|
||||
base::win::ScopedCOMInitializer com_initializer;
|
||||
return base::win::CreateOrUpdateShortcutLink(
|
||||
shortcut_path, properties, operation);
|
||||
return base::win::CreateOrUpdateShortcutLink(shortcut_path, properties,
|
||||
operation);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> ReadShortcutLink(mate::Arguments* args,
|
||||
|
@ -135,8 +136,10 @@ v8::Local<v8::Value> ReadShortcutLink(mate::Arguments* args,
|
|||
}
|
||||
#endif
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
|
||||
dict.SetMethod("openItem", &platform_util::OpenItem);
|
||||
|
|
|
@ -30,7 +30,7 @@ struct hash<std::pair<Type1, Type2>> {
|
|||
|
||||
namespace mate {
|
||||
|
||||
template<typename Type1, typename Type2>
|
||||
template <typename Type1, typename Type2>
|
||||
struct Converter<std::pair<Type1, Type2>> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
|
@ -96,15 +96,17 @@ void TakeHeapSnapshot(v8::Isolate* isolate) {
|
|||
|
||||
void RequestGarbageCollectionForTesting(v8::Isolate* isolate) {
|
||||
isolate->RequestGarbageCollectionForTesting(
|
||||
v8::Isolate::GarbageCollectionType::kFullGarbageCollection);
|
||||
v8::Isolate::GarbageCollectionType::kFullGarbageCollection);
|
||||
}
|
||||
|
||||
bool IsSameOrigin(const GURL& l, const GURL& r) {
|
||||
return url::Origin(l).IsSameOriginWith(url::Origin(r));
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("getHiddenValue", &GetHiddenValue);
|
||||
dict.SetMethod("setHiddenValue", &SetHiddenValue);
|
||||
|
|
|
@ -22,7 +22,9 @@ namespace atom {
|
|||
namespace {
|
||||
|
||||
// Dummy class type that used for crashing the program.
|
||||
struct DummyClass { bool crash; };
|
||||
struct DummyClass {
|
||||
bool crash;
|
||||
};
|
||||
|
||||
// Called when there is a fatal error in V8, we just crash the process here so
|
||||
// we can get the stack trace.
|
||||
|
@ -33,7 +35,6 @@ void FatalErrorCallback(const char* location, const char* message) {
|
|||
|
||||
} // namespace
|
||||
|
||||
|
||||
AtomBindings::AtomBindings(uv_loop_t* loop) {
|
||||
uv_async_init(loop, &call_next_tick_async_, OnCallNextTick);
|
||||
call_next_tick_async_.data = this;
|
||||
|
@ -44,8 +45,7 @@ AtomBindings::~AtomBindings() {
|
|||
uv_close(reinterpret_cast<uv_handle_t*>(&call_next_tick_async_), nullptr);
|
||||
}
|
||||
|
||||
void AtomBindings::BindTo(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> process) {
|
||||
void AtomBindings::BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process) {
|
||||
v8::V8::SetFatalErrorHandler(FatalErrorCallback);
|
||||
|
||||
mate::Dictionary dict(isolate, process);
|
||||
|
@ -54,14 +54,14 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
|
|||
dict.SetMethod("log", &Log);
|
||||
dict.SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo);
|
||||
dict.SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo);
|
||||
dict.SetMethod("getCPUUsage",
|
||||
base::Bind(&AtomBindings::GetCPUUsage, base::Unretained(this)));
|
||||
dict.SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage,
|
||||
base::Unretained(this)));
|
||||
dict.SetMethod("getIOCounters", &GetIOCounters);
|
||||
#if defined(OS_POSIX)
|
||||
dict.SetMethod("setFdLimit", &base::SetFdLimit);
|
||||
#endif
|
||||
dict.SetMethod("activateUvLoop",
|
||||
base::Bind(&AtomBindings::ActivateUVLoop, base::Unretained(this)));
|
||||
dict.SetMethod("activateUvLoop", base::Bind(&AtomBindings::ActivateUVLoop,
|
||||
base::Unretained(this)));
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
dict.Set("mas", true);
|
||||
|
@ -76,8 +76,8 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
|
|||
}
|
||||
|
||||
void AtomBindings::EnvironmentDestroyed(node::Environment* env) {
|
||||
auto it = std::find(pending_next_ticks_.begin(), pending_next_ticks_.end(),
|
||||
env);
|
||||
auto it =
|
||||
std::find(pending_next_ticks_.begin(), pending_next_ticks_.end(), env);
|
||||
if (it != pending_next_ticks_.end())
|
||||
pending_next_ticks_.erase(it);
|
||||
}
|
||||
|
@ -102,9 +102,7 @@ void AtomBindings::OnCallNextTick(uv_async_t* handle) {
|
|||
mate::Locker locker(env->isolate());
|
||||
v8::Context::Scope context_scope(env->context());
|
||||
node::InternalCallbackScope scope(
|
||||
env,
|
||||
v8::Local<v8::Object>(),
|
||||
{0, 0},
|
||||
env, v8::Local<v8::Object>(), {0, 0},
|
||||
node::InternalCallbackScope::kAllowEmptyResource);
|
||||
}
|
||||
|
||||
|
@ -149,7 +147,7 @@ v8::Local<v8::Value> AtomBindings::GetProcessMemoryInfo(v8::Isolate* isolate) {
|
|||
|
||||
// static
|
||||
v8::Local<v8::Value> AtomBindings::GetSystemMemoryInfo(v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
mate::Arguments* args) {
|
||||
base::SystemMemoryInfoKB mem_info;
|
||||
if (!base::GetSystemMemoryInfo(&mem_info)) {
|
||||
args->ThrowError("Unable to retrieve system memory information");
|
||||
|
|
|
@ -20,9 +20,8 @@ v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate,
|
|||
v8::MicrotasksScope::kRunMicrotasks);
|
||||
// Use node::MakeCallback to call the callback, and it will also run pending
|
||||
// tasks in Node.js.
|
||||
v8::MaybeLocal<v8::Value> ret = node::MakeCallback(isolate, obj, method,
|
||||
args->size(),
|
||||
&args->front(), {0, 0});
|
||||
v8::MaybeLocal<v8::Value> ret = node::MakeCallback(
|
||||
isolate, obj, method, args->size(), &args->front(), {0, 0});
|
||||
// If the JS function throws an exception (doesn't return a value) the result
|
||||
// of MakeCallback will be empty and therefore ToLocal will be false, in this
|
||||
// case we need to return "false" as that indicates that the event emitter did
|
||||
|
|
|
@ -11,7 +11,6 @@ Locker::Locker(v8::Isolate* isolate) {
|
|||
locker_.reset(new v8::Locker(isolate));
|
||||
}
|
||||
|
||||
Locker::~Locker() {
|
||||
}
|
||||
Locker::~Locker() {}
|
||||
|
||||
} // namespace mate
|
||||
|
|
|
@ -12,8 +12,7 @@ namespace atom {
|
|||
|
||||
ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> target)
|
||||
: target_(isolate, target),
|
||||
weak_ptr_factory_(this) {
|
||||
: target_(isolate, target), weak_ptr_factory_(this) {
|
||||
target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,9 @@ RemoteCallbackFreer::RemoteCallbackFreer(v8::Isolate* isolate,
|
|||
content::WebContents* web_contents)
|
||||
: ObjectLifeMonitor(isolate, target),
|
||||
content::WebContentsObserver(web_contents),
|
||||
object_id_(object_id) {
|
||||
}
|
||||
object_id_(object_id) {}
|
||||
|
||||
RemoteCallbackFreer::~RemoteCallbackFreer() {
|
||||
}
|
||||
RemoteCallbackFreer::~RemoteCallbackFreer() {}
|
||||
|
||||
void RemoteCallbackFreer::RunDestructor() {
|
||||
base::string16 channel =
|
||||
|
|
|
@ -27,13 +27,15 @@ content::RenderFrame* GetCurrentRenderFrame() {
|
|||
} // namespace
|
||||
|
||||
// static
|
||||
void RemoteObjectFreer::BindTo(
|
||||
v8::Isolate* isolate, v8::Local<v8::Object> target, int object_id) {
|
||||
void RemoteObjectFreer::BindTo(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> target,
|
||||
int object_id) {
|
||||
new RemoteObjectFreer(isolate, target, object_id);
|
||||
}
|
||||
|
||||
RemoteObjectFreer::RemoteObjectFreer(
|
||||
v8::Isolate* isolate, v8::Local<v8::Object> target, int object_id)
|
||||
RemoteObjectFreer::RemoteObjectFreer(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> target,
|
||||
int object_id)
|
||||
: ObjectLifeMonitor(isolate, target),
|
||||
object_id_(object_id),
|
||||
routing_id_(MSG_ROUTING_NONE) {
|
||||
|
@ -43,8 +45,7 @@ RemoteObjectFreer::RemoteObjectFreer(
|
|||
}
|
||||
}
|
||||
|
||||
RemoteObjectFreer::~RemoteObjectFreer() {
|
||||
}
|
||||
RemoteObjectFreer::~RemoteObjectFreer() {}
|
||||
|
||||
void RemoteObjectFreer::RunDestructor() {
|
||||
content::RenderFrame* render_frame =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue