[iOS] Ensure local state is commited on app background

Also adds a commit immediately after setting p3a enabled
This commit is contained in:
Kyle Hickinson
2022-12-02 11:34:57 -05:00
parent b53d9c6e62
commit 8501005f1c
2 changed files with 10 additions and 1 deletions
+8 -1
View File
@@ -212,8 +212,12 @@ const BraveCoreLogSeverity BraveCoreLogSeverityVerbose =
- (void)onAppEnterBackground:(NSNotification*)notification {
auto* context = GetApplicationContext();
if (context)
if (context) {
context->OnAppEnterBackground();
// Since we don't use the WebViewWebMainParts, local state is never commited
// on app background
context->GetLocalState()->CommitPendingWrite();
}
}
- (void)onAppEnterForeground:(NSNotification*)notification {
@@ -223,6 +227,9 @@ const BraveCoreLogSeverity BraveCoreLogSeverityVerbose =
}
- (void)onAppWillTerminate:(NSNotification*)notification {
// ApplicationContextImpl doesn't get teardown call at the moment because we
// cannot dealloc this class yet without crashing.
GetApplicationContext()->GetLocalState()->CommitPendingWrite();
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
+2
View File
@@ -38,6 +38,7 @@
- (void)setIsP3AEnabled:(bool)isP3AEnabled {
_localState->SetBoolean(brave::kP3AEnabled, isP3AEnabled);
_localState->CommitPendingWrite();
}
- (bool)isNoticeAcknowledged {
@@ -46,6 +47,7 @@
- (void)setIsNoticeAcknowledged:(bool)isNoticeAcknowledged {
_localState->SetBoolean(brave::kP3ANoticeAcknowledged, isNoticeAcknowledged);
_localState->CommitPendingWrite();
}
- (BraveHistogramsController*)histogramsController {