more logging, don't respond to cancelled requests

This commit is contained in:
Mike Morris
2015-08-27 15:23:46 -04:00
parent 580719c9f9
commit c2539d6bd4
2 changed files with 11 additions and 4 deletions

View File

@@ -62,7 +62,7 @@ NAN_METHOD(NodeRequest::Respond) {
// Request has already been responded to, or was canceled, fail silently.
if (!nodeRequest->resource) NanReturnUndefined();
std::cout << "RESPOND: " << nodeRequest->resource->url << std::endl;
std::cout << "C++ RESPOND: " << nodeRequest->resource->url << std::endl;
auto source = nodeRequest->source;
auto resource = std::move(nodeRequest->resource);
@@ -136,10 +136,11 @@ NodeRequest::NodeRequest(NodeFileSource* source_, const mbgl::Resource& resource
resource(std::make_unique<mbgl::Resource>(resource_)) {}
NodeRequest::~NodeRequest() {
if (resource) std::cout << "DESTROY: " << resource->url << std::endl;
if (resource) std::cout << "C++ DESTROY: " << resource->url << std::endl;
}
void NodeRequest::cancel() {
std::cout << "C++ CANCEL: " << resource->url << std::endl;
resource.reset();
}

View File

@@ -42,12 +42,18 @@ function renderTest(style, info, base, key) {
var options = {};
options.request = function(req) {
var url = decodeURIComponent(req.url);
console.log('REQUEST: ', url);
console.log('JAVASCRIPT REQUEST:', url);
fs.readFile(path.join(suitePath, url), function(err, data) {
// t.error(err);
req.respond(err, { data: data });
console.log('CANCELED?', req.canceled, 'ERROR?', err, url);
if (!req.canceled) req.respond(err, { data: data });
});
};
options.cancel = function(req) {
var url = decodeURIComponent(req.url);
console.log('JAVASCRIPT CANCEL:', url);
req.canceled = true;
};
options.ratio = 1.0;
var map = new mbgl.Map(options);