Fix potential corruption/leak in cookiejar. The flush() method of the cookie jar can be accessed from different threads. This method (eventually) creates a NewRunnableTask and a callback on FlushSemaphore object. Therefore FlushSemaphore should inherit from a ThreadSafe ref counter rather than a simple base ref counter. Change-Id: Ie6914fba9b1554081c4b3b5992661af066e23653