Rename HttpServer::OnRequestCallback into RequestHandlerCallback BUG:24267885 Change-Id: I236a464f99056c8af04ef3818739416fdf92f765 Reviewed-on: https://weave-review.googlesource.com/1276 Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/libweave/examples/ubuntu/event_http_server.cc b/libweave/examples/ubuntu/event_http_server.cc index f05ed8b..87834f0 100644 --- a/libweave/examples/ubuntu/event_http_server.cc +++ b/libweave/examples/ubuntu/event_http_server.cc
@@ -192,7 +192,7 @@ } void HttpServerImpl::AddRequestHandler(const std::string& path_prefix, - const OnRequestCallback& callback) { + const RequestHandlerCallback& callback) { handlers_.emplace(path_prefix, callback); }
diff --git a/libweave/examples/ubuntu/event_http_server.h b/libweave/examples/ubuntu/event_http_server.h index 8be3716..0f21787 100644 --- a/libweave/examples/ubuntu/event_http_server.h +++ b/libweave/examples/ubuntu/event_http_server.h
@@ -29,7 +29,7 @@ explicit HttpServerImpl(EventTaskRunner* task_runner); void AddRequestHandler(const std::string& path_prefix, - const OnRequestCallback& callback) override; + const RequestHandlerCallback& callback) override; uint16_t GetHttpPort() const override; uint16_t GetHttpsPort() const override; std::vector<uint8_t> GetHttpsCertificateFingerprint() const override; @@ -44,7 +44,7 @@ const std::string& mime_type); void NotFound(evhttp_request* req); - std::map<std::string, OnRequestCallback> handlers_; + std::map<std::string, RequestHandlerCallback> handlers_; std::unique_ptr<EC_KEY, decltype(&EC_KEY_free)> ec_key_{nullptr, &EC_KEY_free};
diff --git a/libweave/include/weave/provider/http_server.h b/libweave/include/weave/provider/http_server.h index a577229..5119229 100644 --- a/libweave/include/weave/provider/http_server.h +++ b/libweave/include/weave/provider/http_server.h
@@ -29,12 +29,13 @@ const std::string& mime_type) = 0; }; - using OnRequestCallback = + // Callback type for AddRequestHandler. + using RequestHandlerCallback = base::Callback<void(std::unique_ptr<Request> request)>; // Adds callback called on new http/https requests with the given path prefix. virtual void AddRequestHandler(const std::string& path_prefix, - const OnRequestCallback& callback) = 0; + const RequestHandlerCallback& callback) = 0; virtual uint16_t GetHttpPort() const = 0; virtual uint16_t GetHttpsPort() const = 0;
diff --git a/libweave/include/weave/provider/test/mock_http_server.h b/libweave/include/weave/provider/test/mock_http_server.h index 95988ac..a2c9ac2 100644 --- a/libweave/include/weave/provider/test/mock_http_server.h +++ b/libweave/include/weave/provider/test/mock_http_server.h
@@ -19,7 +19,7 @@ class MockHttpServer : public HttpServer { public: MOCK_METHOD2(AddRequestHandler, - void(const std::string&, const OnRequestCallback&)); + void(const std::string&, const RequestHandlerCallback&)); MOCK_CONST_METHOD0(GetHttpPort, uint16_t()); MOCK_CONST_METHOD0(GetHttpsPort, uint16_t());
diff --git a/libweave/src/weave_unittest.cc b/libweave/src/weave_unittest.cc index 4eef7d4..7be9a24 100644 --- a/libweave/src/weave_unittest.cc +++ b/libweave/src/weave_unittest.cc
@@ -202,9 +202,9 @@ EXPECT_CALL(http_server_, GetHttpsCertificateFingerprint()) .WillRepeatedly(Return(std::vector<uint8_t>{1, 2, 3})); EXPECT_CALL(http_server_, AddRequestHandler(_, _)) - .WillRepeatedly( - Invoke([this](const std::string& path_prefix, - const provider::HttpServer::OnRequestCallback& cb) { + .WillRepeatedly(Invoke( + [this](const std::string& path_prefix, + const provider::HttpServer::RequestHandlerCallback& cb) { http_server_request_cb_.push_back(cb); })); } @@ -238,7 +238,8 @@ } } - std::vector<provider::HttpServer::OnRequestCallback> http_server_request_cb_; + std::vector<provider::HttpServer::RequestHandlerCallback> + http_server_request_cb_; StrictMock<provider::test::MockConfigStore> config_store_; StrictMock<provider::test::FakeTaskRunner> task_runner_;