AU: Watch for writes on write fds only, and for reads on read fds.

This reduces the CPU load from 100% to 0% when staying idle waiting for a server
response.

BUG=8200
TEST=unit tests, tested on device

Change-Id: I07216076753b4b0dea9672470f1a6d572482f9a2

Review URL: http://codereview.chromium.org/4190009
diff --git a/libcurl_http_fetcher.h b/libcurl_http_fetcher.h
index 25c4e49..3a50bda 100644
--- a/libcurl_http_fetcher.h
+++ b/libcurl_http_fetcher.h
@@ -147,10 +147,12 @@
   CURLM *curl_multi_handle_;
   CURL *curl_handle_;
 
-  // a list of all file descriptors that we're waiting on from the
-  // glib main loop
+  // Lists of all read(0)/write(1) file descriptors that we're waiting on from
+  // the glib main loop. libcurl may open/close descriptors and switch their
+  // directions so maintain two separate lists so that watch conditions can be
+  // set appropriately.
   typedef std::map<int, std::pair<GIOChannel*, guint> > IOChannels;
-  IOChannels io_channels_;
+  IOChannels io_channels_[2];
 
   // if non-NULL, a timer we're waiting on. glib main loop will call us back
   // when it fires.