FYI: i'm starting with the IOCP CL. once we have that one in pretty good shape, i'll look more closely at this one (in case changes in the other ripple up into this one).
CoreImpl* core_impl();
all callers of this seem to assume that it's only used after the core is created. can we make it return a reference to the impl rather than a pointer so that there's no mystery about it being null vs non-null?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
signaled event [1], which comes with OS thread scheduling and task queuing overhead. We want to test the hypothesis that using an
nit: wrap at 72 cols
// These constructors must be invoked via Create() (enforced via PassKey).
can we instead make them `private` and use `base::WrapUnique(new ...)` instead of `std::make_unique` in `Create()`?
Core();
nit: move this into the `protected` block since this is a pure-virtual interface -- only subclasses can run the ctor
: TCPSocketWin(std::move(socket_performance_watcher), net_log_source) {}
`std::move` this? maybe it doesn't matter, but what the heck
return *static_cast<CoreImpl*>(core_.get());
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Please take another look. Thanks.
signaled event [1], which comes with OS thread scheduling and task queuing overhead. We want to test the hypothesis that using an
nit: wrap at 72 cols
Done
// These constructors must be invoked via Create() (enforced via PassKey).
can we instead make them `private` and use `base::WrapUnique(new ...)` instead of `std::make_unique` in `Create()`?
Yes, done.
nit: move this into the `protected` block since this is a pure-virtual interface -- only subclasses can run the ctor
Done
all callers of this seem to assume that it's only used after the core is created. can we make it return a reference to the impl rather than a pointer so that there's no mystery about it being null vs non-null?
Done
: TCPSocketWin(std::move(socket_performance_watcher), net_log_source) {}
`std::move` this? maybe it doesn't matter, but what the heck
Done
Switched to CHECK_DEREF but kept the implementation in the .cc file, because the .h file doesn't know that CoreImpl is related to Core and therefore doesn't allow the cast (error: static_cast from 'net::TCPSocketWin::Core *' to 'CoreImpl *', which are not related by inheritance, is not allowed).
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
// These constructors must be invoked via Create() (enforced via PassKey).
maybe this comment isn't needed anymore now that the ctors are private? if you think it's still useful, please remove mention of PassKey.
~TCPSocketWin() override;
please put a scary comment here stating that subclasses must call `Close()` in their dtors. (see the comment on `base::Thread::~Thread` for something similar.)
if (!!core_->socket_->connect_callback_) {
`connect_callback_` has a well-defined `operator bool`, so there is no need/reason for `!!`. please remove -- "if the socket holds a connect callback" is more readable than "if the socket doesn't not hold a connect callback."
if (socket_ == INVALID_SOCKET || !!connect_callback_) {
here, too
if (socket_ == INVALID_SOCKET || !!connect_callback_) {
and here
CHECK(!read_callback_ || !!read_if_ready_callback_);
and these two
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// These constructors must be invoked via Create() (enforced via PassKey).
maybe this comment isn't needed anymore now that the ctors are private? if you think it's still useful, please remove mention of PassKey.
Done
please put a scary comment here stating that subclasses must call `Close()` in their dtors. (see the comment on `base::Thread::~Thread` for something similar.)
Done
`connect_callback_` has a well-defined `operator bool`, so there is no need/reason for `!!`. please remove -- "if the socket holds a connect callback" is more readable than "if the socket doesn't not hold a connect callback."
Done
if (socket_ == INVALID_SOCKET || !!connect_callback_) {
Francois Pierre Dorayhere, too
Done
if (socket_ == INVALID_SOCKET || !!connect_callback_) {
Francois Pierre Dorayand here
Done
CHECK(!!connect_callback_);
Francois Pierre Dorayand here
Done
CHECK(!read_callback_ || !!read_if_ready_callback_);
Francois Pierre Dorayand these two
Done
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
return !!read_if_ready_callback_;
could you get rid of this one, too? :-)
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
ricea@: Please take a look.
See context at: https://groups.google.com/a/chromium.org/g/net-dev/c/AT79ASeYEpI
Thanks!
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
could you get rid of this one, too? :-)
This does not compile:
```
bool HasCallback() {
base::OnceClosure closure;
return closure;
}
```
```
error: no viable conversion from returned value of type 'base::OnceClosure' (aka 'OnceCallback<void ()>') to function return type 'bool'
52 | return closure;
| ^~~~~~~
../../base/functional/callback.h:111:12: note: explicit conversion function is not a candidate
111 | explicit operator bool() const { return !!holder_; }
```
But this does:
```
bool HasCallback() {
base::OnceClosure closure;
return !closure.is_null();
}
```
So I switched to the latter.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
return !!read_if_ready_callback_;
Francois Pierre Doraycould you get rid of this one, too? :-)
This does not compile:
```
bool HasCallback() {
base::OnceClosure closure;
return closure;
}
``````
error: no viable conversion from returned value of type 'base::OnceClosure' (aka 'OnceCallback<void ()>') to function return type 'bool'
52 | return closure;
| ^~~~~~~
../../base/functional/callback.h:111:12: note: explicit conversion function is not a candidate
111 | explicit operator bool() const { return !!holder_; }
```
But this does:```
bool HasCallback() {
base::OnceClosure closure;
return !closure.is_null();
}
```So I switched to the latter.
oh, yeah, it's an `explicit` bool operator. another option is `bool(read_if_ready_callback_)`, but i find what you've written here eminently readable. :-)
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
class NET_EXPORT TCPSocketDefaultWin : public TCPSocketWin {
Can't this go in the .cc file?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Auto-Submit | +1 |
lgtm. Very nice. Sorry for the delay.
Thanks!
mattreynolds@: Please take a look at //device/bluetooth/.
Thanks!
class NET_EXPORT TCPSocketDefaultWin : public TCPSocketWin {
Can't this go in the .cc file?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
Commit-Queue | +2 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[net] Refactor TCPSocketWin to allow alternative read/write impls.
TCPSocketWin uses base::win::ObjectWatcher to watch for completed
reads and writes. Under the hood, this incurs one PostTask per
signaled event [1], which comes with OS thread scheduling and task
queuing overhead. We want to test the hypothesis that using an
IO completion port to be notified of completed reads and writes
without going through PostTask improves page load time.
Steps:
1. [this CL] Make the methods of TCPSocketWin which implement
the read/write operations pure virtual and implement them in
TCPSocketDefaultWin. Introduce TCPSocketWin::Create which
instantiates a TCPSocketDefaultWin. No behavior change in this CL.
2. [crrev.com/c/5627052] Introduce TcpSocketIoCompletionPortWin which
uses an IO completion port to be notified of completed reads and
writes, instead of an event watched by base::win::ObjectWatcher.
Make TCPSocketWin::Create instantiate that class instead of
TCPSocketDefaultWin when the new "cpSocketIoCompletionPortWin"
feature is enabled.
[1] https://source.chromium.org/chromium/chromium/src/+/main:base/win/object_watcher.cc;l=87-92;drc=82d96b9965565487874b66b939ca2527a9b2783d
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |