src: Rename verbose callback functions

This commit is contained in:
Tatsuhiro Tsujikawa 2013-12-20 23:48:56 +09:00
parent 9f7b231c2c
commit bb70cdf6ad
4 changed files with 58 additions and 61 deletions

View File

@ -764,7 +764,7 @@ int hd_on_frame_recv_callback
auto hd = reinterpret_cast<Http2Handler*>(user_data);
if(hd->get_config()->verbose) {
print_session_id(hd->session_id());
on_frame_recv_callback(session, frame, user_data);
verbose_on_frame_recv_callback(session, frame, user_data);
}
switch(frame->hd.type) {
case NGHTTP2_HEADERS:
@ -856,7 +856,7 @@ int hd_on_frame_send_callback
}
if(hd->get_config()->verbose) {
print_session_id(hd->session_id());
on_frame_send_callback(session, frame, user_data);
verbose_on_frame_send_callback(session, frame, user_data);
}
return 0;
}
@ -881,7 +881,8 @@ int hd_on_data_recv_callback
auto hd = reinterpret_cast<Http2Handler*>(user_data);
if(hd->get_config()->verbose) {
print_session_id(hd->session_id());
on_data_recv_callback(session, length, flags, stream_id, user_data);
verbose_on_data_recv_callback(session, length, flags, stream_id,
user_data);
}
return 0;
}
@ -895,7 +896,8 @@ int hd_on_data_send_callback
auto hd = reinterpret_cast<Http2Handler*>(user_data);
if(hd->get_config()->verbose) {
print_session_id(hd->session_id());
on_data_send_callback(session, length, flags, stream_id, user_data);
verbose_on_data_send_callback(session, length, flags, stream_id,
user_data);
}
return 0;
}
@ -931,10 +933,12 @@ void fill_callback(nghttp2_session_callbacks& callbacks, const Config *config)
callbacks.on_data_recv_callback = hd_on_data_recv_callback;
callbacks.on_data_send_callback = hd_on_data_send_callback;
if(config->verbose) {
callbacks.on_invalid_frame_recv_callback = on_invalid_frame_recv_callback;
callbacks.on_invalid_frame_recv_callback =
verbose_on_invalid_frame_recv_callback;
callbacks.on_frame_recv_parse_error_callback =
on_frame_recv_parse_error_callback;
callbacks.on_unknown_frame_recv_callback = on_unknown_frame_recv_callback;
verbose_on_frame_recv_parse_error_callback;
callbacks.on_unknown_frame_recv_callback =
verbose_on_unknown_frame_recv_callback;
}
callbacks.on_data_chunk_recv_callback = on_data_chunk_recv_callback;
callbacks.on_request_recv_callback = config->on_request_recv_callback;

View File

@ -340,7 +340,7 @@ void print_frame(print_type ptype, const nghttp2_frame *frame)
}
} // namespace
int on_frame_recv_callback
int verbose_on_frame_recv_callback
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
{
print_timer();
@ -350,7 +350,7 @@ int on_frame_recv_callback
return 0;
}
int on_invalid_frame_recv_callback
int verbose_on_invalid_frame_recv_callback
(nghttp2_session *session, const nghttp2_frame *frame,
nghttp2_error_code error_code, void *user_data)
{
@ -374,13 +374,14 @@ void dump_header(const uint8_t *head, size_t headlen)
}
} // namespace
int on_frame_recv_parse_error_callback(nghttp2_session *session,
nghttp2_frame_type type,
const uint8_t *head,
size_t headlen,
const uint8_t *payload,
size_t payloadlen,
int error_code, void *user_data)
int verbose_on_frame_recv_parse_error_callback(nghttp2_session *session,
nghttp2_frame_type type,
const uint8_t *head,
size_t headlen,
const uint8_t *payload,
size_t payloadlen,
int error_code,
void *user_data)
{
print_timer();
printf(" [PARSE_ERROR] recv %s%s%s frame\n",
@ -394,12 +395,12 @@ int on_frame_recv_parse_error_callback(nghttp2_session *session,
return 0;
}
int on_unknown_frame_recv_callback(nghttp2_session *session,
const uint8_t *head,
size_t headlen,
const uint8_t *payload,
size_t payloadlen,
void *user_data)
int verbose_on_unknown_frame_recv_callback(nghttp2_session *session,
const uint8_t *head,
size_t headlen,
const uint8_t *payload,
size_t payloadlen,
void *user_data)
{
print_timer();
printf(" recv unknown frame\n");
@ -408,7 +409,7 @@ int on_unknown_frame_recv_callback(nghttp2_session *session,
return 0;
}
int on_frame_send_callback
int verbose_on_frame_send_callback
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
{
print_timer();
@ -433,7 +434,7 @@ void print_data_frame(print_type ptype, uint16_t length, uint8_t flags,
}
} // namespace
int on_data_recv_callback
int verbose_on_data_recv_callback
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data)
{
@ -444,7 +445,7 @@ int on_data_recv_callback
return 0;
}
int on_data_send_callback
int verbose_on_data_send_callback
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data)
{

View File

@ -41,36 +41,37 @@ namespace nghttp2 {
void print_nv(char **nv);
int on_frame_recv_callback
int verbose_on_frame_recv_callback
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data);
int on_invalid_frame_recv_callback
int verbose_on_invalid_frame_recv_callback
(nghttp2_session *session, const nghttp2_frame *frame,
nghttp2_error_code error_code, void *user_data);
int on_frame_recv_parse_error_callback(nghttp2_session *session,
nghttp2_frame_type type,
const uint8_t *head,
size_t headlen,
const uint8_t *payload,
size_t payloadlen,
int error_code, void *user_data);
int verbose_on_frame_recv_parse_error_callback(nghttp2_session *session,
nghttp2_frame_type type,
const uint8_t *head,
size_t headlen,
const uint8_t *payload,
size_t payloadlen,
int error_code,
void *user_data);
int on_unknown_frame_recv_callback(nghttp2_session *session,
const uint8_t *head,
size_t headlen,
const uint8_t *payload,
size_t payloadlen,
void *user_data);
int verbose_on_unknown_frame_recv_callback(nghttp2_session *session,
const uint8_t *head,
size_t headlen,
const uint8_t *payload,
size_t payloadlen,
void *user_data);
int on_frame_send_callback
int verbose_on_frame_send_callback
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data);
int on_data_recv_callback
int verbose_on_data_recv_callback
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data);
int on_data_send_callback
int verbose_on_data_send_callback
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data);

View File

@ -1096,17 +1096,6 @@ int before_frame_send_callback
}
} // namespace
namespace {
int on_frame_send_callback2
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
{
if(config.verbose) {
on_frame_send_callback(session, frame, user_data);
}
return 0;
}
} // namespace
namespace {
void check_response_header
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
@ -1169,7 +1158,7 @@ int on_frame_recv_callback2
}
}
if(config.verbose) {
on_frame_recv_callback(session, frame, user_data);
verbose_on_frame_recv_callback(session, frame, user_data);
}
return 0;
}
@ -1480,15 +1469,17 @@ int run(char **uris, int n)
callbacks.recv_callback = client_recv_callback;
callbacks.on_stream_close_callback = on_stream_close_callback;
callbacks.on_frame_recv_callback = on_frame_recv_callback2;
callbacks.on_frame_send_callback = on_frame_send_callback2;
callbacks.before_frame_send_callback = before_frame_send_callback;
if(config.verbose) {
callbacks.on_data_recv_callback = on_data_recv_callback;
callbacks.on_data_send_callback = on_data_send_callback;
callbacks.on_invalid_frame_recv_callback = on_invalid_frame_recv_callback;
callbacks.on_frame_send_callback = verbose_on_frame_send_callback;
callbacks.on_data_recv_callback = verbose_on_data_recv_callback;
callbacks.on_data_send_callback = verbose_on_data_send_callback;
callbacks.on_invalid_frame_recv_callback =
verbose_on_invalid_frame_recv_callback;
callbacks.on_frame_recv_parse_error_callback =
on_frame_recv_parse_error_callback;
callbacks.on_unknown_frame_recv_callback = on_unknown_frame_recv_callback;
verbose_on_frame_recv_parse_error_callback;
callbacks.on_unknown_frame_recv_callback =
verbose_on_unknown_frame_recv_callback;
}
callbacks.on_data_chunk_recv_callback = on_data_chunk_recv_callback;
std::string prev_scheme;