Add backpressure to web_proxy

Implement things such that the client will send back what it has
currently processed on a given channel. The server will then avoid
sending more than 10000 messages ahead of that point.

Also, fix up some memory management to ensure that data channels
actually get closed/destroyed at the end of a browser session.

Change-Id: Id1795d7496f410332407624a559d6a16a1698702
Signed-off-by: James Kuszmaul <jabukuszmaul@gmail.com>
diff --git a/aos/network/rawrtc.h b/aos/network/rawrtc.h
index 3f37435..4c61313 100644
--- a/aos/network/rawrtc.h
+++ b/aos/network/rawrtc.h
@@ -44,7 +44,7 @@
 //    on_close callback and shuts down the channel.
 class ScopedDataChannel {
  public:
-  ScopedDataChannel();
+  static std::shared_ptr<ScopedDataChannel> MakeDataChannel();
   ScopedDataChannel(const ScopedDataChannel &) = delete;
   ScopedDataChannel &operator=(const ScopedDataChannel &) = delete;
 
@@ -90,6 +90,7 @@
   uint64_t buffered_amount();
 
  private:
+  ScopedDataChannel();
   // Trampolines from C -> C++.
   static void StaticDataChannelOpenHandler(void *const arg);
   static void StaticBufferedAmountLowHandler(void *const arg);