New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS: Drain and pass URLRequest body data to the platform implementation #2286
Conversation
Fixes flutter/flutter#1343 |
// If the body has request data, try to drain that | ||
AsyncNSDataDrainer::Drain( | ||
request->body[0].Pass(), // handle | ||
base::Bind(&URLLoaderImpl::StartNow, base::Unretained(this), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lifetimes here are slightly sketchy. In particular, this
can die before the drain is finished and you'll get a callback call with a bogus this pointer. You've got two choices for how to resolve this issue:
- Have this object hold the AsyncNSDataDrainer as a member, similar to how AsyncNSDataDrainer holds common::DataPipeDrainer. Then when this object dies, it will kill the AsyncNSDataDrainer, which will kill the common::DataPipeDrainer and stop the callbacks.
- Instead of using
base::Unretained(this)
here, you can bind abase::WeakPtr
to the callback. The callback will check the weak pointer before using it as the "this" pointer.
I'd recommend (1) because the WeakPtr approach doesn't stop the drain when the client goes away.
LGTM w/ lifetime issue fixed. |
|
||
void OnDataComplete() override { | ||
auto callback = callback_; | ||
auto data = data_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put the type in here explicitly because it's important that its an NSMutableData*
rather than a NSMutableData*&
, for example.
LGTM |
Done. Rebased. |
iOS: Drain and pass URLRequest body data to the platform implementation
Since enum values listed on the enum class's page are, I think, the only case of multiple paragraphs inside a dd, they deserve some special styling.
Removing make and automake.
No description provided.