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

Refactor loadFromJson from RapidJSON to base::JSONReader #4045

Merged
merged 4 commits into from
Dec 2, 2019
Merged

Conversation

tmancey
Copy link
Collaborator

@tmancey tmancey commented Nov 21, 2019

Fixes brave/brave-browser#6351

Submitter Checklist:

Test Plan:

  • Confirm ledger state is persisted for upgrade paths
  • Confirm ledger state is persisted for fresh installs

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@tmancey
Copy link
Collaborator Author

tmancey commented Nov 21, 2019

c465ab7 is legacy code just refactored to use new code/properties. Legacy code should not be considered

@tmancey tmancey force-pushed the issues/6351 branch 3 times, most recently from 1dd45c4 to 2ed0bd9 Compare November 21, 2019 11:21
Copy link
Contributor

@masparrow masparrow left a comment

Choose a reason for hiding this comment

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

👍

@NejcZdovc
Copy link
Contributor

I would suggest that we don't add append Properties to every struck. It sounds redundant. We could just do CurrentReconcileProperties -> CurrentReconcile or if we are worried about collision put all properties in a separate namespace. Some names are real long because of that and require a lot of typing 😃 wdyt @tmancey ?

@tmancey
Copy link
Collaborator Author

tmancey commented Nov 25, 2019

I would suggest that we don't add append Properties to every struck. It sounds redundant. We could just do CurrentReconcileProperties -> CurrentReconcile or if we are worried about collision put all properties in a separate namespace. Some names are real long because of that and require a lot of typing 😃 wdyt @tmancey ?

@NejcZdovc Following style guide at https://google.github.io/styleguide/cppguide.html#Type_Names and also within the same BUILD.gn sources we cannot have the same class name so by having wallet_properties.cc and WalletProperties this resolves the issue. Also makes code clear what is a data structure and what is an object.

@NejcZdovc
Copy link
Contributor

NejcZdovc commented Nov 25, 2019

@tmancey that may be, but one thing to consider is that we will put everything that will be left after anonize removal into mojo, where we don't have *Properties. This will mean another big renaming refactor, which could be avoided in my opinion.

Also I think we need to have this two the same ledger::Transactions vs ledger::TransactionProperties. So adding Properties to the vector. Now it looks like they are different structs

@tmancey tmancey force-pushed the issues/6351 branch 3 times, most recently from 6d88c7e to a3a3f04 Compare November 27, 2019 13:55
@tmancey tmancey added CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-linux CI/skip-macos-x64 Do not run CI builds for macOS x64 labels Nov 28, 2019
@tmancey
Copy link
Collaborator Author

tmancey commented Nov 28, 2019

CI passed for all builds other than Windows. Rebuilding Windows

@tmancey tmancey removed CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-linux CI/skip-macos-x64 Do not run CI builds for macOS x64 labels Nov 28, 2019
@tmancey tmancey force-pushed the issues/6351 branch 3 times, most recently from f38a753 to 4e3bace Compare November 28, 2019 14:19
count = properties.count;
prepare_ballot = properties.prepare_ballot;
proof_ballot = properties.proof_ballot;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there is nothing special in this copy-constructor. Having it declared explicitly prevents generating of move operations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Complex class/struct needs an explicit out-of-line copy constructor as per Chromium style guide

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't agree.
The document explains the style checked by Chromium Style Checker tool.
(https://www.chromium.org/developers/coding-style/chromium-style-checker-errors)
For classes/structs encapsulating other complex types the style requires to have explicit out-of-line constructor/copy-constructor/destructor only if it does non-trival initialization or copying. For other cases, including the one I mentioned above, we should stick with defaulted implementation.

Prefer to use =default:
https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++-dos-and-donts.md#prefer-to-use

Also, initialize members in the declaration where possible:
https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++-dos-and-donts.md#initialize-members-in-the-declaration-where-possible

Copy link
Contributor

@gdregalo gdregalo left a comment

Choose a reason for hiding this comment

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

Approving.
There are many cases when move operations are not generated for types like the one I mentioned in my comments.
When refactoring, please don't forget to default all trival constructors/copy-constructors/destructors and add move operations when necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor loadFromJson from RapidJSON to base::JSONReader
4 participants