Remove unused

There are no longer any requests made that don't have a run loop to
dispatch back to.
This commit is contained in:
John Firebaugh
2015-05-07 19:57:12 -07:00
parent 1d38b63640
commit 386be7c0fa
8 changed files with 1 additions and 78 deletions

View File

@@ -39,7 +39,6 @@ public:
// #############################################################################################
// File request APIs
void requestAsync(const Resource&, std::function<void(const Response&)>);
Request* request(const Resource&, std::function<void(const Response&)>);
void cancelRequest(Request*);

View File

@@ -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;

View File

@@ -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;
};
}

View File

@@ -121,11 +121,6 @@ unsigned Environment::getID() const {
return id;
}
void Environment::requestAsync(const Resource& resource,
std::function<void(const Response&)> callback) {
fileSource.request(resource, std::move(callback));
}
Request* Environment::request(const Resource& resource,
std::function<void(const Response&)> callback) {
return fileSource.request(resource, util::RunLoop::current.get()->get(), std::move(callback));

View File

@@ -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);
}

View File

@@ -1,38 +0,0 @@
#include "storage.hpp"
#include <uv.h>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/util/uv.hpp>
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);
}

View File

@@ -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<void> promise;
fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, [&] (const Response &) {
promise.set_value();
});
promise.get_future().get();
HTTPTest.finish();
}

View File

@@ -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',
],