Put all writes in queue; use queue to handle HTTP

This commit includes some fancy promise/deferred footwork. Basically,
when you make a request that isn't a GET, the following happens:

1. The body of the request (postData) goes in the cache corresponding
   to that resource instance. If the request doesn't succeed, we can
   still return this data for GET requests against the same instance,
   and when we regain connectivity, we use this cache to get/send the
   postData again.

2. The metadata of the request (the resource's "action" and the URL
   parameters of the resource instance) gets added to a queue
   corresponding to the resource, unless a pending request against that
   resource instance is already in the queue.

3. We return a resource object, with a $promise and a $resolved flag.
   If the resource is successfully saved at any point, the $promise will
   be resolved. (Along with any other promises associated with that same
   resource instance and action. In other words, if you call the same
   action repeatedly on the same resource instance while the browser is
   offline, then when the browser goes online only one request will be
   made, but all the promises for all the requests will immediately be
   resolved.)

4. We "flush" the queue, which takes all the outstanding requests in the
   queue and attempts to send them.
When browser reports an "online" event, flush caches