Refactor OriginValuePair.

Move OriginValuePair out of SpdyAcceptChIR, because SpdyAcceptChIR is only used
when serializing, but OriginValuePair will be reused for parsing.

Add operator==() to help writing tests.

PiperOrigin-RevId: 355920343
Change-Id: I01822cef9896eae4f0a2f936b65f19037220c0f1
diff --git a/spdy/core/spdy_framer.cc b/spdy/core/spdy_framer.cc
index e34b068..6b850c2 100644
--- a/spdy/core/spdy_framer.cc
+++ b/spdy/core/spdy_framer.cc
@@ -787,7 +787,7 @@
   builder.BeginNewFrame(SpdyFrameType::ACCEPT_CH, kNoFlags,
                         accept_ch.stream_id());
 
-  for (const SpdyAcceptChIR::OriginValuePair& entry : accept_ch.entries()) {
+  for (const AcceptChOriginValuePair& entry : accept_ch.entries()) {
     builder.WriteUInt16(entry.origin.size());
     builder.WriteBytes(entry.origin.data(), entry.origin.size());
     builder.WriteUInt16(entry.value.size());
@@ -1263,7 +1263,7 @@
   bool ok = builder.BeginNewFrame(SpdyFrameType::ACCEPT_CH, kNoFlags,
                                   accept_ch.stream_id());
 
-  for (const SpdyAcceptChIR::OriginValuePair& entry : accept_ch.entries()) {
+  for (const AcceptChOriginValuePair& entry : accept_ch.entries()) {
     ok = ok && builder.WriteUInt16(entry.origin.size());
     ok = ok && builder.WriteBytes(entry.origin.data(), entry.origin.size());
     ok = ok && builder.WriteUInt16(entry.value.size());
diff --git a/spdy/core/spdy_protocol.cc b/spdy/core/spdy_protocol.cc
index 2f66ba7..9a5c229 100644
--- a/spdy/core/spdy_protocol.cc
+++ b/spdy/core/spdy_protocol.cc
@@ -592,7 +592,7 @@
 
 size_t SpdyAcceptChIR::size() const {
   size_t total_size = kAcceptChFrameMinimumSize;
-  for (const OriginValuePair& entry : entries_) {
+  for (const AcceptChOriginValuePair& entry : entries_) {
     total_size += entry.origin.size() + entry.value.size() +
                   kAcceptChFramePerEntryOverhead;
   }
diff --git a/spdy/core/spdy_protocol.h b/spdy/core/spdy_protocol.h
index 635439b..fcd6ada 100644
--- a/spdy/core/spdy_protocol.h
+++ b/spdy/core/spdy_protocol.h
@@ -921,14 +921,17 @@
   std::string priority_field_value_;
 };
 
+struct AcceptChOriginValuePair {
+  std::string origin;
+  std::string value;
+  bool operator==(const AcceptChOriginValuePair& rhs) const {
+    return origin == rhs.origin && value == rhs.value;
+  }
+};
+
 class QUICHE_EXPORT_PRIVATE SpdyAcceptChIR : public SpdyFrameIR {
  public:
-  struct OriginValuePair {
-    std::string origin;
-    std::string value;
-  };
-
-  SpdyAcceptChIR(std::vector<OriginValuePair> entries)
+  SpdyAcceptChIR(std::vector<AcceptChOriginValuePair> entries)
       : entries_(std::move(entries)) {}
   SpdyAcceptChIR(const SpdyAcceptChIR&) = delete;
   SpdyAcceptChIR& operator=(const SpdyAcceptChIR&) = delete;
@@ -939,10 +942,12 @@
 
   size_t size() const override;
 
-  const std::vector<OriginValuePair>& entries() const { return entries_; }
+  const std::vector<AcceptChOriginValuePair>& entries() const {
+    return entries_;
+  }
 
  private:
-  std::vector<OriginValuePair> entries_;
+  std::vector<AcceptChOriginValuePair> entries_;
 };
 
 // Represents a frame of unrecognized type.