Bug 1411631 - Use ContiguousEnumSerializerInclusive for GetOpenFileName IPC. r=jimm
authorDavid Parks <dparks@mozilla.com>
Wed, 01 Nov 2017 01:59:31 -0700
changeset 443865 e195ac70ab165bd6806d0bffc3db25fcdd708c51
parent 443864 3949da89d1c91ae3ffebe96fc3bdbb53762b58de
child 443866 e843de356b7e5f3cb01f114bc101f4a71092550b
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1411631
milestone58.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 1411631 - Use ContiguousEnumSerializerInclusive for GetOpenFileName IPC. r=jimm Use the new helper for serializing enums in IPDL.
dom/plugins/ipc/PluginMessageUtils.h
dom/plugins/ipc/PluginModuleParent.cpp
--- a/dom/plugins/ipc/PluginMessageUtils.h
+++ b/dom/plugins/ipc/PluginMessageUtils.h
@@ -867,41 +867,21 @@ struct ParamTraits<mozilla::plugins::_Op
   {
     aLog->append(StringPrintf(L"[%S, %S, %S, %d, %d]", aParam.mCustomFilterOut.c_str(),
                               aParam.mFile.c_str(), aParam.mFileTitle.c_str(),
                               aParam.mFileOffset, aParam.mFileExtension));
   }
 };
 
 template <>
-struct ParamTraits<mozilla::plugins::GetFileNameFunc>
-{
-  typedef mozilla::plugins::GetFileNameFunc paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, static_cast<uint32_t>(aParam));
-  }
-
-  static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
-  {
-    uint32_t result;
-    if (ReadParam(aMsg, aIter, &result)) {
-      *aResult = static_cast<paramType>(result);
-      return true;
-    }
-    return false;
-  }
-
-  static void Log(const paramType& aParam, std::wstring* aLog)
-  {
-    aLog->append(StringPrintf(L"[%S]",
-                 aParam == mozilla::plugins::OPEN_FUNC ? "GetOpenFileName" : "GetSaveFileName"));
-  }
-};
+struct ParamTraits<mozilla::plugins::GetFileNameFunc> :
+  public ContiguousEnumSerializerInclusive<mozilla::plugins::GetFileNameFunc,
+                                           mozilla::plugins::OPEN_FUNC,
+                                           mozilla::plugins::SAVE_FUNC>
+{};
 #endif  // XP_WIN
 
 } /* namespace IPC */
 
 
 // Serializing NPEvents is completely platform-specific and can be rather
 // intricate depending on the platform.  So for readability we split it
 // into separate files and have the only macro crud live here.
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -2942,16 +2942,19 @@ PluginModuleChromeParent::AnswerGetFileN
     aOfnIn.AddToOfn(&ofn);
     switch (aFunc) {
     case OPEN_FUNC:
         *aResult = GetOpenFileName(&ofn);
         break;
     case SAVE_FUNC:
         *aResult = GetSaveFileName(&ofn);
         break;
+    default:
+        *aResult = false;
+        break;
     }
     if (*aResult) {
         if (ofn.Flags & OFN_ALLOWMULTISELECT) {
             // We only support multiselect with the OFN_EXPLORER flag.
             // This guarantees that ofn.lpstrFile follows the pattern below.
             MOZ_ASSERT(ofn.Flags & OFN_EXPLORER);
 
             // lpstrFile is one of two things: