Bug 1110669: Inherit |RilConsumer| from |StreamSocket|, r=qdot
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 07 Jan 2015 11:19:59 +0100
changeset 248257 9bf521b43c84d4f1252f51e4b072999b81bfe254
parent 248256 14e25d5825f7b562a7458d972e42d1a511e17d32
child 248258 1e76255040adc72259e7d2ccadc05384138b60e2
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1110669
milestone37.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 1110669: Inherit |RilConsumer| from |StreamSocket|, r=qdot |StreamSocket| and |ListenSocket| are replacements for |UnixSocketConsumer| that split connection listening and data transfer into separate classes. |RilConsumer| only requires data transfer, and with this patch it inherits from |StreamSocket| instead of |UnixSocketConsumer|.
ipc/ril/Ril.cpp
ipc/ril/Ril.h
--- a/ipc/ril/Ril.cpp
+++ b/ipc/ril/Ril.cpp
@@ -16,16 +16,17 @@
 #include <android/log.h>
 #define CHROMIUM_LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
 #else
 #define CHROMIUM_LOG(args...)  printf(args);
 #endif
 
 #include "jsfriendapi.h"
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/ipc/UnixSocketConnector.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h" // For NS_IsMainThread.
 
 USING_WORKERS_NAMESPACE
 using namespace mozilla::ipc;
 
 namespace {
 
@@ -318,17 +319,17 @@ RilConsumer::RilConsumer(unsigned long a
     mAddress = RIL_SOCKET_NAME;
   } else {
     struct sockaddr_un addr_un;
     snprintf(addr_un.sun_path, sizeof addr_un.sun_path, "%s%lu",
              RIL_SOCKET_NAME, aClientId);
     mAddress = addr_un.sun_path;
   }
 
-  ConnectSocket(new RilConnector(mClientId), mAddress.get());
+  Connect(new RilConnector(mClientId), mAddress.get());
 }
 
 nsresult
 RilConsumer::Register(unsigned int aClientId,
                       WorkerCrossThreadDispatcher* aDispatcher)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -357,17 +358,17 @@ RilConsumer::Shutdown()
 
   for (unsigned long i = 0; i < sRilConsumers.Length(); i++) {
     nsRefPtr<RilConsumer>& instance = sRilConsumers[i];
     if (!instance) {
       continue;
     }
 
     instance->mShutdown = true;
-    instance->CloseSocket();
+    instance->Close();
     instance = nullptr;
   }
 }
 
 void
 RilConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -382,23 +383,29 @@ RilConsumer::OnConnectSuccess()
   // Nothing to do here.
   CHROMIUM_LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
 }
 
 void
 RilConsumer::OnConnectError()
 {
   CHROMIUM_LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
-  CloseSocket();
+  Close();
 }
 
 void
 RilConsumer::OnDisconnect()
 {
   CHROMIUM_LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
   if (!mShutdown) {
-    ConnectSocket(new RilConnector(mClientId), mAddress.get(),
-                  GetSuggestedConnectDelayMs());
+    Connect(new RilConnector(mClientId), mAddress.get(),
+            GetSuggestedConnectDelayMs());
   }
 }
 
+ConnectionOrientedSocketIO*
+RilConsumer::GetIO()
+{
+  return PrepareAccept(new RilConnector(mClientId));
+}
+
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/ril/Ril.h
+++ b/ipc/ril/Ril.h
@@ -3,29 +3,31 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_ipc_Ril_h
 #define mozilla_ipc_Ril_h 1
 
 #include <mozilla/dom/workers/Workers.h>
-#include <mozilla/ipc/UnixSocket.h>
+#include <mozilla/ipc/StreamSocket.h>
 
 namespace mozilla {
 namespace ipc {
 
-class RilConsumer MOZ_FINAL : public mozilla::ipc::UnixSocketConsumer
+class RilConsumer MOZ_FINAL : public mozilla::ipc::StreamSocket
 {
 public:
   static nsresult Register(
     unsigned int aClientId,
     mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
   static void Shutdown();
 
+  ConnectionOrientedSocketIO* GetIO() MOZ_OVERRIDE;
+
 private:
   RilConsumer(unsigned long aClientId,
               mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
 
   void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage) MOZ_OVERRIDE;
 
   void OnConnectSuccess() MOZ_OVERRIDE;
   void OnConnectError() MOZ_OVERRIDE;