My system drive in my mac mini crashed again and so I need a new computer. I shopped around, I think I'll get a zareason machine with Ubuntu. I was thinking about system76 too but zareason supports more kinds of OS and I take that as an evidence that their machines are more widely compatible and they're not just supplying their own drivers that won't exist in an ubuntu update!
maybe not.
So I was right at the edge of finding out why my callback system wasn't working. The short version (I was keeping notes in wiki pages, you'll never read them, at github... ok, short version: I had been saving information happilly in the IndexedDB (iDB from now on) from the content script which saved it in the domain based namespace of the site the content script was working with. This data was not available to background no other pages (e.g. extension pages I might launch, such as summaries or extra features beyond what the content script (or popup or settings) offers).
The content script was using the novem _njn object to do this so I have altered _njn to be able to send a message to another "process" (which is how each of these "pages" acts within the context of the extension), to store and retrieve objects from the iDB. This way the background.js process (it's the logical choice though anything could do it... problem being nothing else is always around) can store and retrieve data from the iDB transparently to the code in the content script or anyone using the _njn in some mode the name of which I've already forgotten. "Send_to_background" I think.
Anyway doing a call is simple, so the saves went rapidly, but handling callbacks, which are asynchronous are more difficult. They shouldn't be too difficult, I found out my problem was that there is a .sendMessage in chrome.runtime and in chrome.tabs and I had to use the latter to send messages back to the tab (of course, I just hadn't noticed the two versions). Also difficult is all the deferred action. Now I have to deal with simulating the return even from _njn running in the content script, loading the object correctly and whatnot. It's not at all normalized and generalized, my goal is just to get a working system that allows everything to work as it had before and also make a simple summary page.
Maybe the system will work better letting the background do the relatively slow iDB queries, but I don't know that.
Another thing is it's just kind of confusing refactoring like this, with messages between processes.
No comments:
Post a Comment