Stub out request handlers for Binder

Change-Id: I1c40467cf8115db429703b0fa9199c8ccbb174fd
Test: Build continues to pass in binder mode
Bug: 26914456
diff --git a/aidl/android/webservd/IProtocolHandler.aidl b/aidl/android/webservd/IProtocolHandler.aidl
index ba96285..0e6e91d 100644
--- a/aidl/android/webservd/IProtocolHandler.aidl
+++ b/aidl/android/webservd/IProtocolHandler.aidl
@@ -18,10 +18,20 @@
 
 interface IProtocolHandler {
   // Add a new request handler. See aidl/android/webservd/IRequestHandler.aidl
-  void AddRequestHandler(in IRequestHandler handler);
-  void RemoveRequestHandler(in IRequestHandler handler);
+  @utf8InCpp String AddRequestHandler(in @utf8InCpp String url,
+                                      in @utf8InCpp String method,
+                                      in IRequestHandler handler);
+
+  // Remove a request handler.
+  void RemoveRequestHandler(in @utf8InCpp String guid);
+
+  // Get the name of this protocol handler.
   @utf8InCpp String GetName();
+
+  // Get the port this protocol handler operates on.
   int GetPort();
+
+  // Get the name of the protocol this handler handles.
   @utf8InCpp String GetProtocol();
 
   // Get the certificate fingerprint of this handler, empty if this handler
diff --git a/aidl/android/webservd/IRequestHandler.aidl b/aidl/android/webservd/IRequestHandler.aidl
index 529a54b..49d1351 100644
--- a/aidl/android/webservd/IRequestHandler.aidl
+++ b/aidl/android/webservd/IRequestHandler.aidl
@@ -18,10 +18,6 @@
 import android.webservd.HttpRequest;
 
 interface IRequestHandler {
-  // Get the request methods that are handled by this handler. An empty return
-  // means handle all methods.
-  @utf8InCpp String[] GetMethods();
-
   // Process a request with this handler.
   oneway
   void ProcessRequest(in HttpRequest request);
diff --git a/webservd/binder_server.cc b/webservd/binder_server.cc
index 561fc41..5bfe5e1 100644
--- a/webservd/binder_server.cc
+++ b/webservd/binder_server.cc
@@ -12,13 +12,13 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include <set>
-
 #include "webservd/binder_server.h"
 #include "webservd/protocol_handler.h"
+#include "webservd/request_handler_interface.h"
 #include "android/webservd/BnProtocolHandler.h"
 
 using android::sp;
+using android::String8;
 
 using android::binder::Status;
 
@@ -32,6 +32,21 @@
 
 namespace webservd {
 namespace {
+
+class BinderRequestHandler : public RequestHandlerInterface {
+ public:
+  BinderRequestHandler(const sp<IRequestHandler>& handler)
+      : handler_(handler) {}
+
+  void HandleRequest(Request* /*request*/) {
+  }
+
+ private:
+  sp<IRequestHandler> handler_;
+
+  DISALLOW_COPY_AND_ASSIGN(BinderRequestHandler);
+};
+
 class BinderProtocolHandler : public android::webservd::BnProtocolHandler {
  public:
   BinderProtocolHandler(string name, BinderServer* server)
@@ -41,14 +56,22 @@
     return impl_.Start(config);
   }
 
-  Status AddRequestHandler(const sp<IRequestHandler>& handler) override {
-    handlers_.insert(handler);
+  Status AddRequestHandler(const string& url, const string& method,
+                           const sp<IRequestHandler>& handler, string* ret)
+        override {
+    *ret = impl_.AddRequestHandler(url, method,
+        unique_ptr<RequestHandlerInterface>(new BinderRequestHandler(handler)));
     return Status::ok();
   }
 
-  Status RemoveRequestHandler(const sp<IRequestHandler>& handler) override {
-    handlers_.erase(handler);
-    return Status::ok();
+  Status RemoveRequestHandler(const string& guid) override {
+    if (impl_.RemoveRequestHandler(guid)) {
+      return Status::ok();
+    }
+
+    return Status::fromExceptionCode(
+        Status::EX_ILLEGAL_ARGUMENT,
+        String8{"No such handler registered"});
   }
 
   Status GetName(string* name) override {
@@ -78,7 +101,6 @@
 
  private:
   ProtocolHandler impl_;
-  set<sp<IRequestHandler>> handlers_;
 
   DISALLOW_COPY_AND_ASSIGN(BinderProtocolHandler);
 };