Make Enable/Disable work using new callbacks for async support.

Use new-style callbacks to implement the Manager EnableTechnology
and DisableTechnology operations asynchronously. This allows
devices to be enabled and disabled from the UI ,and for the UI
to display available networks once the device is enabled.

Removed the behavior whereby setting the Device.Powered property
had the side effect of enabling or disabling the device. To
replace this, I added new Device.Enable and Device.Disable calls
for enabling and disabling individual devices.

Also separated the in-memory value of the Powered property from
the persisted value. Whenever a client requests that a device
be enabled or disabled, the desired power state is immediately
saved in the profile, but the in-memory value isn't updated until
the operation completes. On startup, shill now automatically
starts any devices for which the persistent Powered property
is set, and does not start devices for which it is not set.

BUG=chromium-os:23319,chromium-os:27814
TEST=Manual testing on device + unit tests passing.

Change-Id: Id676be3fc662cfd5efb730c67687edfd16b2dc6b
Reviewed-on: https://gerrit.chromium.org/gerrit/18123
Commit-Ready: Eric Shienbrood <ers@chromium.org>
Reviewed-by: Eric Shienbrood <ers@chromium.org>
Tested-by: Eric Shienbrood <ers@chromium.org>
diff --git a/http_proxy.cc b/http_proxy.cc
index 5aa1f9e..3d2fd0c 100644
--- a/http_proxy.cc
+++ b/http_proxy.cc
@@ -29,7 +29,6 @@
 
 using base::Bind;
 using base::StringPrintf;
-using base::Unretained;
 using std::string;
 using std::vector;
 
@@ -56,14 +55,20 @@
     : state_(kStateIdle),
       connection_(connection),
       weak_ptr_factory_(this),
-      accept_callback_(Bind(&HTTPProxy::AcceptClient, Unretained(this))),
+      accept_callback_(Bind(&HTTPProxy::AcceptClient,
+                            weak_ptr_factory_.GetWeakPtr())),
       connect_completion_callback_(Bind(&HTTPProxy::OnConnectCompletion,
-                                        Unretained(this))),
-      dns_client_callback_(Bind(&HTTPProxy::GetDNSResult, Unretained(this))),
-      read_client_callback_(Bind(&HTTPProxy::ReadFromClient, Unretained(this))),
-      read_server_callback_(Bind(&HTTPProxy::ReadFromServer, Unretained(this))),
-      write_client_callback_(Bind(&HTTPProxy::WriteToClient, Unretained(this))),
-      write_server_callback_(Bind(&HTTPProxy::WriteToServer, Unretained(this))),
+                                        weak_ptr_factory_.GetWeakPtr())),
+      dns_client_callback_(Bind(&HTTPProxy::GetDNSResult,
+                                weak_ptr_factory_.GetWeakPtr())),
+      read_client_callback_(Bind(&HTTPProxy::ReadFromClient,
+                                 weak_ptr_factory_.GetWeakPtr())),
+      read_server_callback_(Bind(&HTTPProxy::ReadFromServer,
+                                 weak_ptr_factory_.GetWeakPtr())),
+      write_client_callback_(Bind(&HTTPProxy::WriteToClient,
+                                  weak_ptr_factory_.GetWeakPtr())),
+      write_server_callback_(Bind(&HTTPProxy::WriteToServer,
+                                  weak_ptr_factory_.GetWeakPtr())),
       dispatcher_(NULL),
       dns_client_(NULL),
       proxy_port_(-1),