Bug 1285572 - Move ResolveURI to nsAppShell; r=snorp
authorJim Chen <nchen@mozilla.com>
Wed, 20 Jul 2016 21:43:34 -0400
changeset 346006 56b6362b516e71447964b615b7c1fb8f9889f590
parent 346005 fdefc01b91dfb9e227522f5319f312b4309ed6f9
child 346007 a2608d51d577c86d8092f8856cc8cd3363b2443f
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1285572
milestone50.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
Bug 1285572 - Move ResolveURI to nsAppShell; r=snorp Change ResolveURI to be a member function of nsAppShell, so that code outside of nsAppShell can use it.
widget/android/nsAppShell.cpp
widget/android/nsAppShell.h
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -128,39 +128,16 @@ public:
     return NS_OK;
   }
 };
 
 NS_IMPL_ISUPPORTS(WakeLockListener, nsIDOMMozWakeLockListener)
 nsCOMPtr<nsIPowerManagerService> sPowerManagerService = nullptr;
 StaticRefPtr<WakeLockListener> sWakeLockListener;
 
-namespace {
-
-already_AddRefed<nsIURI>
-ResolveURI(const nsCString& uriStr)
-{
-    nsCOMPtr<nsIIOService> ioServ = do_GetIOService();
-    nsCOMPtr<nsIURI> uri;
-
-    if (NS_SUCCEEDED(ioServ->NewURI(uriStr, nullptr,
-                                    nullptr, getter_AddRefs(uri)))) {
-        return uri.forget();
-    }
-
-    nsCOMPtr<nsIURIFixup> fixup = do_GetService(NS_URIFIXUP_CONTRACTID);
-    if (fixup && NS_SUCCEEDED(
-            fixup->CreateFixupURI(uriStr, 0, nullptr, getter_AddRefs(uri)))) {
-        return uri.forget();
-    }
-    return nullptr;
-}
-
-} // namespace
-
 
 class GeckoThreadSupport final
     : public widget::GeckoThread::Natives<GeckoThreadSupport>
     , public UsesGeckoThreadProxy
 {
     static uint32_t sPauseCount;
 
 public:
@@ -171,33 +148,33 @@ public:
             aCall.IsTarget(&WaitOnGecko)) {
 
             aCall();
             return;
         }
         return UsesGeckoThreadProxy::OnNativeCall(aCall);
     }
 
-    static void SpeculativeConnect(jni::String::Param uriStr)
+    static void SpeculativeConnect(jni::String::Param aUriStr)
     {
         if (!NS_IsMainThread()) {
             // We will be on the main thread if the call was queued on the Java
             // side during startup. Otherwise, the call was not queued, which
             // means Gecko is already sufficiently loaded, and we don't really
             // care about speculative connections at this point.
             return;
         }
 
         nsCOMPtr<nsIIOService> ioServ = do_GetIOService();
         nsCOMPtr<nsISpeculativeConnect> specConn = do_QueryInterface(ioServ);
         if (!specConn) {
             return;
         }
 
-        nsCOMPtr<nsIURI> uri = ResolveURI(uriStr->ToCString());
+        nsCOMPtr<nsIURI> uri = nsAppShell::ResolveURI(aUriStr->ToCString());
         if (!uri) {
             return;
         }
         specConn->SpeculativeConnect(uri, nullptr);
     }
 
     static void WaitOnGecko()
     {
@@ -653,16 +630,35 @@ nsAppShell::SyncRunEvent(Event&& event,
 
     appShell->mEventQueue.Post(mozilla::Move(runAndNotifyEvent));
 
     while (!finished && MOZ_LIKELY(sAppShell && !sAppShell->mSyncRunQuit)) {
         appShell->mSyncRunFinished.Wait();
     }
 }
 
+already_AddRefed<nsIURI>
+nsAppShell::ResolveURI(const nsCString& aUriStr)
+{
+    nsCOMPtr<nsIIOService> ioServ = do_GetIOService();
+    nsCOMPtr<nsIURI> uri;
+
+    if (NS_SUCCEEDED(ioServ->NewURI(aUriStr, nullptr,
+                                    nullptr, getter_AddRefs(uri)))) {
+        return uri.forget();
+    }
+
+    nsCOMPtr<nsIURIFixup> fixup = do_GetService(NS_URIFIXUP_CONTRACTID);
+    if (fixup && NS_SUCCEEDED(
+            fixup->CreateFixupURI(aUriStr, 0, nullptr, getter_AddRefs(uri)))) {
+        return uri.forget();
+    }
+    return nullptr;
+}
+
 class nsAppShell::LegacyGeckoEvent : public Event
 {
     mozilla::UniquePtr<AndroidGeckoEvent> ae;
 
 public:
     LegacyGeckoEvent(AndroidGeckoEvent* e) : ae(e) {}
 
     void Run() override;
--- a/widget/android/nsAppShell.h
+++ b/widget/android/nsAppShell.h
@@ -134,16 +134,18 @@ public:
 
     static void PostEvent(mozilla::AndroidGeckoEvent* event);
 
     // Post a event and wait for it to finish running on the Gecko thread.
     static void SyncRunEvent(Event&& event,
                              mozilla::UniquePtr<Event>(*eventFactory)(
                                     mozilla::UniquePtr<Event>&&) = nullptr);
 
+    static already_AddRefed<nsIURI> ResolveURI(const nsCString& aUriStr);
+
     void SetBrowserApp(nsIAndroidBrowserApp* aBrowserApp) {
         mBrowserApp = aBrowserApp;
     }
 
     void GetBrowserApp(nsIAndroidBrowserApp* *aBrowserApp) {
         *aBrowserApp = mBrowserApp;
     }