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

[cronet_http] 🏗️ Use dart-define to determine dependency #1111

Merged
merged 15 commits into from
Feb 23, 2024

Conversation

AlexV525
Copy link
Contributor

@AlexV525 AlexV525 commented Jan 10, 2024

Instead of creating a new embedded package, we can use dart-define to conditionally implement dependencies.

521a017a3284d4ca88cb3c63c618785f


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

@github-actions github-actions bot added package:cronet_http type-infra A repository infrastructure change or enhancement labels Jan 10, 2024
@AlexV525
Copy link
Contributor Author

@AlexV525
Copy link
Contributor Author

This also includes #1101.

# Conflicts:
#	.github/workflows/cronet.yml
#	pkgs/cronet_http/android/build.gradle
#	pkgs/cronet_http/example/android/app/build.gradle
#	pkgs/cronet_http/tool/prepare_for_embedded.dart
Copy link
Collaborator

@brianquinlan brianquinlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really cool approach! I think that you need to increment the pub spec version and add an entry to the CHANGELOG.

One this is live, I think that I can add a note to cronet_http_embedded and deprecate it.

userAgent: 'Book Agent');
cacheMode: CacheMode.memory,
cacheMaxSize: 2 * 1024 * 1024,
userAgent: 'Book Agent',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be some random formatting changes in this file...isn't this formatting actually incorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flutter prefers trailing commas, which makes the formatting different.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just looks misindented though. Can you change it back?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the extra space. Would it be accepted if I only took it away?

}
```

### Use embedded Cronet

The embedded [Cronet][] is provided as `org.chromium.net:cronet-embedded`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something more explicit like:

By default, package:cronet_http uses the [Cronet][] library provided by [Google Play Services][].

If you want your application to work without [Google Play Services][], you can instead depend on the org.chromium.net:cronet-embedded package by using dart-define to set cronetHttpNoPlay is set to true.

For example:
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, package:cronet_http uses the [Cronet][] library provided by [Google Play Services][].

The first paragraph duplicates the previous paragraphs. I'll take the second.

For example:

```
flutter run --dart-define=cronetHttpNoPlay=true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention seems to be to use name_with_underscore. So maybe:

cronet_http_no_play=true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any guide suggesting this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I just looked at some existing defines e.g. test_runner.configuration.

But it is not consistent so feel free to leave it this way.

@brianquinlan
Copy link
Collaborator

After patching this in and using it for a bit, I'm even more amazed by this approach!

@AlexV525
Copy link
Contributor Author

AlexV525 commented Feb 8, 2024

@brianquinlan Thanks for the review. I'll update this after #1091 gets merged.

# Conflicts:
#	.github/workflows/cronet.yml
#	pkgs/cronet_http/README.md
pkgs/cronet_http/CHANGELOG.md Show resolved Hide resolved
userAgent: 'Book Agent');
cacheMode: CacheMode.memory,
cacheMaxSize: 2 * 1024 * 1024,
userAgent: 'Book Agent',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just looks misindented though. Can you change it back?

For example:

```
flutter run --dart-define=cronetHttpNoPlay=true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I just looked at some existing defines e.g. test_runner.configuration.

But it is not consistent so feel free to leave it this way.

@AlexV525 AlexV525 marked this pull request as ready for review February 23, 2024 17:38
pkgs/cronet_http/CHANGELOG.md Show resolved Hide resolved
@brianquinlan brianquinlan merged commit 6e0a46f into dart-lang:master Feb 23, 2024
27 checks passed
@brianquinlan
Copy link
Collaborator

Thanks!

@AlexV525 AlexV525 deleted the feat/dart-define-embedded branch February 23, 2024 23:09
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Feb 27, 2024
Revisions updated by `dart tools/rev_sdk_deps.dart`.

http (https://github.com/dart-lang/http/compare/ce0de37..6e0a46f):
  6e0a46f  2024-02-24  Alex Li  [cronet_http] 🏗️ Use dart-define to determine dependency (dart-lang/http#1111)
  d5cab74  2024-02-23  Alex Li  👷 Update configuration related files (dart-lang/http#1091)
  6873731  2024-02-22  Brian Quinlan  Make it possible for `CronetClient` to own the lifetime of an existing `CronetEngine` (dart-lang/http#1137)

protobuf (https://github.com/dart-lang/protobuf/compare/f085bfd..ef0ab7d):
  ef0ab7d  2024-02-23  Sebastian  Optimize repeated field decoding (google/protobuf.dart#911)

tools (https://github.com/dart-lang/tools/compare/9f4e6a4..c7fbf26):
  c7fbf26  2024-02-21  Elias Yishak  Fallback to current datetime when failing on parse session json file (dart-lang/tools#235)

web (https://github.com/dart-lang/web/compare/975e55c..d96c01d):
  d96c01d  2024-02-23  Srujan Gaddam  Use extension types and generics internally (dart-lang/web#184)

yaml_edit (https://github.com/dart-lang/yaml_edit/compare/82ab64d..54884db):
  54884db  2024-02-23  Devon Carew  update to the latest sdk; update lints (dart-lang/yaml_edit#68)

Change-Id: Ib2cb7971df05f4501f81fe5c04b7eaf88d0d93a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354381
Commit-Queue: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:cronet_http type-infra A repository infrastructure change or enhancement
Projects
None yet
2 participants