Last active
July 8, 2016 23:09
-
-
Save brendandahl/e0d7b90076f1deb85daead0b75a33981 to your computer and use it in GitHub Desktop.
Attempt at adding an observer before XRE_main runs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in main.cpp | |
#include "nsIObserver.h" | |
#include "nsIObserverService.h" | |
#include "nsServiceManagerUtils.h" | |
class nsBlahObserver final : public nsIObserver | |
{ | |
public: | |
NS_DECL_ISUPPORTS | |
NS_DECL_NSIOBSERVER | |
nsBlahObserver() {} | |
protected: | |
~nsBlahObserver() {} | |
}; | |
NS_IMPL_ISUPPORTS(nsBlahObserver, nsIObserver) | |
NS_IMETHODIMP | |
nsBlahObserver::Observe(nsISupports* aSubject, const char* aTopic, | |
const char16_t* aData) | |
{ | |
printf("!!!!!!!!!!!%s\n", aTopic); | |
return NS_OK; | |
} | |
// in main(): | |
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1")); | |
if (os) { | |
nsBlahObserver* observer = new nsBlahObserver();; | |
os->AddObserver(observer, "abc", false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment