mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 419918 - Add the ability to fire the memory pressure observers from the embedding test app. Taken from Stuart's ramback extension and made available here for testing. r=dougt, sr=pavlov, a=beltzner
This commit is contained in:
parent
25d68a96ad
commit
c4cc186971
@ -46,6 +46,11 @@
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMUIEvent.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
||||
#include "nsStringAPI.h"
|
||||
#include "gtkmozembed_glue.cpp"
|
||||
|
||||
@ -57,6 +62,7 @@ typedef struct _TestGtkBrowser {
|
||||
GtkWidget *fileMenu;
|
||||
GtkWidget *fileOpenNewBrowser;
|
||||
GtkWidget *fileStream;
|
||||
GtkWidget *fileMemory;
|
||||
GtkWidget *fileClose;
|
||||
GtkWidget *fileQuit;
|
||||
GtkWidget *toolbarHBox;
|
||||
@ -107,6 +113,8 @@ static void menu_open_new_cb (GtkMenuItem *menuitem,
|
||||
TestGtkBrowser *browser);
|
||||
static void menu_stream_cb (GtkMenuItem *menuitem,
|
||||
TestGtkBrowser *browser);
|
||||
static void menu_memory_cb (GtkMenuItem *menuitem,
|
||||
TestGtkBrowser *browser);
|
||||
static void menu_close_cb (GtkMenuItem *menuitem,
|
||||
TestGtkBrowser *browser);
|
||||
static void menu_quit_cb (GtkMenuItem *menuitem,
|
||||
@ -328,6 +336,11 @@ new_gtk_browser(guint32 chromeMask)
|
||||
gtk_menu_append(GTK_MENU(browser->fileMenu),
|
||||
browser->fileStream);
|
||||
|
||||
browser->fileMemory =
|
||||
gtk_menu_item_new_with_label("Release Memory");
|
||||
gtk_menu_append(GTK_MENU(browser->fileMenu),
|
||||
browser->fileMemory);
|
||||
|
||||
browser->fileClose =
|
||||
gtk_menu_item_new_with_label("Close");
|
||||
gtk_menu_append(GTK_MENU(browser->fileMenu),
|
||||
@ -465,6 +478,9 @@ new_gtk_browser(guint32 chromeMask)
|
||||
// hook up to the stream test
|
||||
gtk_signal_connect(GTK_OBJECT(browser->fileStream), "activate",
|
||||
GTK_SIGNAL_FUNC(menu_stream_cb), browser);
|
||||
// hook up the memory pressure release function
|
||||
gtk_signal_connect(GTK_OBJECT(browser->fileMemory), "activate",
|
||||
GTK_SIGNAL_FUNC(menu_memory_cb), browser);
|
||||
// close this window
|
||||
gtk_signal_connect(GTK_OBJECT(browser->fileClose), "activate",
|
||||
GTK_SIGNAL_FUNC(menu_close_cb), browser);
|
||||
@ -672,6 +688,21 @@ menu_stream_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
|
||||
gtk_moz_embed_close_stream(GTK_MOZ_EMBED(browser->mozEmbed));
|
||||
}
|
||||
|
||||
void
|
||||
menu_memory_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
|
||||
{
|
||||
g_print("menu_memory_cb\n");
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
if (!os)
|
||||
return;
|
||||
|
||||
// Compact like you mean it. We do this three times to give the
|
||||
// cycle collector a chance to try and reclaim as much as we can.
|
||||
os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get());
|
||||
os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get());
|
||||
os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get());
|
||||
}
|
||||
|
||||
void
|
||||
menu_close_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user