Rename WindowManager::(ShouldNotifyListener --> ShouldWindowUpdateFn).
This rename improves readability and clarity overall, and especially when the
function is referenced in contexts without WindowManager::WindowUpdateListener
(like OgHttp2Session::Options).
PiperOrigin-RevId: 432293498
diff --git a/http2/adapter/oghttp2_session.cc b/http2/adapter/oghttp2_session.cc
index e1be0d8..89d6d6f 100644
--- a/http2/adapter/oghttp2_session.cc
+++ b/http2/adapter/oghttp2_session.cc
@@ -334,7 +334,7 @@
[this](size_t window_update_delta) {
SendWindowUpdate(kConnectionStreamId, window_update_delta);
},
- /*should_notify_listener=*/{},
+ /*should_window_update_fn=*/{},
/*update_window_on_notify=*/false),
options_(options) {
decoder_.set_visitor(&receive_logger_);
diff --git a/http2/adapter/oghttp2_session.h b/http2/adapter/oghttp2_session.h
index 63d54bc..c9eed29 100644
--- a/http2/adapter/oghttp2_session.h
+++ b/http2/adapter/oghttp2_session.h
@@ -215,7 +215,7 @@
StreamState(int32_t stream_receive_window, int32_t stream_send_window,
WindowManager::WindowUpdateListener listener)
: window_manager(stream_receive_window, std::move(listener),
- /*should_notify_listener=*/{},
+ /*should_window_update_fn=*/{},
/*update_window_on_notify=*/false),
send_window(stream_send_window) {}
diff --git a/http2/adapter/window_manager.cc b/http2/adapter/window_manager.cc
index c93356a..eca9031 100644
--- a/http2/adapter/window_manager.cc
+++ b/http2/adapter/window_manager.cc
@@ -8,7 +8,7 @@
namespace http2 {
namespace adapter {
-bool DefaultShouldNotifyListener(int64_t limit, int64_t window, int64_t delta) {
+bool DefaultShouldWindowUpdateFn(int64_t limit, int64_t window, int64_t delta) {
// For the sake of efficiency, we want to send window updates if less than
// half of the max quota is available to the peer at any point in time.
const int64_t kDesiredMinWindow = limit / 2;
@@ -27,16 +27,16 @@
WindowManager::WindowManager(int64_t window_size_limit,
WindowUpdateListener listener,
- ShouldNotifyListener should_notify_listener,
+ ShouldWindowUpdateFn should_window_update_fn,
bool update_window_on_notify)
: limit_(window_size_limit),
window_(window_size_limit),
buffered_(0),
listener_(std::move(listener)),
- should_notify_listener_(std::move(should_notify_listener)),
+ should_window_update_fn_(std::move(should_window_update_fn)),
update_window_on_notify_(update_window_on_notify) {
- if (!should_notify_listener_) {
- should_notify_listener_ = DefaultShouldNotifyListener;
+ if (!should_window_update_fn_) {
+ should_window_update_fn_ = DefaultShouldWindowUpdateFn;
}
}
@@ -89,7 +89,7 @@
void WindowManager::MaybeNotifyListener() {
const int64_t delta = limit_ - (buffered_ + window_);
- if (should_notify_listener_(limit_, window_, delta) && delta > 0) {
+ if (should_window_update_fn_(limit_, window_, delta) && delta > 0) {
QUICHE_VLOG(2) << "WindowManager@" << this
<< " Informing listener of delta: " << delta;
listener_(delta);
diff --git a/http2/adapter/window_manager.h b/http2/adapter/window_manager.h
index 373e602..48ec3d9 100644
--- a/http2/adapter/window_manager.h
+++ b/http2/adapter/window_manager.h
@@ -23,11 +23,11 @@
// Invoked to determine whether to call the listener based on the window
// limit, window size, and delta that would be sent.
- using ShouldNotifyListener =
+ using ShouldWindowUpdateFn =
std::function<bool(int64_t limit, int64_t size, int64_t delta)>;
WindowManager(int64_t window_size_limit, WindowUpdateListener listener,
- ShouldNotifyListener should_notify_listener = {},
+ ShouldWindowUpdateFn should_window_update_fn = {},
bool update_window_on_notify = true);
int64_t CurrentWindowSize() const { return window_; }
@@ -81,7 +81,7 @@
WindowUpdateListener listener_;
- ShouldNotifyListener should_notify_listener_;
+ ShouldWindowUpdateFn should_window_update_fn_;
bool update_window_on_notify_;
};
diff --git a/http2/adapter/window_manager_test.cc b/http2/adapter/window_manager_test.cc
index 27b5e21..fd2327d 100644
--- a/http2/adapter/window_manager_test.cc
+++ b/http2/adapter/window_manager_test.cc
@@ -266,9 +266,9 @@
}
// This test verifies that when the constructor option is specified,
-// WindowManager uses the provided ShouldNotifyListener to determine when to
+// WindowManager uses the provided ShouldWindowUpdateFn to determine when to
// notify the listener.
-TEST(WindowManagerShouldUpdateTest, CustomShouldNotifyListener) {
+TEST(WindowManagerShouldUpdateTest, CustomShouldWindowUpdateFn) {
const int64_t kDefaultLimit = 65535;
// This window manager should always notify.