Rob--W / browser-action-jplib

Jetpack module to add a Browser action badge to the toolbar, using the chrome.browserAction syntax from Chromium
21 stars 9 forks source link

make messageID from sendMessage() 100% unique per thread #16

Closed duzun closed 9 years ago

duzun commented 9 years ago

I know the chances two different messages will have same ID using messageID = Math.random() are close to 0%, but as the application runs and there are more and more messages, the collision probability increases.

I added a counter variable _unique_id_ to make sure messageID is unique per thread/module. The random part make it unique at Add-on level.

P.S. Sorry for extra lines touched, my editor removes trailing white spaces.

Rob--W commented 9 years ago

Thanks for the patches! If you have more spare time, it would be awesome if you update browser-action-jplib to use the sdk/ui APIs when they are available.