Skip to content

Commit 0841a2d

Browse files
committed
Automated g4 rollback of changelist 280497743.
*** Reason for rollback *** The instance id desktop impl internally is hidden behind the EAP flag, and the correct usage of the library is to always link against it, and let the desktop impl worry about it. *** Original change description *** Firebase Cpp: Fixed build issue with open source and removal of instance id for desktop *** PiperOrigin-RevId: 280690993
1 parent 1eaa088 commit 0841a2d

File tree

1 file changed

+29
-37
lines changed

1 file changed

+29
-37
lines changed

remote_config/src/desktop/rest.cc

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
#include <sstream>
2121

2222
#include "firebase/app.h"
23-
#ifdef FIREBASE_EARLY_ACCESS_PREVIEW
2423
#include "app/instance_id/instance_id_desktop_impl.h"
25-
#endif
2624
#include "app/meta/move.h"
2725
#include "app/rest/request_binary.h"
2826
#include "app/rest/response_binary.h"
@@ -52,35 +50,6 @@ const int SDK_PATCH_VERSION = 0;
5250

5351
const char kTokenScope[] = "*";
5452

55-
namespace {
56-
#ifdef FIREBASE_EARLY_ACCESS_PREVIEW
57-
void WaitForInstanceIdFuture(const Future<std::string>& future,
58-
Semaphore* future_sem, std::string* result, const char* action_name) {
59-
// Block and wait until Future is complete.
60-
future.OnCompletion(
61-
[](const firebase::Future<std::string>& result, void* data) {
62-
Semaphore* sem = static_cast<Semaphore*>(data);
63-
sem->Post();
64-
},
65-
future_sem);
66-
future_sem->Wait();
67-
68-
if (future.status() == firebase::kFutureStatusComplete &&
69-
future.error() ==
70-
firebase::instance_id::internal::InstanceIdDesktopImpl::kErrorNone) {
71-
*result = *future.result();
72-
} else if (future.status() != firebase::kFutureStatusComplete) {
73-
// It is fine if timeout
74-
LogWarning("Remote Config Fetch: %s timeout", action_name);
75-
} else {
76-
// It is fine if failed
77-
LogWarning("Remote Config Fetch: Failed to %s. Error %d: %s", action_name,
78-
future.error(), future.error_message());
79-
}
80-
}
81-
#endif
82-
} // namespace
83-
8453
RemoteConfigREST::RemoteConfigREST(const firebase::AppOptions& app_options,
8554
const LayeredConfigs& configs,
8655
uint64_t cache_expiration_in_seconds)
@@ -105,8 +74,32 @@ void RemoteConfigREST::Fetch(const App& app) {
10574
ParseRestResponse();
10675
}
10776

77+
void WaitForFuture(const Future<std::string>& future, Semaphore* future_sem,
78+
std::string* result, const char* action_name) {
79+
// Block and wait until Future is complete.
80+
future.OnCompletion(
81+
[](const firebase::Future<std::string>& result, void* data) {
82+
Semaphore* sem = static_cast<Semaphore*>(data);
83+
sem->Post();
84+
},
85+
future_sem);
86+
future_sem->Wait();
87+
88+
if (future.status() == firebase::kFutureStatusComplete &&
89+
future.error() ==
90+
firebase::instance_id::internal::InstanceIdDesktopImpl::kErrorNone) {
91+
*result = *future.result();
92+
} else if (future.status() != firebase::kFutureStatusComplete) {
93+
// It is fine if timeout
94+
LogWarning("Remote Config Fetch: %s timeout", action_name);
95+
} else {
96+
// It is fine if failed
97+
LogWarning("Remote Config Fetch: Failed to %s. Error %d: %s", action_name,
98+
future.error(), future.error_message());
99+
}
100+
}
101+
108102
void RemoteConfigREST::TryGetInstanceIdAndToken(const App& app) {
109-
#ifdef FIREBASE_EARLY_ACCESS_PREVIEW
110103
// Convert the app reference stored in RemoteConfigDesktop
111104
// pointer for InstanceIdDesktopImpl.
112105
App* non_const_app = const_cast<App*>(&app);
@@ -118,15 +111,14 @@ void RemoteConfigREST::TryGetInstanceIdAndToken(const App& app) {
118111
return;
119112
}
120113

121-
WaitForInstanceIdFuture(iid_impl->GetId(), &fetch_future_sem_,
122-
&app_instance_id_, "Get Instance Id");
114+
WaitForFuture(iid_impl->GetId(), &fetch_future_sem_, &app_instance_id_,
115+
"Get Instance Id");
123116

124117
// Only get token if instance id is retrieved.
125118
if (!app_instance_id_.empty()) {
126-
WaitForInstanceIdFuture(iid_impl->GetToken(kTokenScope), &fetch_future_sem_,
127-
&app_instance_id_token_, "Get Instance Id Token");
119+
WaitForFuture(iid_impl->GetToken(kTokenScope), &fetch_future_sem_,
120+
&app_instance_id_token_, "Get Instance Id Token");
128121
}
129-
#endif
130122
}
131123

132124
void RemoteConfigREST::SetupRestRequest() {

0 commit comments

Comments
 (0)