b=634719 Add a helper to get the nsDragService r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 19 Apr 2012 18:18:31 +1200
changeset 92751 bc7ea0e82d8380cfb958b64b701657df0f7e3ba1
parent 92750 dc6ee8f01e92526e2dce65ea753476ff8f8742b8
child 92752 3c6358d51fa567800fdafa6485a790974e9c47b3
push id8855
push userktomlinson@mozilla.com
push dateMon, 30 Apr 2012 20:56:38 +0000
treeherdermozilla-inbound@c0a2d79ca66d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs634719
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=634719 Add a helper to get the nsDragService r=roc
widget/gtk2/nsDragService.cpp
widget/gtk2/nsDragService.h
--- a/widget/gtk2/nsDragService.cpp
+++ b/widget/gtk2/nsDragService.cpp
@@ -174,16 +174,25 @@ nsDragService::nsDragService()
 nsDragService::~nsDragService()
 {
     PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::~nsDragService"));
 }
 
 NS_IMPL_ISUPPORTS_INHERITED2(nsDragService, nsBaseDragService,
                              nsIDragSessionGTK, nsIObserver)
 
+/* static */ nsDragService*
+nsDragService::GetInstance()
+{
+    static const nsIID iid = NS_DRAGSERVICE_CID;
+    nsCOMPtr<nsIDragService> dragService = do_GetService(iid);
+    return static_cast<nsDragService*>(dragService.get());
+    // We rely on XPCOM keeping a reference to the service.
+}
+
 // nsIObserver
 
 NS_IMETHODIMP
 nsDragService::Observe(nsISupports *aSubject, const char *aTopic,
                        const PRUnichar *aData)
 {
   if (!nsCRT::strcmp(aTopic, "quit-application")) {
     PR_LOG(sDragLm, PR_LOG_DEBUG,
--- a/widget/gtk2/nsDragService.h
+++ b/widget/gtk2/nsDragService.h
@@ -93,16 +93,18 @@ public:
                                       gint               aX,
                                       gint               aY,
                                       GtkSelectionData  *aSelection_data,
                                       guint              aInfo,
                                       guint32            aTime);
 
     NS_IMETHOD TargetSetTimeCallback (nsIDragSessionGTKTimeCB aCallback);
 
+    static nsDragService* GetInstance();
+
     //  END PUBLIC API
 
     // These methods are public only so that they can be called from functions
     // with C calling conventions.  They are called for drags started with the
     // invisible widget.
     void           SourceEndDragSession(GdkDragContext *aContext,
                                         gint            aResult);
     void           SourceDataGet(GtkWidget        *widget,