aboutsummaryrefslogtreecommitdiffstats
path: root/extension
diff options
context:
space:
mode:
authorOmar Rizwan <omar.rizwan@gmail.com>2018-11-24 10:58:33 -0800
committerOmar Rizwan <omar.rizwan@gmail.com>2018-11-24 10:58:33 -0800
commite734173e6f5df2fc9df39dc8b98a03e8b83d889f (patch)
treef2cf6ad37765b04759e072b5470fb0dc185f62c0 /extension
parentc8fad64066650ed6089bf3bf39dbf3f5389f3a04 (diff)
URL and title kind of work.
direct_io option makes it reliably change. Big speedup from... removing prints. Did I even need multithreading?
Diffstat (limited to 'extension')
-rw-r--r--extension/background.js40
1 files changed, 23 insertions, 17 deletions
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));