By accident (well research) we discovered NPNVisOfflineBool. If we can NPN_GetValue for it and passing a NULL for the NPP instance, our problem is solved.
Andrei On Fri, Mar 6, 2009 at 12:40 PM, Andrei Popescu <[email protected]> wrote: > On Fri, Mar 6, 2009 at 1:19 AM, Michael Nordman <[email protected]> wrote: >>> Ah! well, because it actually seems to make a difference on mobile -- >>> we have at least one case of a webapp using gears that has large >>> manifests, and the update seems to slow everything down until the >>> network connection attempts timeout... as we can know if we have >>> network access or not, it makes sense to take advantage of that >>> information to be more efficient when we can, I think. >> >> I see. >> >>>>> Uh... I'm not sure I understand -- AsyncTasks can span multiple page >>>>> navigations ? >>>> >>>> NPN_GetValue takes an NPP instance as a parameter. AsyncTasks can run >>>> where there are no NPP instances. >>> >>> Yes, in that case we simply consider that we are online, and attempt >>> the connection. >> >> AsyncTasks started via one NPP instance can outlive the NPP instance >> that started it. I think NPN_GetValue may get called with a dangling >> pointer in that case? >> >> >> Some ideas... >> >> * Can android be modified to support NPN_GetValue(NULL, >> NPNVOnline_Android, &result) callable from any thread? >> >> * Sounds like ApacheHttpRequestAndroid doesn't know about online or >> not. Would it be possible to modify that class do know about this >> state? Would be closer to the root of the issue i think. >> > > Thinking about it more, I believe that this is the right solution. We > discussed doing this initially but discarded it since we thought we > don't have access to the 'android.content.Context' object (required to > get a handle to system services such as the network manager) when > we're inside a worker. However, we forgot we had already solved this > problem with the WebViewManager class. > > The only problem is with update tasks that are fired as a result of > Gears serving resources from a managed resource store. This can happen > without the application ever making any call to Gears (gears_init.js > is not even parsed by the browser at that point) so we don't have any > NPP instances to poke at. > > The only solution I see (without modifying the browser in any way) is > to somehow get the jobject corresponding to the network manager in > NP_Initialize(), and then cache it as a global variable. We can then > pass it to the ApacheHttpRequestAndroid whenever we need. > > Thanks, > Andrei >
