SkDocument: remove use of SkTArray (part 1/3).

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1689683002

Review URL: https://codereview.chromium.org/1689683002
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 9a62362..0e2d307 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -979,7 +979,7 @@
 
     info.emplace_back(SkString("Keywords"),
                       SkStringPrintf("Rasterizer:%s;", fRasterizer));
-    doc->setMetadata(info, nullptr, nullptr);
+    doc->setMetadata(&info[0], info.count(), nullptr, nullptr);
     return draw_skdocument(src, doc.get(), dst);
 }
 
diff --git a/include/core/SkDocument.h b/include/core/SkDocument.h
index 6ee96b9..9e1de8a 100644
--- a/include/core/SkDocument.h
+++ b/include/core/SkDocument.h
@@ -131,7 +131,7 @@
      *  nullptr.  For example:
      *
      *  SkDocument* make_doc(SkWStream* output) {
-     *      SkTArray<SkDocument::Attribute> info;
+     *      std::vector<SkDocument::Attribute> info;
      *      info.emplace_back(SkString("Title"), SkString("..."));
      *      info.emplace_back(SkString("Author"), SkString("..."));
      *      info.emplace_back(SkString("Subject"), SkString("..."));
@@ -140,7 +140,7 @@
      *      SkTime::DateTime now;
      *      SkTime::GetDateTime(&now);
      *      SkDocument* doc = SkDocument::CreatePDF(output);
-     *      doc->setMetadata(info, &now, &now);
+     *      doc->setMetadata(&info[0], (int)info.size(), &now, &now);
      *      return doc;
      *  }
      */
@@ -148,10 +148,18 @@
         SkString fKey, fValue;
         Attribute(const SkString& k, const SkString& v) : fKey(k), fValue(v) {}
     };
-    virtual void setMetadata(const SkTArray<SkDocument::Attribute>&,
+    virtual void setMetadata(const SkDocument::Attribute[],
+                             int /* attributeCount */,
                              const SkTime::DateTime* /* creationDate */,
                              const SkTime::DateTime* /* modifiedDate */) {}
 
+    // This version is deprecated.
+    void setMetadata(const SkTArray<SkDocument::Attribute>& att,
+                     const SkTime::DateTime* creation,
+                     const SkTime::DateTime* modified) {
+        this->setMetadata(&att[0], att.count(), creation, modified);
+    }
+
 protected:
     SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted));
 
diff --git a/src/doc/SkDocument_PDF.cpp b/src/doc/SkDocument_PDF.cpp
index fb560ea..a56de70 100644
--- a/src/doc/SkDocument_PDF.cpp
+++ b/src/doc/SkDocument_PDF.cpp
@@ -370,10 +370,11 @@
         fCanon.reset();
     }
 
-    void setMetadata(const SkTArray<SkDocument::Attribute>& info,
+    void setMetadata(const SkDocument::Attribute info[],
+                     int infoCount,
                      const SkTime::DateTime* creationDate,
                      const SkTime::DateTime* modifiedDate) override {
-        fMetadata.fInfo = info;
+        fMetadata.fInfo.reset(info, infoCount);
         fMetadata.fCreation.reset(clone(creationDate));
         fMetadata.fModified.reset(clone(modifiedDate));
     }
diff --git a/tests/PDFMetadataAttributeTest.cpp b/tests/PDFMetadataAttributeTest.cpp
index e58146b..e436ee2 100644
--- a/tests/PDFMetadataAttributeTest.cpp
+++ b/tests/PDFMetadataAttributeTest.cpp
@@ -21,7 +21,7 @@
     info.emplace_back(SkString("Creator"), SkString("A5"));
     SkTime::DateTime now;
     SkTime::GetDateTime(&now);
-    doc->setMetadata(info, &now, &now);
+    doc->setMetadata(&info[0], info.count(), &now, &now);
     doc->beginPage(612.0f, 792.0f);
     doc->close();
     SkAutoTUnref<SkData> data(pdf.copyToData());