reduce cookie tracking (1/4): add a way to count cookies

the HasCookies call was implemented by counting all cookies and then
returning true or false. replace HasCookies functionality by a wrapper
around CountCookies, and allow CountCookies to be called from java.

Change-Id: I863a7f683c617bd5026fbe4909a0e5cd52f0a8e3