Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #9989 from brave/shared-mem-app-state
Browse files Browse the repository at this point in the history
use shared memory for initial state transfer
  • Loading branch information
bbondy authored Jul 17, 2017
2 parents 316d86d + e009588 commit 8c60084
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions js/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ window.addEventListener('beforeunload', function (e) {
ipc.send(messages.LAST_WINDOW_STATE, windowStore.getState().toJS())
})

ipc.on(messages.INITIALIZE_WINDOW, (e, windowValue, appState, frames, windowState) => {
ipc.on(messages.INITIALIZE_WINDOW, (e, mem) => {
const message = mem.memory()
const windowValue = message.windowValue

currentWindow.setWindowId(windowValue.id)
const newState = Immutable.fromJS(windowState) || windowStore.getState()
const newState = Immutable.fromJS(message.windowState) || windowStore.getState()

appStoreRenderer.state = Immutable.fromJS(appState)
appStoreRenderer.state = Immutable.fromJS(message.appState)
windowStore.state = newState
generateTabs(newState, frames, windowValue.id)
generateTabs(newState, message.frames, windowValue.id)
appActions.windowReady(windowValue.id)
ReactDOM.render(<Window />, document.getElementById('appContainer'))
})
Expand Down
11 changes: 7 additions & 4 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,17 @@ const createWindow = (action) => {
mainWindow.webContents.on('did-finish-load', (e) => {
lastEmittedState = appState
mainWindow.webContents.setZoomLevel(zoomLevel[toolbarUserInterfaceScale] || 0.0)
e.sender.send(messages.INITIALIZE_WINDOW,
{

const mem = muon.shared_memory.create({
windowValue: {
disposition: frameOpts.disposition,
id: mainWindow.id
},
appState.toJS(),
appState: appState.toJS(),
frames,
action.restoredState)
windowState: action.restoredState})

e.sender.sendShared(messages.INITIALIZE_WINDOW, mem)
if (action.cb) {
action.cb()
}
Expand Down

0 comments on commit 8c60084

Please sign in to comment.