From e734173e6f5df2fc9df39dc8b98a03e8b83d889f Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Sat, 24 Nov 2018 10:58:33 -0800 Subject: URL and title kind of work. direct_io option makes it reliably change. Big speedup from... removing prints. Did I even need multithreading? --- extension/background.js | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'extension') diff --git a/extension/background.js b/extension/background.js index 1b2b5cc..25575ca 100644 --- a/extension/background.js +++ b/extension/background.js @@ -88,25 +88,31 @@ const router = { }; }, async open(path) { - return fhManager.allocate(await getTab(parseInt(pathComponent(path, -2)))); + return 0; }, async read(path, fh, size, offset) { - const tab = fhManager.ref(fh); - return tab.url.substr(offset, size); + const tab = await getTab(parseInt(pathComponent(path, -2))); + return (tab.url + "\n").substr(offset, size); }, - async release(path, fh) { - fhManager.free(fh); - } + async release(path, fh) {} + }, + "title": { + async getattr() { + return { + st_mode: unix.S_IFREG | 0444, + st_nlink: 1, + st_size: 1000 // FIXME + }; + }, + async open(path) { + return 0; + }, + async read(path, fh, size, offset) { + const tab = await getTab(parseInt(pathComponent(path, -2))); + return (tab.title + "\n").substr(offset, size); + }, + async release(path, fh) {} }, - /* "title": fileFromProperty('title'), - * "sources": folderFromResource( - * (tab, path) => new Promise(resolve => chrome.debugger.attach( - * { tabId: tab.id }, "1-3", resolve)), - * { - * readdir() { - - * } - * }*/ } } } @@ -160,7 +166,7 @@ ws.onmessage = async function(event) { const req = JSON.parse(event.data); let response = { op: req.op, error: unix.EIO }; - console.time(req.op + ':' + req.path); + /* console.time(req.op + ':' + req.path);*/ try { if (req.op === 'getattr') { response = { @@ -202,7 +208,7 @@ ws.onmessage = async function(event) { error: e instanceof UnixError ? e.error : unix.EIO } } - console.timeEnd(req.op + ':' + req.path); + /* console.timeEnd(req.op + ':' + req.path);*/ response.id = req.id; ws.send(JSON.stringify(response)); -- cgit v1.2.3