no bug - fix merge bustage, CLOSED TREE
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 12 May 2015 16:51:08 +0100
changeset 243532 060f9a5bdcaf2e7fc9cf941bf183c58bb7b7f6ac
parent 243531 ed36c68799441edb22044213af40e406d8d1f131
child 243533 71935b9669d95b44759ceeddf0d6642b7c4a7800
push id59684
push useramarchesini@mozilla.com
push dateTue, 12 May 2015 15:51:45 +0000
treeherdermozilla-inbound@060f9a5bdcaf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone41.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
no bug - fix merge bustage, CLOSED TREE
dom/ipc/ContentChild.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2938,8 +2938,149 @@ ContentChild::RecvInvokeDragSession(nsTA
             blobImpl->GetMozFullPathInternal(path, result);
             if (result.Failed()) {
               variant->SetAsISupports(blobImpl);
             } else {
               nsCOMPtr<nsIFile> file;
               NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(path), true, getter_AddRefs(file));
               variant->SetAsISupports(file);
             }
+          } else {
+            continue;
+          }
+          dataTransfer->SetDataWithPrincipal(NS_ConvertUTF8toUTF16(item.flavor()),
+                                             variant, i,
+                                             nsContentUtils::GetSystemPrincipal());
+        }
+      }
+      session->SetDataTransfer(dataTransfer);
+    }
+  }
+  return true;
+}
+
+bool
+ContentChild::RecvEndDragSession(const bool& aDoneDrag,
+                                 const bool& aUserCancelled)
+{
+  nsCOMPtr<nsIDragService> dragService =
+    do_GetService("@mozilla.org/widget/dragservice;1");
+  if (dragService) {
+    if (aUserCancelled) {
+      nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
+      if (dragSession) {
+        dragSession->UserCancelled();
+      }
+    }
+    dragService->EndDragSession(aDoneDrag);
+  }
+  return true;
+}
+
+} // namespace dom
+} // namespace mozilla
+
+extern "C" {
+
+#if defined(MOZ_NUWA_PROCESS)
+NS_EXPORT void
+GetProtoFdInfos(NuwaProtoFdInfo* aInfoList,
+                size_t aInfoListSize,
+                size_t* aInfoSize)
+{
+    size_t i = 0;
+
+    mozilla::dom::ContentChild* content =
+        mozilla::dom::ContentChild::GetSingleton();
+    aInfoList[i].protoId = content->GetProtocolId();
+    aInfoList[i].originFd =
+        content->GetTransport()->GetFileDescriptor();
+    i++;
+
+    IToplevelProtocol* actors[NUWA_TOPLEVEL_MAX];
+    size_t count = content->GetOpenedActorsUnsafe(actors, ArrayLength(actors));
+    for (size_t j = 0; j < count; j++) {
+        IToplevelProtocol* actor = actors[j];
+        if (i >= aInfoListSize) {
+            NS_RUNTIMEABORT("Too many top level protocols!");
+        }
+
+        aInfoList[i].protoId = actor->GetProtocolId();
+        aInfoList[i].originFd =
+            actor->GetTransport()->GetFileDescriptor();
+        i++;
+    }
+
+    if (i > NUWA_TOPLEVEL_MAX) {
+        NS_RUNTIMEABORT("Too many top level protocols!");
+    }
+    *aInfoSize = i;
+}
+
+class RunAddNewIPCProcess : public nsRunnable
+{
+public:
+    RunAddNewIPCProcess(pid_t aPid,
+                        nsTArray<mozilla::ipc::ProtocolFdMapping>& aMaps)
+        : mPid(aPid)
+    {
+        mMaps.SwapElements(aMaps);
+    }
+
+    NS_IMETHOD Run()
+    {
+        mozilla::dom::ContentChild::GetSingleton()->
+            SendAddNewProcess(mPid, mMaps);
+
+        MOZ_ASSERT(sNuwaForking);
+        sNuwaForking = false;
+
+        return NS_OK;
+    }
+
+private:
+    pid_t mPid;
+    nsTArray<mozilla::ipc::ProtocolFdMapping> mMaps;
+};
+
+/**
+ * AddNewIPCProcess() is called by Nuwa process to tell the parent
+ * process that a new process is created.
+ *
+ * In the newly created process, ResetContentChildTransport() is called to
+ * reset fd for the IPC Channel and the session.
+ */
+NS_EXPORT void
+AddNewIPCProcess(pid_t aPid, NuwaProtoFdInfo* aInfoList, size_t aInfoListSize)
+{
+    nsTArray<mozilla::ipc::ProtocolFdMapping> maps;
+
+    for (size_t i = 0; i < aInfoListSize; i++) {
+        int _fd = aInfoList[i].newFds[NUWA_NEWFD_PARENT];
+        mozilla::ipc::FileDescriptor fd(_fd);
+        mozilla::ipc::ProtocolFdMapping map(aInfoList[i].protoId, fd);
+        maps.AppendElement(map);
+    }
+
+    nsRefPtr<RunAddNewIPCProcess> runner = new RunAddNewIPCProcess(aPid, maps);
+    NS_DispatchToMainThread(runner);
+}
+
+NS_EXPORT void
+OnNuwaProcessReady()
+{
+    mozilla::dom::ContentChild* content =
+        mozilla::dom::ContentChild::GetSingleton();
+    content->SendNuwaReady();
+}
+
+NS_EXPORT void
+AfterNuwaFork()
+{
+    SetCurrentProcessPrivileges(base::PRIVILEGES_DEFAULT);
+#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
+    mozilla::SandboxEarlyInit(XRE_GetProcessType(), /* isNuwa: */ false);
+#endif
+}
+
+#endif // MOZ_NUWA_PROCESS
+
+}