Get rid of the ATOM_BROWSER_RELEASE_RENDER_VIEW event
This commit is contained in:
parent
593a79ce20
commit
6753fcc1b4
3 changed files with 10 additions and 19 deletions
|
@ -485,17 +485,7 @@ void WebContents::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
|
|||
}
|
||||
|
||||
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
|
||||
int process_id = render_view_host->GetProcess()->GetID();
|
||||
Emit("render-view-deleted", process_id);
|
||||
|
||||
// process.emit('ATOM_BROWSER_RELEASE_RENDER_VIEW', processId);
|
||||
// Tell the rpc server that a render view has been deleted and we need to
|
||||
// release all objects owned by it.
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
node::Environment* env = node::Environment::GetCurrent(isolate());
|
||||
mate::EmitEvent(isolate(), env->process_object(),
|
||||
"ATOM_BROWSER_RELEASE_RENDER_VIEW", process_id);
|
||||
Emit("render-view-deleted", render_view_host->GetProcess()->GetID());
|
||||
}
|
||||
|
||||
void WebContents::RenderProcessGone(base::TerminationStatus status) {
|
||||
|
|
|
@ -17,14 +17,20 @@ class ObjectsRegistry {
|
|||
|
||||
// Register a new object and return its assigned ID. If the object is already
|
||||
// registered then the already assigned ID would be returned.
|
||||
add(webContentsId, obj) {
|
||||
add(webContents, obj) {
|
||||
// Get or assign an ID to the object.
|
||||
let id = this.saveToStorage(obj);
|
||||
|
||||
// Add object to the set of referenced objects.
|
||||
let webContentsId = webContents.getId();
|
||||
let owner = this.owners[webContentsId];
|
||||
if (!owner)
|
||||
if (!owner) {
|
||||
owner = this.owners[webContentsId] = new Set();
|
||||
// Clear the storage when webContents is reloaded/navigated.
|
||||
webContents.once('render-view-deleted', (event, id) => {
|
||||
this.clear(id);
|
||||
});
|
||||
}
|
||||
if (!owner.has(id)) {
|
||||
owner.add(id);
|
||||
// Increase reference count if not referenced before.
|
||||
|
|
|
@ -100,7 +100,7 @@ var valueToMeta = function(sender, value, optimizeSimpleObject) {
|
|||
// Reference the original value if it's an object, because when it's
|
||||
// passed to renderer we would assume the renderer keeps a reference of
|
||||
// it.
|
||||
meta.id = objectsRegistry.add(sender.getId(), value);
|
||||
meta.id = objectsRegistry.add(sender, value);
|
||||
meta.members = getObjectMemebers(value);
|
||||
meta.proto = getObjectPrototype(value);
|
||||
} else if (meta.type === 'buffer') {
|
||||
|
@ -239,11 +239,6 @@ var callFunction = function(event, func, caller, args) {
|
|||
}
|
||||
};
|
||||
|
||||
// Send by BrowserWindow when its render view is deleted.
|
||||
process.on('ATOM_BROWSER_RELEASE_RENDER_VIEW', function(id) {
|
||||
return objectsRegistry.clear(id);
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_REQUIRE', function(event, module) {
|
||||
try {
|
||||
return event.returnValue = valueToMeta(event.sender, process.mainModule.require(module));
|
||||
|
|
Loading…
Reference in a new issue