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

No more singleton #8

Merged
merged 12 commits into from
May 8, 2019
Merged

No more singleton #8

merged 12 commits into from
May 8, 2019

Conversation

badboy
Copy link
Member

@badboy badboy commented May 8, 2019

Pull Request checklist

  • Quality: This PR builds and tests run cleanly
    • cargo clean; cargo test --all runs without emitting any warnings
    • cargo fmt does not produce any changes to the code
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly

}

/**
* Returns true if the Glean library has been initialized.
*/
internal fun isInitialized(): Boolean {
val initialized = LibGleanFFI.INSTANCE.glean_is_initialized()
if (glean == 0L) {
Copy link
Contributor

Choose a reason for hiding this comment

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

With lateinit, we can simply check glean.isInitialized, making klint happy.

mdboom
mdboom previously approved these changes May 8, 2019
@@ -1,5 +1,5 @@
ifeq ($(ANDROID_HOME),)
ANDROID_HOME := ~/Library/Android
ANDROID_HOME := ~/Library/Android/sdk
Copy link
Contributor

Choose a reason for hiding this comment

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

On my machine this is Sdk. Will we run into issues on case-sensitive filesystems here?

@@ -45,7 +43,8 @@ impl CommonMetricData {
}

pub fn should_record(&self) -> bool {
if self.disabled || !Glean::singleton().is_upload_enabled() {
//if self.disabled || !Glean::singleton().is_upload_enabled() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a TODO here to remember to come back to this so Glean is passed in and we can check whether upload is enabled?

@@ -13,7 +13,8 @@ import mozilla.telemetry.glean.rust.RustError

open class GleanInternalAPI internal constructor () {
// `internal` so this can be modified for testing
internal var bool_metric: MetricHandle = 0
internal var bool_metric: MetricHandle = 0L
internal var glean: MetricHandle = 0L
Copy link
Contributor

Choose a reason for hiding this comment

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

It might make sense to use lateinit for this. We should also probably call this apiHandle, and directly use it from the types.

return initialized.toInt() != 0
}

fun handle(): Long {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this: we should be able to access internal variables from the types.

@@ -45,7 +43,8 @@ impl CommonMetricData {
}

pub fn should_record(&self) -> bool {
if self.disabled || !Glean::singleton().is_upload_enabled() {
//if self.disabled || !Glean::singleton().is_upload_enabled() {
Copy link
Contributor

Choose a reason for hiding this comment

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

How can we now handle is_upload_enabled? Would it help to pass around the Glean instance rathre than the Storage alone? Then we could check, at call site, if upload is enabled or not. Or maybe we don't simply care now, and keep the same behaviour as desktop.

@badboy badboy merged commit ec6c604 into api-playground May 8, 2019
@badboy badboy mentioned this pull request May 8, 2019
@badboy badboy deleted the no-more-singleton branch May 9, 2019 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants