apmanager: expose service state through DBus

Update AP service state based on the input from hostapd monitor.
We assume hostapd failed to start when the hostapd control interface
does not get created within a reasonable time, and it is started
once the control interface is detected.

While there, update the HostapdMonitor to use WeakPtr for the tasks
that it will post, so those tasks won't run after HostapdMonitor is
destructed.

BUG=chromium:454863
TEST=Run apmanager_CheckAPProcesses
Manual Test:
1. Start an AP service
2. Verify AP service is in "Started" state using dbus-send command.
3. Stop the AP service, verify it is in "Idle" state using dbus-send
   command.

Change-Id: Id6e22e9e15cd8ef815cc81ef6ae8a00e066b958b
Reviewed-on: https://chromium-review.googlesource.com/245830
Tested-by: Zeping Qiu <zqiu@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
diff --git a/service.h b/service.h
index a290533..f2eec5b 100644
--- a/service.h
+++ b/service.h
@@ -46,6 +46,10 @@
   static const char kHostapdConfigPathFormat[];
   static const char kHostapdControlInterfacePath[];
   static const int kTerminationTimeoutSeconds;
+  static const char kStateIdle[];
+  static const char kStateStarting[];
+  static const char kStateStarted[];
+  static const char kStateFailed[];
 
   // Return true if hostapd process is currently running.
   bool IsHostapdRunning();