-
Notifications
You must be signed in to change notification settings - Fork 816
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
[SkusSDK] - Rust-C++ FFI Improvements #23658
Conversation
[puLL-Merge] - brave/brave-core@23658 DescriptionThis PR makes changes to the Rust-C++ bindings for the Skus SDK to improve error handling and simplify the callback mechanism between Rust and C++. The main motivation appears to be refactoring the error handling to provide more detailed error messages from Rust to C++, and to streamline the various callback types into a single ChangesChanges
SummaryOverall, this is a sizable refactoring of the Skus SDK bindings to centralize error handling and simplify the callback mechanism between Rust and C++. The changes look reasonable and well-structured. The main points to verify would be:
Assuming thorough testing of the SDK functionality, this PR should improve maintainability of the Skus bindings without introducing new issues. Nice work! |
7f5f865
to
da6213a
Compare
@@ -414,16 +393,14 @@ impl CppSDK { | |||
|
|||
fn submit_receipt( | |||
self: &CppSDK, | |||
callback: SubmitReceiptCallback, | |||
callback_state: UniquePtr<ffi::SubmitReceiptCallbackState>, | |||
callback_state: UniquePtr<ffi::RustBoundPostTask>, |
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.
shouldn't we keep the param name callback
instead of callback_state
?
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.
Fixed.
@@ -9,6 +9,7 @@ | |||
#include <utility> | |||
|
|||
#include "base/logging.h" | |||
#include "base/task/bind_post_task.h" | |||
#include "base/task/sequenced_task_runner.h" |
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.
is this header still used?
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.
Removed.
da6213a
to
97b844c
Compare
…e task running. Refactor Rust Skus to use the RustSequencedCallback directly. Refactor SkusSDK to use the RustSequencedCallback. Refactor Rust Skus to call C++ member functions and remove use of UniquePtr as we no longer have dangling pointers or UB.
97b844c
to
626b1e2
Compare
- Create a OnceCallback version for Rust Skus that's bound to a sequence task running. - Refactor Rust Skus to use the RustBoundTask directly. - Refactor SkusSDK to use the RustBoundTask. Signed-off-by: Brandon T <JustBrandonT@gmail.com>
Summary
extern "C"
, etc. We're able to call C++ member functions directly.some_rust_func(base::BindOnce(&OnceCallback<void(T)>::Run, once_callback, args, ...)
so long asonce_callback
is heap allocated.Resolves brave/brave-browser#38327
This PR is a prerequisite for: #22944 which will be rebased onto this PR.
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: