asio: Export session_impl* from stream rather than delegating everything

This commit is contained in:
Tatsuhiro Tsujikawa 2015-03-05 21:48:37 +09:00
parent 9efb62f40b
commit ca1f43dfca
3 changed files with 13 additions and 9 deletions

View File

@ -25,6 +25,7 @@
#include "asio_client_request_impl.h"
#include "asio_client_stream.h"
#include "asio_client_session_impl.h"
#include "template.h"
namespace nghttp2 {
@ -33,7 +34,10 @@ namespace client {
request_impl::request_impl() : strm_(nullptr) {}
void request_impl::cancel(uint32_t error_code) { strm_->cancel(error_code); }
void request_impl::cancel(uint32_t error_code) {
auto sess = strm_->session();
sess->cancel(*strm_, error_code);
}
void request_impl::on_response(response_cb cb) { response_cb_ = std::move(cb); }
@ -72,7 +76,10 @@ read_cb::result_type request_impl::call_on_read(uint8_t *buf, std::size_t len,
return 0;
}
void request_impl::resume() { strm_->resume(); }
void request_impl::resume() {
auto sess = strm_->session();
sess->resume(*strm_);
}
void request_impl::header(header_map h) { header_ = std::move(h); }

View File

@ -36,10 +36,6 @@ stream::stream(session_impl *sess) : sess_(sess), stream_id_(0) {
request_.impl().stream(this);
}
void stream::cancel(uint32_t error_code) { sess_->cancel(*this, error_code); }
void stream::resume() { sess_->resume(*this); }
void stream::stream_id(int32_t stream_id) { stream_id_ = stream_id; }
int32_t stream::stream_id() const { return stream_id_; }
@ -48,6 +44,8 @@ request &stream::request() { return request_; }
response &stream::response() { return response_; }
session_impl *stream::session() const { return sess_; }
bool stream::expect_final_response() const {
return response_.status_code() / 100 == 1;
}

View File

@ -44,15 +44,14 @@ public:
stream(const stream &) = delete;
stream &operator=(const stream &) = delete;
void cancel(uint32_t error_code);
void resume();
void stream_id(int32_t stream_id);
int32_t stream_id() const;
request &request();
response &response();
session_impl *session() const;
bool expect_final_response() const;
private: