Bug 1110669: Improve correctness of |RilConsumer| and its helpers, r=htsai
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 07 Jan 2015 11:19:59 +0100
changeset 248256 14e25d5825f7b562a7458d972e42d1a511e17d32
parent 248255 9a9147872e5bd54decba097f965fdb9dfb86c028
child 248257 9bf521b43c84d4f1252f51e4b072999b81bfe254
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)
reviewershtsai
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: Improve correctness of |RilConsumer| and its helpers, r=htsai This patch applies some correctness fixes to ipc/Ril.{cpp,h}.
ipc/ril/Ril.cpp
ipc/ril/Ril.h
--- a/ipc/ril/Ril.cpp
+++ b/ipc/ril/Ril.cpp
@@ -24,43 +24,40 @@
 #include "nsTArray.h"
 #include "nsThreadUtils.h" // For NS_IsMainThread.
 
 USING_WORKERS_NAMESPACE
 using namespace mozilla::ipc;
 
 namespace {
 
-const char* RIL_SOCKET_NAME = "/dev/socket/rilproxy";
+static const char RIL_SOCKET_NAME[] = "/dev/socket/rilproxy";
 
 // Network port to connect to for adb forwarded sockets when doing
 // desktop development.
-const uint32_t RIL_TEST_PORT = 6200;
+static const uint32_t RIL_TEST_PORT = 6200;
 
-nsTArray<nsRefPtr<mozilla::ipc::RilConsumer> > sRilConsumers;
+static nsTArray<nsRefPtr<mozilla::ipc::RilConsumer> > sRilConsumers;
 
-class ConnectWorkerToRIL : public WorkerTask
+class ConnectWorkerToRIL MOZ_FINAL : public WorkerTask
 {
 public:
-  ConnectWorkerToRIL()
-  { }
-
-  virtual bool RunTask(JSContext* aCx);
+  bool RunTask(JSContext* aCx) MOZ_OVERRIDE;
 };
 
-class SendRilSocketDataTask : public nsRunnable
+class SendRilSocketDataTask MOZ_FINAL : public nsRunnable
 {
 public:
   SendRilSocketDataTask(unsigned long aClientId,
                         UnixSocketRawData* aRawData)
     : mRawData(aRawData)
     , mClientId(aClientId)
   { }
 
-  NS_IMETHOD Run()
+  NS_IMETHOD Run() MOZ_OVERRIDE
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (sRilConsumers.Length() <= mClientId ||
         !sRilConsumers[mClientId] ||
         sRilConsumers[mClientId]->GetConnectionStatus() != SOCKET_CONNECTED) {
       // Probably shuting down.
       delete mRawData;
@@ -71,17 +68,17 @@ public:
     return NS_OK;
   }
 
 private:
   UnixSocketRawData* mRawData;
   unsigned long mClientId;
 };
 
-bool
+static bool
 PostToRIL(JSContext* aCx, unsigned aArgc, JS::Value* aVp)
 {
   JS::CallArgs args = JS::CallArgsFromVp(aArgc, aVp);
   NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
 
   if (args.length() != 2) {
     JS_ReportError(aCx, "Expecting two arguments with the RIL message");
     return false;
@@ -157,25 +154,25 @@ ConnectWorkerToRIL::RunTask(JSContext* a
   if (JSTYPE_FUNCTION == JS_TypeOfValue(aCx, val)) {
     return true;
   }
 
   return !!JS_DefineFunction(aCx, workerGlobal, "postRILMessage",
                              PostToRIL, 2, 0);
 }
 
-class DispatchRILEvent : public WorkerTask
+class DispatchRILEvent MOZ_FINAL : public WorkerTask
 {
 public:
   DispatchRILEvent(unsigned long aClient, UnixSocketRawData* aMessage)
     : mClientId(aClient)
     , mMessage(aMessage)
   { }
 
-  virtual bool RunTask(JSContext* aCx);
+  bool RunTask(JSContext* aCx) MOZ_OVERRIDE;
 
 private:
   unsigned long mClientId;
   nsAutoPtr<UnixSocketRawData> mMessage;
 };
 
 bool
 DispatchRILEvent::RunTask(JSContext* aCx)
@@ -196,35 +193,32 @@ DispatchRILEvent::RunTask(JSContext* aCx
   JS::AutoValueArray<2> args(aCx);
   args[0].setNumber((uint32_t)mClientId);
   args[1].setObject(*array);
 
   JS::Rooted<JS::Value> rval(aCx);
   return JS_CallFunctionName(aCx, obj, "onRILMessage", args, &rval);
 }
 
-class RilConnector : public mozilla::ipc::UnixSocketConnector
+class RilConnector MOZ_FINAL : public mozilla::ipc::UnixSocketConnector
 {
 public:
   RilConnector(unsigned long aClientId)
     : mClientId(aClientId)
   { }
 
-  virtual ~RilConnector()
-  { }
-
-  virtual int Create();
-  virtual bool CreateAddr(bool aIsServer,
-                          socklen_t& aAddrSize,
-                          sockaddr_any& aAddr,
-                          const char* aAddress);
-  virtual bool SetUp(int aFd);
-  virtual bool SetUpListenSocket(int aFd);
-  virtual void GetSocketAddr(const sockaddr_any& aAddr,
-                             nsAString& aAddrStr);
+  int Create() MOZ_OVERRIDE;
+  bool CreateAddr(bool aIsServer,
+                  socklen_t& aAddrSize,
+                  sockaddr_any& aAddr,
+                  const char* aAddress) MOZ_OVERRIDE;
+  bool SetUp(int aFd) MOZ_OVERRIDE;
+  bool SetUpListenSocket(int aFd) MOZ_OVERRIDE;
+  void GetSocketAddr(const sockaddr_any& aAddr,
+                     nsAString& aAddrStr) MOZ_OVERRIDE;
 
 private:
   unsigned long mClientId;
 };
 
 int
 RilConnector::Create()
 {
--- a/ipc/ril/Ril.h
+++ b/ipc/ril/Ril.h
@@ -8,36 +8,34 @@
 #define mozilla_ipc_Ril_h 1
 
 #include <mozilla/dom/workers/Workers.h>
 #include <mozilla/ipc/UnixSocket.h>
 
 namespace mozilla {
 namespace ipc {
 
-class RilConsumer : public mozilla::ipc::UnixSocketConsumer
+class RilConsumer MOZ_FINAL : public mozilla::ipc::UnixSocketConsumer
 {
 public:
-  virtual ~RilConsumer() { }
-
-  static nsresult Register(unsigned int aClientId,
-                           mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
+  static nsresult Register(
+    unsigned int aClientId,
+    mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
   static void Shutdown();
 
 private:
   RilConsumer(unsigned long aClientId,
               mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
 
-  virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage);
+  void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage) MOZ_OVERRIDE;
 
-  virtual void OnConnectSuccess();
-  virtual void OnConnectError();
-  virtual void OnDisconnect();
+  void OnConnectSuccess() MOZ_OVERRIDE;
+  void OnConnectError() MOZ_OVERRIDE;
+  void OnDisconnect() MOZ_OVERRIDE;
 
-private:
   nsRefPtr<mozilla::dom::workers::WorkerCrossThreadDispatcher> mDispatcher;
   unsigned long mClientId;
   nsCString mAddress;
   bool mShutdown;
 };
 
 } // namespace ipc
 } // namespace mozilla