[Invalidations] Require there to be no registered handlers on Invalidator destruction

Add CHECK to catch sloppy clients.

Make ProfileSyncService destroy its invalidator registrar on shut down (also to catch
sloppy clients).  Comment on expected usage of Initialize() and Shutdown(),
and add DCHECKs for them.

Fix Invalidator test template to unregister handlers properly.  Also fix some ProfileSyncService tests.

BUG=137086
[email protected],[email protected]

Review URL: https://codereview.chromium.org/11046008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160420 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/sync/invalidation_frontend.h b/chrome/browser/sync/invalidation_frontend.h
index 3076b61..6f19b73 100644
--- a/chrome/browser/sync/invalidation_frontend.h
+++ b/chrome/browser/sync/invalidation_frontend.h
@@ -47,6 +47,12 @@
 // It can also do the above in OnInvalidatorStateChange(), or it can use the
 // argument to OnInvalidatorStateChange().
 //
+// It is an error to have registered handlers when an
+// InvalidationFrontend is shut down; clients must ensure that they
+// unregister themselves before then. (Depending on the
+// InvalidationFrontend, shutdown may be equivalent to destruction, or
+// a separate function call like Shutdown()).
+//
 // NOTE(akalin): Invalidations that come in during browser shutdown may get
 // dropped.  This won't matter once we have an Acknowledge API, though: see
 // http://crbug.com/78462 and http://crbug.com/124149.