Bug 1287378 - Fix static analysis for bug 1213517 landing: Avoid non-memmovable nsTArray<NormalizedConstraintSet>. draft
authorJan-Ivar Bruaroey <jib@mozilla.com>
Wed, 29 Jun 2016 14:52:19 -0400
changeset 388888 94db07ed0c009de040622f4799d1fa9dd011cf1e
parent 388887 376d9213aaa70e796a307d1297ac996d92e1d347
child 525616 8bc32504199cfe744be70b3ce73d4c50f205bf93
push id23254
push userjbruaroey@mozilla.com
push dateMon, 18 Jul 2016 07:31:43 +0000
bugs1287378, 1213517
milestone50.0a1
Bug 1287378 - Fix static analysis for bug 1213517 landing: Avoid non-memmovable nsTArray<NormalizedConstraintSet>. MozReview-Commit-ID: 5a42mW9O9I2
dom/media/webrtc/MediaEngineCameraVideoSource.cpp
dom/media/webrtc/MediaTrackConstraints.cpp
dom/media/webrtc/MediaTrackConstraints.h
--- a/dom/media/webrtc/MediaEngineCameraVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineCameraVideoSource.cpp
@@ -209,18 +209,18 @@ MediaEngineCameraVideoSource::ChooseCapa
     const MediaEnginePrefs &aPrefs,
     const nsString& aDeviceId)
 {
   if (MOZ_LOG_TEST(GetMediaManagerLog(), LogLevel::Debug)) {
     LOG(("ChooseCapability: prefs: %dx%d @%d-%dfps",
          aPrefs.GetWidth(), aPrefs.GetHeight(),
          aPrefs.mFPS, aPrefs.mMinFPS));
     LogConstraints(aConstraints);
-    if (aConstraints.mAdvanced.Length()) {
-      LOG(("Advanced array[%u]:", aConstraints.mAdvanced.Length()));
+    if (aConstraints.mAdvanced.size()) {
+      LOG(("Advanced array[%u]:", aConstraints.mAdvanced.size()));
       for (auto& advanced : aConstraints.mAdvanced) {
         LogConstraints(advanced);
       }
     }
   }
 
   size_t num = NumCapabilities();
 
--- a/dom/media/webrtc/MediaTrackConstraints.cpp
+++ b/dom/media/webrtc/MediaTrackConstraints.cpp
@@ -274,17 +274,17 @@ NormalizedConstraintSet::StringRange::Me
 NormalizedConstraints::NormalizedConstraints(
     const dom::MediaTrackConstraints& aOther,
     nsTArray<MemberPtrType>* aList)
   : NormalizedConstraintSet(aOther, false, aList)
   , mBadConstraint(nullptr)
 {
   if (aOther.mAdvanced.WasPassed()) {
     for (auto& entry : aOther.mAdvanced.Value()) {
-      mAdvanced.AppendElement(NormalizedConstraintSet(entry, true));
+      mAdvanced.push_back(NormalizedConstraintSet(entry, true));
     }
   }
 }
 
 // Merge constructor. Create net constraints out of merging a set of others.
 // This is only used to resolve competing constraints from concurrent requests,
 // something the spec doesn't cover.
 
@@ -308,17 +308,17 @@ NormalizedConstraints::NormalizedConstra
 
       if (!member.Merge(otherMember)) {
         mBadConstraint = member.mName;
         return;
       }
     }
 
     for (auto& entry : other.mAdvanced) {
-      mAdvanced.AppendElement(entry);
+      mAdvanced.push_back(entry);
     }
   }
   for (auto& memberPtr : list) {
     (this->*memberPtr).FinalizeMerge();
   }
 
   // ...except for resolution and frame rate where we take the highest ideal.
   // This is a bit of a hack based on the perception that people would be more
--- a/dom/media/webrtc/MediaTrackConstraints.h
+++ b/dom/media/webrtc/MediaTrackConstraints.h
@@ -268,17 +268,17 @@ struct NormalizedConstraints : public No
 {
   explicit NormalizedConstraints(const dom::MediaTrackConstraints& aOther,
                         nsTArray<MemberPtrType>* aList = nullptr);
 
   // Merge constructor
   explicit NormalizedConstraints(
       const nsTArray<const NormalizedConstraints*>& aOthers);
 
-  nsTArray<NormalizedConstraintSet> mAdvanced;
+  std::vector<NormalizedConstraintSet> mAdvanced;
   const char* mBadConstraint;
 };
 
 // Flattened version is used in low-level code with orthogonal constraints only.
 struct FlattenedConstraints : public NormalizedConstraintSet
 {
   explicit FlattenedConstraints(const NormalizedConstraints& aOther);
 
@@ -356,17 +356,17 @@ public:
     // Order devices by shortest distance
     for (auto& ordinal : ordered) {
       aDevices.RemoveElement(ordinal.second);
       aDevices.AppendElement(ordinal.second);
     }
 
     // Then apply advanced constraints.
 
-    for (int i = 0; i < int(c.mAdvanced.Length()); i++) {
+    for (int i = 0; i < int(c.mAdvanced.size()); i++) {
       aggregateConstraints.AppendElement(&c.mAdvanced[i]);
       nsTArray<RefPtr<DeviceType>> rejects;
       for (uint32_t j = 0; j < aDevices.Length();) {
         if (aDevices[j]->GetBestFitnessDistance(aggregateConstraints) == UINT32_MAX) {
           rejects.AppendElement(aDevices[j]);
           aDevices.RemoveElementAt(j);
         } else {
           ++j;