Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit c0868a7

Browse files
committed
[[BrowserWidget ]] Implement linux version of cef-based libbrowser API
[[ BrowserWidget ]] Move browser memory code to shared libbrowser_memory.cpp
1 parent cf76aff commit c0868a7

10 files changed

+734
-72
lines changed

libbrowser/include/libbrowser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ typedef bool (*MCBrowserWaitFunction)(void);
140140

141141
MC_DLLEXPORT void MCBrowserLibrarySetAllocator(MCBrowserAllocator p_alloc);
142142
MC_DLLEXPORT void MCBrowserLibrarySetDeallocator(MCBrowserDeallocator p_dealloc);
143-
MC_DLLEXPORT void MCBrowserLibrarySetReallocator(MCBrowserReallocator p_dealloc);
143+
MC_DLLEXPORT void MCBrowserLibrarySetReallocator(MCBrowserReallocator p_realloc);
144144
MC_DLLEXPORT void MCBrowserLibrarySetWaitFunction(MCBrowserWaitFunction p_wait);
145145

146146
typedef void (*MCBrowserRunloopCallback)(void *p_context);

libbrowser/libbrowser.gyp

Lines changed: 74 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@
2727
[
2828
'include/libbrowser.h',
2929

30+
'src/libbrowser_memory.cpp',
3031
'src/libbrowser.cpp',
3132
'src/libbrowser_cef.cpp',
3233
'src/libbrowser_cef.h',
34+
'src/libbrowser_cef_lnx.cpp',
3335
'src/libbrowser_cef_osx.mm',
3436
'src/libbrowser_cefshared_osx.cpp',
37+
'src/libbrowser_cefshared_lnx.cpp',
3538
'src/libbrowser_value.cpp',
3639

40+
'src/signal_restore_posix.cpp',
3741
'src/WebAuthenticationPanel.m',
3842
],
3943

@@ -63,6 +67,18 @@
6367
},
6468
],
6569

70+
[
71+
'OS != "linux"',
72+
{
73+
'sources!':
74+
[
75+
'src/libbrowser_cef_lnx.cpp',
76+
'src/libbrowser_cefshared_lnx.cpp',
77+
'src/signal_restore_posix.cpp',
78+
],
79+
},
80+
],
81+
6682
[
6783
'OS == "mac"',
6884
{
@@ -96,6 +112,16 @@
96112
},
97113
},
98114
],
115+
116+
[
117+
'OS == "mac" or OS == "win" or OS == "linux"',
118+
{
119+
'dependencies':
120+
[
121+
'libbrowser-cefprocess',
122+
],
123+
},
124+
],
99125
],
100126

101127
'direct_dependent_settings':
@@ -138,15 +164,62 @@
138164
'mac_bundle': 1,
139165
'product_name': 'libbrowser-cefprocess',
140166

141-
# OSX, Windows, and Linux only
167+
'dependencies':
168+
[
169+
'../libcore/libcore.gyp:libCore',
170+
'../libfoundation/libfoundation.gyp:libFoundation',
171+
'../thirdparty/libcef/libcef.gyp:libcef_library_wrapper',
172+
'../thirdparty/libcef/libcef.gyp:libcef_stubs',
173+
],
174+
175+
'include_dirs':
176+
[
177+
'include',
178+
],
179+
180+
'sources':
181+
[
182+
'src/libbrowser_memory.cpp',
183+
'src/libbrowser_cefprocess.cpp',
184+
'src/libbrowser_cefprocess_lnx.cpp',
185+
'src/libbrowser_cefprocess_osx.mm',
186+
'src/libbrowser_cefshared_lnx.cpp',
187+
'src/libbrowser_cefshared_osx.cpp',
188+
],
189+
142190
'conditions':
143191
[
192+
# OSX, Windows, and Linux only
144193
[
145194
'OS != "mac" and OS != "win" and OS != "linux"',
146195
{
147196
'type': 'none',
148197
},
149198
],
199+
200+
## Exclusions
201+
[
202+
'OS != "mac"',
203+
{
204+
'sources!':
205+
[
206+
'src/libbrowser_cefprocess_osx.mm',
207+
'src/libbrowser_cefshared_osx.cpp',
208+
],
209+
},
210+
],
211+
212+
[
213+
'OS != "linux"',
214+
{
215+
'sources!':
216+
[
217+
'src/libbrowser_cefprocess_lnx.cpp',
218+
'src/libbrowser_cefshared_lnx.cpp',
219+
],
220+
},
221+
],
222+
150223
[
151224
'OS == "win" or OS == "linux"',
152225
{
@@ -162,26 +235,6 @@
162235
],
163236
],
164237

165-
'dependencies':
166-
[
167-
'../libcore/libcore.gyp:libCore',
168-
'../libfoundation/libfoundation.gyp:libFoundation',
169-
'../thirdparty/libcef/libcef.gyp:libcef_library_wrapper',
170-
'../thirdparty/libcef/libcef.gyp:libcef_stubs',
171-
],
172-
173-
'include_dirs':
174-
[
175-
'include',
176-
],
177-
178-
'sources':
179-
[
180-
'src/libbrowser_cefprocess.cpp',
181-
'src/libbrowser_cefprocess_osx.mm',
182-
'src/libbrowser_cefshared_osx.cpp',
183-
],
184-
185238
'xcode_settings':
186239
{
187240
'INFOPLIST_FILE': 'rsrc/libbrowser-cefprocess-Info.plist',

libbrowser/src/libbrowser.cpp

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -498,52 +498,3 @@ bool MCBrowserRunloopWait()
498498
}
499499

500500
////////////////////////////////////////////////////////////////////////////////
501-
502-
static bool MCBrowserMallocWrapper(size_t p_size, void *&r_mem)
503-
{
504-
void *t_mem;
505-
t_mem = malloc(p_size);
506-
if (t_mem == nil)
507-
return false;
508-
r_mem = t_mem;
509-
return true;
510-
}
511-
512-
static bool MCBrowserReallocWrapper(void *p_mem, size_t p_new_size, void *&r_new_mem)
513-
{
514-
void *t_mem;
515-
t_mem = realloc(p_mem, p_new_size);
516-
if (t_mem == nil)
517-
return false;
518-
519-
r_new_mem = t_mem;
520-
return true;
521-
}
522-
523-
static MCBrowserAllocator s_mem_allocate = MCBrowserMallocWrapper;
524-
static MCBrowserReallocator s_mem_reallocate = MCBrowserReallocWrapper;
525-
static MCBrowserDeallocator s_mem_deallocate = free;
526-
527-
//////////
528-
529-
bool MCBrowserMemoryAllocate(size_t p_size, void *&r_mem)
530-
{
531-
return s_mem_allocate(p_size, r_mem);
532-
}
533-
534-
bool MCBrowserMemoryReallocate(void *p_mem, size_t p_new_size, void *&r_new_mem)
535-
{
536-
return s_mem_reallocate(p_mem, p_new_size, r_new_mem);
537-
}
538-
539-
void MCBrowserMemoryDeallocate(void *p_mem)
540-
{
541-
s_mem_deallocate(p_mem);
542-
}
543-
544-
void MCBrowserMemoryClear(void *p_mem, size_t p_size)
545-
{
546-
memset(p_mem, 0, p_size);
547-
}
548-
549-
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)