Skip to content
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

Merged
merged 1 commit into from Jan 25, 2016

Conversation

chinmaygarde
Copy link
Member

No description provided.

@chinmaygarde
Copy link
Member Author

Fixes flutter/flutter#1343

@eseidelGoogle
Copy link
Contributor

lgtm 2m. If you need deep c++ review, you'll need to ask @abarth or @jamesr.

// If the body has request data, try to drain that
AsyncNSDataDrainer::Drain(
request->body[0].Pass(), // handle
base::Bind(&URLLoaderImpl::StartNow, base::Unretained(this),
Copy link
Contributor

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:

  1. 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.
  2. Instead of using base::Unretained(this) here, you can bind a base::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.

@abarth
Copy link
Contributor

abarth commented Jan 23, 2016

LGTM w/ lifetime issue fixed.


void OnDataComplete() override {
auto callback = callback_;
auto data = data_;
Copy link
Contributor

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.

@abarth
Copy link
Contributor

abarth commented Jan 25, 2016

LGTM

@chinmaygarde
Copy link
Member Author

Done. Rebased.

chinmaygarde added a commit that referenced this pull request Jan 25, 2016
iOS: Drain and pass URLRequest body data to the platform implementation
@chinmaygarde chinmaygarde merged commit 4421177 into flutter:master Jan 25, 2016
rhencke pushed a commit to rhencke/engine that referenced this pull request Dec 20, 2020
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.
rhencke pushed a commit to rhencke/engine that referenced this pull request Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants