[iOS] Ensure local state is commited on app background
Also adds a commit immediately after setting p3a enabled
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user