14
14
* limitations under the License.
15
15
*/
16
16
17
+ #include " app/src/app_desktop.h"
18
+
17
19
#include < string.h>
18
20
19
21
#include < fstream>
22
+ #include < memory>
23
+ #include < string>
20
24
21
25
#include " app/src/app_common.h"
22
26
#include " app/src/function_registry.h"
27
+ #include " app/src/heartbeat/heartbeat_controller_desktop.h"
23
28
#include " app/src/include/firebase/app.h"
24
29
#include " app/src/include/firebase/internal/common.h"
25
30
#include " app/src/include/firebase/version.h"
29
34
namespace firebase {
30
35
DEFINE_FIREBASE_VERSION_STRING (Firebase);
31
36
32
- namespace internal {
33
-
34
- class AppInternal {
35
- public:
36
- // A registry that modules can use to expose functions to each other, without
37
- // requiring a linkage dependency.
38
- // todo - make all the implementations use something like this, for internal
39
- // or implementation-specific code. b/70229654
40
- FunctionRegistry function_registry;
41
- };
42
-
43
- // When Create() is invoked without arguments, it checks for a file named
44
- // google-services-desktop.json, to load options from. This specifies the
45
- // path to search.
46
- static std::string g_default_config_path; // NOLINT
47
-
48
- } // namespace internal
49
-
50
37
namespace {
51
38
52
39
// Size is arbitrary, just making sure that there is a sane limit.
@@ -150,6 +137,15 @@ App* App::Create(const AppOptions& options, const char* name) { // NOLINT
150
137
app->name_ = name;
151
138
app->options_ = options_with_defaults;
152
139
app = app_common::AddApp (app, &app->init_results_ );
140
+ app->internal_ ->heartbeat_controller_ =
141
+ std::make_shared<heartbeat::HeartbeatController>(
142
+ name, *app_common::FindAppLoggerByName (name),
143
+ app->internal_ ->date_provider_ );
144
+ #ifndef SWIG
145
+ // Log a heartbeat after creating an App. In the Unity SDK this will happen
146
+ // at a later time, after additional user agents have been registered.
147
+ app->internal_ ->heartbeat_controller_ ->LogHeartbeat ();
148
+ #endif // SWIG
153
149
}
154
150
return app;
155
151
}
@@ -166,7 +162,7 @@ App* App::GetInstance(const char* name) { // NOLINT
166
162
internal::FunctionRegistry* App::function_registry () {
167
163
return &internal_->function_registry ;
168
164
}
169
- #endif
165
+ #endif // INTERNAL_EXPERIMENTAL
170
166
171
167
void App::RegisterLibrary (const char * library, const char * version) {
172
168
app_common::RegisterLibrary (library, version);
@@ -191,6 +187,21 @@ void App::SetDefaultConfigPath(const char* path) {
191
187
}
192
188
}
193
189
190
+ void App::LogHeartbeat () const {
191
+ if (internal_ != nullptr && internal_->heartbeat_controller_ ) {
192
+ internal_->heartbeat_controller_ ->LogHeartbeat ();
193
+ }
194
+ }
195
+
196
+ std::shared_ptr<heartbeat::HeartbeatController> App::GetHeartbeatController ()
197
+ const {
198
+ if (internal_ != nullptr ) {
199
+ return internal_->heartbeat_controller_ ;
200
+ } else {
201
+ return std::shared_ptr<heartbeat::HeartbeatController>();
202
+ }
203
+ }
204
+
194
205
// Desktop support is for developer workflow only, so automatic data collection
195
206
// is always enabled.
196
207
void App::SetDataCollectionDefaultEnabled (bool /* enabled */ ) {}
0 commit comments