This helped me to understand how to implement native host for Chrome, however, the whole reason I'm going this way is that I can have one shared state where I can store data and send/request back and forth between host and extension running in multiple Chrome Windows.
So naturally comes the question of read/write locks and syncing request. The example above uses stdin in a way I'm not familiar with. How would I ensure data integrity and prevent possible case when another request is send in-between while first one is being processed? I can implement R/W lock ad mutexes on the native part, but the communication part with Chrome is what confuses me. Because extension instances can run on a completely separate Chrome windows instances (and potentially one vanilla Chromium), I can't implement any kind of syncing on this side.