aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Dahlin <sadmac@google.com>2016-02-10 16:50:32 -0800
committerCasey Dahlin <sadmac@google.com>2016-02-12 14:58:00 -0800
commit157f00a901bd4d8c1fa42ecc4d28d15b154a9179 (patch)
tree28ea925f8616cf55d43b9a85457298fe4108c781
parentb6f7541fa7b20a205616354e78e04c0bc2ff3ef2 (diff)
downloadwebservd-157f00a901bd4d8c1fa42ecc4d28d15b154a9179.tar.gz
Stub out request handlers for Binderbrillo-m10-releasebrillo-m10-dev
Change-Id: I1c40467cf8115db429703b0fa9199c8ccbb174fd Test: Build continues to pass in binder mode Bug: 26914456
-rw-r--r--aidl/android/webservd/IProtocolHandler.aidl14
-rw-r--r--aidl/android/webservd/IRequestHandler.aidl4
-rw-r--r--webservd/binder_server.cc38
3 files changed, 42 insertions, 14 deletions
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 @@ import android.webservd.IRequestHandler;
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.IRequestHandler;
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 @@ using std::vector;
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 @@ class BinderProtocolHandler : public android::webservd::BnProtocolHandler {
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 @@ class BinderProtocolHandler : public android::webservd::BnProtocolHandler {
private:
ProtocolHandler impl_;
- set<sp<IRequestHandler>> handlers_;
DISALLOW_COPY_AND_ASSIGN(BinderProtocolHandler);
};