Skip to content

Commit 57d5ea6

Browse files
committed
Merge remote-tracking branch 'origin/master' into ghm
2 parents e609654 + 23b19ee commit 57d5ea6

File tree

134 files changed

+2985
-652
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+2985
-652
lines changed

Android/firebase_dependencies.gradle

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ import org.gradle.util.ConfigureUtil;
1616

1717
// A map of library to the dependencies that need to be added for it.
1818
def firebaseDependenciesMap = [
19-
'app' : ['com.google.firebase:firebase-analytics:17.2.1'],
19+
'app' : ['com.google.firebase:firebase-analytics:17.2.2'],
2020
'admob' : ['com.google.firebase:firebase-ads:18.3.0',
21-
'com.google.android.gms:play-services-measurement-sdk-api:17.2.1'],
22-
'analytics' : ['com.google.firebase:firebase-analytics:17.2.1'],
21+
'com.google.android.gms:play-services-measurement-sdk-api:17.2.2'],
22+
'analytics' : ['com.google.firebase:firebase-analytics:17.2.2'],
2323
'auth' : ['com.google.firebase:firebase-auth:19.2.0'],
24-
'database' : ['com.google.firebase:firebase-database:19.2.0'],
24+
'database' : ['com.google.firebase:firebase-database:19.2.1'],
2525
'dynamic_links' : ['com.google.firebase:firebase-dynamic-links:19.0.0'],
26-
'functions' : ['com.google.firebase:firebase-functions:19.0.1'],
26+
'functions' : ['com.google.firebase:firebase-functions:19.0.2'],
2727
'instance_id' : ['com.google.firebase:firebase-iid:20.0.2'],
2828
'invites' : ['com.google.firebase:firebase-invites:17.0.0'],
2929
// Messaging has an additional local dependency to include.
3030
'messaging' : ['com.google.firebase:firebase-messaging:20.1.0',
3131
'firebase_cpp_sdk.messaging:messaging_java'],
32-
'performance' : ['com.google.firebase:firebase-perf:19.0.4'],
33-
'remote_config' : ['com.google.firebase:firebase-config:19.1.0'],
34-
'storage' : ['com.google.firebase:firebase-storage:19.1.0']
32+
'performance' : ['com.google.firebase:firebase-perf:19.0.5'],
33+
'remote_config' : ['com.google.firebase:firebase-config:19.1.1'],
34+
'storage' : ['com.google.firebase:firebase-storage:19.1.1']
3535
]
3636

3737
// A map of library to the gradle resources that they depend upon.

CMakeLists.txt

+13-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@ endif()
120120

121121
# Some of the external libraries are not used for mobile.
122122
if (NOT ANDROID AND NOT IOS)
123+
# Use the static versions of the OpenSSL libraries.
124+
set(OPENSSL_USE_STATIC_LIBS TRUE)
125+
if (MSVC)
126+
# Get the correct version of the OpenSSL libraries based on building for MT.
127+
if ("${CMAKE_CXX_FLAGS_DEBUG}" MATCHES "/MT" OR
128+
"${CMAKE_CXX_FLAGS_RELEASE}" MATCHES "/MT")
129+
set(OPENSSL_MSVC_STATIC_RT TRUE)
130+
else()
131+
set(OPENSSL_MSVC_STATIC_RT FALSE)
132+
endif()
133+
endif()
134+
123135
# Build curl as a static library
124136
set(CURL_STATICLIB ON CACHE BOOL "")
125137
if (WIN32)
@@ -185,7 +197,7 @@ if (NOT ANDROID AND NOT IOS)
185197
)
186198
target_link_libraries(libuWS
187199
PRIVATE
188-
${OPENSSL_SSL_LIBRARY}
200+
${OPENSSL_LIBRARIES}
189201
uv_a
190202
zlibstatic
191203
)

admob/admob_resources/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ android {
4545
}
4646

4747
dependencies {
48-
implementation 'com.google.firebase:firebase-analytics:17.2.1'
48+
implementation 'com.google.firebase:firebase-analytics:17.2.2'
4949
implementation 'com.google.firebase:firebase-ads:18.3.0'
5050
}
5151

app/app_resources/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ android {
4646
}
4747

4848
dependencies {
49-
implementation 'com.google.firebase:firebase-analytics:17.2.1'
49+
implementation 'com.google.firebase:firebase-analytics:17.2.2'
5050
}
5151

5252
afterEvaluate {

app/google_api_resources/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ android {
4949
}
5050

5151
dependencies {
52-
implementation 'com.google.firebase:firebase-analytics:17.2.1'
52+
implementation 'com.google.firebase:firebase-analytics:17.2.2'
5353
implementation project(':app:app_resources')
5454
}
5555

app/invites_resources/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ android {
4545
}
4646

4747
dependencies {
48-
implementation 'com.google.firebase:firebase-analytics:17.2.1'
48+
implementation 'com.google.firebase:firebase-analytics:17.2.2'
4949
implementation 'com.google.firebase:firebase-dynamic-links:19.0.0'
5050
implementation project(':app:app_resources')
5151
}

app/rest/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ target_link_libraries(firebase_rest_lib
7676
flatbuffers
7777
libcurl
7878
zlibstatic
79+
${CMAKE_DL_LIBS}
7980
)
8081
# Automatically include headers that might not be declared.
8182
if(MSVC)

app/src/app_options.cc

+7-5
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ bool AppOptions::PopulateRequiredWithDefaults(
179179
JNIEnv* jni_env, jobject activity
180180
#endif // FIREBASE_PLATFORM_ANDROID
181181
) {
182-
// Populate App ID and API key from the default options if they're not
183-
// specified.
184-
if (app_id_.empty() || api_key_.empty()) {
182+
// Populate App ID, API key, and Project ID from the default options if
183+
// they're not specified.
184+
if (app_id_.empty() || api_key_.empty() || project_id_.empty()) {
185185
AppOptions default_options;
186186
if (AppOptions::LoadDefault(&default_options
187187
#if FIREBASE_PLATFORM_ANDROID
@@ -190,13 +190,15 @@ bool AppOptions::PopulateRequiredWithDefaults(
190190
)) {
191191
if (app_id_.empty()) app_id_ = default_options.app_id_;
192192
if (api_key_.empty()) api_key_ = default_options.api_key_;
193+
if (project_id_.empty()) project_id_ = default_options.project_id_;
193194
} else {
194195
LogError("Failed to load default options when attempting to populate "
195196
"missing fields");
196197
}
197198
}
198-
if (app_id_.empty() || api_key_.empty()) {
199-
LogError("App ID and API key must be specified in App options.");
199+
if (app_id_.empty() || api_key_.empty() || project_id_.empty()) {
200+
LogError(
201+
"App ID, API key, and Project ID must be specified in App options.");
200202
return false;
201203
}
202204
return true;

app/src/callback.cc

+42-26
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <list>
2020

21+
#include "app/memory/shared_ptr.h"
2122
#include "app/src/log.h"
2223
#include "app/src/mutex.h"
2324
#include "app/src/semaphore.h"
@@ -32,7 +33,7 @@ namespace callback {
3233

3334
class CallbackEntry;
3435

35-
class CallbackQueue : public std::list<CallbackEntry*> {
36+
class CallbackQueue : public std::list<SharedPtr<CallbackEntry>> {
3637
public:
3738
CallbackQueue() {}
3839
~CallbackQueue() {}
@@ -51,7 +52,7 @@ class CallbackEntry {
5152
// callback_mutex_ is used to enforce a critical section for callback
5253
// execution and destruction.
5354
CallbackEntry(Callback* callback, Mutex* callback_mutex)
54-
: callback_(callback), mutex_(callback_mutex) {}
55+
: callback_(callback), mutex_(callback_mutex), executing_(false) {}
5556

5657
// Destroy the callback. This blocks if the callback is currently
5758
// executing.
@@ -61,35 +62,47 @@ class CallbackEntry {
6162
// Returns true if a callback was associated with this entry and was executed,
6263
// false otherwise.
6364
bool Execute() {
64-
bool executed = false;
65-
MutexLock lock(*mutex_);
66-
if (callback_) {
67-
callback_->Run();
68-
// Note: The implementation of BlockingCallback below relies on the
69-
// callback being disabled after being run. If that changes, please
70-
// make sure to also update BlockingCallback.
71-
DisableCallback();
72-
executed = true;
65+
{
66+
MutexLock lock(*mutex_);
67+
if (!callback_) return false;
68+
executing_ = true;
7369
}
74-
return executed;
70+
71+
callback_->Run();
72+
73+
{
74+
MutexLock lock(*mutex_);
75+
executing_ = false;
76+
}
77+
78+
// Note: The implementation of BlockingCallback below relies on the
79+
// callback being disabled after being run. If that changes, please
80+
// make sure to also update BlockingCallback.
81+
DisableCallback();
82+
83+
return true;
7584
}
7685

7786
// Remove the callback method from this entry.
7887
bool DisableCallback() {
79-
MutexLock lock(*mutex_);
80-
if (callback_) {
81-
delete callback_;
88+
Callback* callback_to_delete = nullptr;
89+
{
90+
MutexLock lock(*mutex_);
91+
if (executing_ || !callback_) return false;
92+
callback_to_delete = callback_;
8293
callback_ = nullptr;
83-
return true;
8494
}
85-
return false;
95+
delete callback_to_delete;
96+
return true;
8697
}
8798

8899
private:
89100
// Callback to call from PollCallbacks().
90101
Callback* callback_;
91-
// Mutex that is held when modifying callback_.
102+
// Mutex that is held when modifying callback_ and executing_.
92103
Mutex* mutex_;
104+
// A flag set to true when callback_ is about to be called.
105+
bool executing_;
93106
};
94107

95108
// Dispatches a queue of callbacks.
@@ -106,18 +119,18 @@ class CallbackDispatcher {
106119
remaining_callbacks);
107120
}
108121
while (!queue_.empty()) {
109-
delete queue_.back();
122+
queue_.back().reset();
110123
queue_.pop_back();
111124
}
112125
}
113126

114127
// Add a callback to the dispatch queue returning a reference
115128
// to the entry which can be optionally be removed prior to dispatch.
116129
void* AddCallback(Callback* callback) {
117-
CallbackEntry* entry = new CallbackEntry(callback, &execution_mutex_);
130+
auto entry = MakeShared<CallbackEntry>(callback, &execution_mutex_);
118131
MutexLock lock(*queue_.mutex());
119132
queue_.push_back(entry);
120-
return entry;
133+
return entry.get();
121134
}
122135

123136
// Remove the callback reference from the specified entry.
@@ -137,16 +150,19 @@ class CallbackDispatcher {
137150
int DispatchCallbacks() {
138151
int dispatched = 0;
139152
Mutex* queue_mutex = queue_.mutex();
140-
MutexLock lock(*queue_mutex);
153+
queue_mutex->Acquire();
141154
while (!queue_.empty()) {
142-
CallbackEntry* callback_entry = queue_.front();
155+
// Make a copy of the SharedPtr in case FlushCallbacks() is called
156+
// currently.
157+
SharedPtr<CallbackEntry> callback_entry = queue_.front();
143158
queue_.pop_front();
144159
queue_mutex->Release();
145160
callback_entry->Execute();
146161
dispatched++;
147162
queue_mutex->Acquire();
148-
delete callback_entry;
163+
callback_entry.reset();
149164
}
165+
queue_mutex->Release();
150166
return dispatched;
151167
}
152168

@@ -155,7 +171,7 @@ class CallbackDispatcher {
155171
int flushed = 0;
156172
MutexLock lock(*queue_.mutex());
157173
while (!queue_.empty()) {
158-
delete queue_.front();
174+
queue_.front().reset();
159175
queue_.pop_front();
160176
flushed++;
161177
}
@@ -299,7 +315,7 @@ void RemoveCallback(void* callback_reference) {
299315
// remove the CallbackEntry from the queue so we don't need an additional
300316
// Terminate() here to decrement the reference count that was added by
301317
// AddCallback().
302-
static_cast<CallbackEntry*>(callback_reference)->DisableCallback();
318+
g_callback_dispatcher->DisableCallback(callback_reference);
303319
Terminate(false);
304320
}
305321
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2020 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "UIKit/UIKit.h"
18+
19+
@interface FIRAppDelegate : UIResponder <UIApplicationDelegate>
20+
21+
@property(strong, nonatomic) UIWindow *window;
22+
23+
@end
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2020 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "FIRAppDelegate.h"
18+
19+
@implementation FIRAppDelegate
20+
21+
- (BOOL)application:(UIApplication *)application
22+
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
23+
// Override point for customization after application launch.
24+
return YES;
25+
}
26+
27+
- (void)applicationWillResignActive:(UIApplication *)application {
28+
// Sent when the application is about to move from active to inactive state. This can occur for
29+
// certain types of temporary interruptions (such as an incoming phone call or SMS message) or
30+
// when the user quits the application and it begins the transition to the background state. Use
31+
// this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates.
32+
// Games should use this method to pause the game.
33+
}
34+
35+
- (void)applicationDidEnterBackground:(UIApplication *)application {
36+
// Use this method to release shared resources, save user data, invalidate timers, and store
37+
// enough application state information to restore your application to its current state in case
38+
// it is terminated later. If your application supports background execution, this method is
39+
// called instead of applicationWillTerminate: when the user quits.
40+
}
41+
42+
- (void)applicationWillEnterForeground:(UIApplication *)application {
43+
// Called as part of the transition from the background to the inactive state; here you can undo
44+
// many of the changes made on entering the background.
45+
}
46+
47+
- (void)applicationDidBecomeActive:(UIApplication *)application {
48+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If
49+
// the application was previously in the background, optionally refresh the user interface.
50+
}
51+
52+
- (void)applicationWillTerminate:(UIApplication *)application {
53+
// Called when the application is about to terminate. Save data if appropriate. See also
54+
// applicationDidEnterBackground:.
55+
}
56+
57+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2020 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "UIKit/UIKit.h"
18+
19+
@interface FIRViewController : UIViewController
20+
21+
@end

0 commit comments

Comments
 (0)