-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathperformance_common.cc
More file actions
63 lines (54 loc) · 1.77 KB
/
Copy pathperformance_common.cc
File metadata and controls
63 lines (54 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2021 Google LLC
#include "performance/src/performance_common.h"
#include <assert.h>
#include "app/src/cleanup_notifier.h"
#include "app/src/util.h"
#include "performance/src/include/firebase/performance.h"
// Register the module initializer.
FIREBASE_APP_REGISTER_CALLBACKS(
performance,
{
if (app == ::firebase::App::GetInstance()) {
return firebase::performance::Initialize(*app);
}
return kInitResultSuccess;
},
{
if (app == ::firebase::App::GetInstance()) {
firebase::performance::Terminate();
}
},
false);
namespace firebase {
namespace performance {
namespace internal {
const char* kPerformanceModuleName = "performance";
void RegisterTerminateOnDefaultAppDestroy() {
if (!AppCallback::GetEnabledByName(kPerformanceModuleName)) {
CleanupNotifier* cleanup_notifier =
CleanupNotifier::FindByOwner(App::GetInstance());
assert(cleanup_notifier);
cleanup_notifier->RegisterObject(
const_cast<char*>(kPerformanceModuleName), [](void*) {
LogError(
"performance::Terminate() should be called before default app is "
"destroyed.");
if (firebase::performance::internal::IsInitialized()) {
firebase::performance::Terminate();
}
});
}
}
void UnregisterTerminateOnDefaultAppDestroy() {
if (!AppCallback::GetEnabledByName(kPerformanceModuleName) &&
firebase::performance::internal::IsInitialized()) {
CleanupNotifier* cleanup_notifier =
CleanupNotifier::FindByOwner(App::GetInstance());
assert(cleanup_notifier);
cleanup_notifier->UnregisterObject(
const_cast<char*>(kPerformanceModuleName));
}
}
} // namespace internal
} // namespace performance
} // namespace firebase