Merge pull request #9222 from alexstrat/add-os-process-id

Add OS pid to web-contents
This commit is contained in:
Kevin Sawicki 2017-05-15 13:28:47 -07:00 committed by GitHub
commit d79ac8d9c1
4 changed files with 27 additions and 0 deletions

View file

@ -41,6 +41,7 @@
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "base/process/process_handle.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "brightray/browser/inspectable_web_contents.h"
@ -1007,6 +1008,11 @@ int WebContents::GetProcessID() const {
return web_contents()->GetRenderProcessHost()->GetID();
}
int WebContents::GetOSProcessID() const {
auto process_handle = web_contents()->GetRenderProcessHost()->GetHandle();
return base::GetProcId(process_handle);
}
WebContents::Type WebContents::GetType() const {
return type_;
}
@ -1754,6 +1760,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.MakeDestroyable()
.SetMethod("getId", &WebContents::GetID)
.SetMethod("getProcessId", &WebContents::GetProcessID)
.SetMethod("getOSProcessId", &WebContents::GetOSProcessID)
.SetMethod("equal", &WebContents::Equal)
.SetMethod("_loadURL", &WebContents::LoadURL)
.SetMethod("downloadURL", &WebContents::DownloadURL)