зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
39be3999c2
Коммит
f7d646647b
|
@ -46,6 +46,11 @@
|
||||||
#include "nsIDOMMouseEvent.h"
|
#include "nsIDOMMouseEvent.h"
|
||||||
#include "nsIDOMUIEvent.h"
|
#include "nsIDOMUIEvent.h"
|
||||||
|
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsISupportsUtils.h"
|
||||||
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsIObserverService.h"
|
||||||
|
|
||||||
#include "nsStringAPI.h"
|
#include "nsStringAPI.h"
|
||||||
#include "gtkmozembed_glue.cpp"
|
#include "gtkmozembed_glue.cpp"
|
||||||
|
|
||||||
|
@ -57,6 +62,7 @@ typedef struct _TestGtkBrowser {
|
||||||
GtkWidget *fileMenu;
|
GtkWidget *fileMenu;
|
||||||
GtkWidget *fileOpenNewBrowser;
|
GtkWidget *fileOpenNewBrowser;
|
||||||
GtkWidget *fileStream;
|
GtkWidget *fileStream;
|
||||||
|
GtkWidget *fileMemory;
|
||||||
GtkWidget *fileClose;
|
GtkWidget *fileClose;
|
||||||
GtkWidget *fileQuit;
|
GtkWidget *fileQuit;
|
||||||
GtkWidget *toolbarHBox;
|
GtkWidget *toolbarHBox;
|
||||||
|
@ -107,6 +113,8 @@ static void menu_open_new_cb (GtkMenuItem *menuitem,
|
||||||
TestGtkBrowser *browser);
|
TestGtkBrowser *browser);
|
||||||
static void menu_stream_cb (GtkMenuItem *menuitem,
|
static void menu_stream_cb (GtkMenuItem *menuitem,
|
||||||
TestGtkBrowser *browser);
|
TestGtkBrowser *browser);
|
||||||
|
static void menu_memory_cb (GtkMenuItem *menuitem,
|
||||||
|
TestGtkBrowser *browser);
|
||||||
static void menu_close_cb (GtkMenuItem *menuitem,
|
static void menu_close_cb (GtkMenuItem *menuitem,
|
||||||
TestGtkBrowser *browser);
|
TestGtkBrowser *browser);
|
||||||
static void menu_quit_cb (GtkMenuItem *menuitem,
|
static void menu_quit_cb (GtkMenuItem *menuitem,
|
||||||
|
@ -328,6 +336,11 @@ new_gtk_browser(guint32 chromeMask)
|
||||||
gtk_menu_append(GTK_MENU(browser->fileMenu),
|
gtk_menu_append(GTK_MENU(browser->fileMenu),
|
||||||
browser->fileStream);
|
browser->fileStream);
|
||||||
|
|
||||||
|
browser->fileMemory =
|
||||||
|
gtk_menu_item_new_with_label("Release Memory");
|
||||||
|
gtk_menu_append(GTK_MENU(browser->fileMenu),
|
||||||
|
browser->fileMemory);
|
||||||
|
|
||||||
browser->fileClose =
|
browser->fileClose =
|
||||||
gtk_menu_item_new_with_label("Close");
|
gtk_menu_item_new_with_label("Close");
|
||||||
gtk_menu_append(GTK_MENU(browser->fileMenu),
|
gtk_menu_append(GTK_MENU(browser->fileMenu),
|
||||||
|
@ -465,6 +478,9 @@ new_gtk_browser(guint32 chromeMask)
|
||||||
// hook up to the stream test
|
// hook up to the stream test
|
||||||
gtk_signal_connect(GTK_OBJECT(browser->fileStream), "activate",
|
gtk_signal_connect(GTK_OBJECT(browser->fileStream), "activate",
|
||||||
GTK_SIGNAL_FUNC(menu_stream_cb), browser);
|
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
|
// close this window
|
||||||
gtk_signal_connect(GTK_OBJECT(browser->fileClose), "activate",
|
gtk_signal_connect(GTK_OBJECT(browser->fileClose), "activate",
|
||||||
GTK_SIGNAL_FUNC(menu_close_cb), browser);
|
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));
|
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
|
void
|
||||||
menu_close_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
|
menu_close_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче