diff --git a/include/mbgl/map/environment.hpp b/include/mbgl/map/environment.hpp index 07554a7a9..d8068187e 100644 --- a/include/mbgl/map/environment.hpp +++ b/include/mbgl/map/environment.hpp @@ -39,7 +39,6 @@ public: // ############################################################################################# // File request APIs - void requestAsync(const Resource&, std::function); Request* request(const Resource&, std::function); void cancelRequest(Request*); diff --git a/include/mbgl/storage/default_file_source.hpp b/include/mbgl/storage/default_file_source.hpp index d50d5ddea..405b04a49 100644 --- a/include/mbgl/storage/default_file_source.hpp +++ b/include/mbgl/storage/default_file_source.hpp @@ -18,7 +18,6 @@ public: // FileSource API Request* request(const Resource&, uv_loop_t*, Callback) override; void cancel(Request*) override; - void request(const Resource&, Callback) override; public: class Impl; diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp index 535c41e81..7c6e578a9 100644 --- a/include/mbgl/storage/file_source.hpp +++ b/include/mbgl/storage/file_source.hpp @@ -29,10 +29,6 @@ public: // You can only cancel a request from the same thread it was created in. virtual Request* request(const Resource&, uv_loop_t*, Callback) = 0; virtual void cancel(Request*) = 0; - - // These can be called from any thread. The callback will be invoked in an arbitrary other thread. - // You cannot cancel these requests. - virtual void request(const Resource&, Callback) = 0; }; } diff --git a/src/mbgl/map/environment.cpp b/src/mbgl/map/environment.cpp index 5857d4bdf..327efeecf 100644 --- a/src/mbgl/map/environment.cpp +++ b/src/mbgl/map/environment.cpp @@ -121,11 +121,6 @@ unsigned Environment::getID() const { return id; } -void Environment::requestAsync(const Resource& resource, - std::function callback) { - fileSource.request(resource, std::move(callback)); -} - Request* Environment::request(const Resource& resource, std::function callback) { return fileSource.request(resource, util::RunLoop::current.get()->get(), std::move(callback)); diff --git a/src/mbgl/storage/default_file_source.cpp b/src/mbgl/storage/default_file_source.cpp index cc7475d2f..e8831f546 100644 --- a/src/mbgl/storage/default_file_source.cpp +++ b/src/mbgl/storage/default_file_source.cpp @@ -37,24 +37,14 @@ DefaultFileSource::~DefaultFileSource() { Request* DefaultFileSource::request(const Resource& resource, uv_loop_t* l, Callback callback) { + assert(l); auto req = new Request(resource, l, std::move(callback)); - - // This function can be called from any thread. Make sure we're executing the actual call in the - // file source loop by sending it over the queue. thread->invoke(&Impl::add, req); - return req; } -void DefaultFileSource::request(const Resource& resource, Callback callback) { - request(resource, nullptr, std::move(callback)); -} - void DefaultFileSource::cancel(Request *req) { req->cancel(); - - // This function can be called from any thread. Make sure we're executing the actual call in the - // file source loop by sending it over the queue. thread->invoke(&Impl::cancel, req); } diff --git a/test/storage/http_noloop.cpp b/test/storage/http_noloop.cpp deleted file mode 100644 index e133d3e0c..000000000 --- a/test/storage/http_noloop.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "storage.hpp" - -#include - -#include -#include - -TEST_F(Storage, HTTPNoLoop) { - SCOPED_TEST(HTTPNoLoop) - - using namespace mbgl; - - DefaultFileSource fs(nullptr); - - const auto mainThread = uv_thread_self(); - - // Async handle that keeps the main loop alive until the thread finished - auto async = new uv_async_t; - uv_async_init(uv_default_loop(), async, [] (uv_async_t *as, int) { - uv::close(as); - }); - - fs.request({ Resource::Unknown, "http://127.0.0.1:3000/temporary-error" }, nullptr, - [&](const Response &res) { - EXPECT_NE(uv_thread_self(), mainThread) << "Response was called in the same thread"; - EXPECT_EQ(Response::Successful, res.status); - EXPECT_EQ("Hello World!", res.data); - EXPECT_EQ(0, res.expires); - EXPECT_EQ(0, res.modified); - EXPECT_EQ("", res.etag); - EXPECT_EQ("", res.message); - HTTPNoLoop.finish(); - - uv_async_send(async); - }); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); -} diff --git a/test/storage/http_reading.cpp b/test/storage/http_reading.cpp index 09d33fd6a..b322bbf2a 100644 --- a/test/storage/http_reading.cpp +++ b/test/storage/http_reading.cpp @@ -56,20 +56,3 @@ TEST_F(Storage, HTTPNoCallback) { HTTPTest.finish(); } - -TEST_F(Storage, HTTPCallbackNotOnLoop) { - using namespace mbgl; - - DefaultFileSource fs(nullptr); - - SCOPED_TEST(HTTPTest) - - std::promise promise; - fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, [&] (const Response &) { - promise.set_value(); - }); - - promise.get_future().get(); - - HTTPTest.finish(); -} diff --git a/test/test.gypi b/test/test.gypi index 03bceaae4..75301751c 100644 --- a/test/test.gypi +++ b/test/test.gypi @@ -71,7 +71,6 @@ 'storage/http_header_parsing.cpp', 'storage/http_issue_1369.cpp', 'storage/http_load.cpp', - 'storage/http_noloop.cpp', 'storage/http_other_loop.cpp', 'storage/http_reading.cpp', ],