Replace QuicheStringPiece with absl::string_view

Tested:
    TAP for global presubmit queue passed after automated deflaking of failures: http://mondo/deflaker/run/96cd5e40-b4cb-4ad8-8e9f-62d5c247385b http://mondo/deflaker/run/0a6209be-9013-4346-bd74-893b793b94d1 http://mondo/deflaker/run/f97a1fae-e543-4aea-a52f-88ddf6054d33
    http://test/OCL:335945875:BASE:335945937:1602132930213:6b6e6496
PiperOrigin-RevId: 336088095
Change-Id: I3a39387a5c382c401e0cf55b937dbd5babc7bdf3
diff --git a/quic/tools/quic_memory_cache_backend.cc b/quic/tools/quic_memory_cache_backend.cc
index 370eb4a..5efe0e6 100644
--- a/quic/tools/quic_memory_cache_backend.cc
+++ b/quic/tools/quic_memory_cache_backend.cc
@@ -6,12 +6,12 @@
 
 #include <utility>
 
+#include "absl/strings/string_view.h"
 #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_file_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
 #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h"
 
 using spdy::kV3LowestPriority;
@@ -40,7 +40,7 @@
     if (file_contents_[pos - 1] == '\r') {
       len -= 1;
     }
-    quiche::QuicheStringPiece line(file_contents_.data() + start, len);
+    absl::string_view line(file_contents_.data() + start, len);
     start = pos + 1;
     // Headers end with an empty line.
     if (line.empty()) {
@@ -83,30 +83,29 @@
   // stuff as described in https://w3c.github.io/preload/.
   it = spdy_headers_.find("x-push-url");
   if (it != spdy_headers_.end()) {
-    quiche::QuicheStringPiece push_urls = it->second;
+    absl::string_view push_urls = it->second;
     size_t start = 0;
     while (start < push_urls.length()) {
       size_t pos = push_urls.find('\0', start);
       if (pos == std::string::npos) {
-        push_urls_.push_back(quiche::QuicheStringPiece(
-            push_urls.data() + start, push_urls.length() - start));
+        push_urls_.push_back(absl::string_view(push_urls.data() + start,
+                                               push_urls.length() - start));
         break;
       }
-      push_urls_.push_back(
-          quiche::QuicheStringPiece(push_urls.data() + start, pos));
+      push_urls_.push_back(absl::string_view(push_urls.data() + start, pos));
       start += pos + 1;
     }
   }
 
-  body_ = quiche::QuicheStringPiece(file_contents_.data() + start,
-                                    file_contents_.size() - start);
+  body_ = absl::string_view(file_contents_.data() + start,
+                            file_contents_.size() - start);
 }
 
 void QuicMemoryCacheBackend::ResourceFile::SetHostPathFromBase(
-    quiche::QuicheStringPiece base) {
+    absl::string_view base) {
   DCHECK(base[0] != '/') << base;
   size_t path_start = base.find_first_of('/');
-  if (path_start == quiche::QuicheStringPiece::npos) {
+  if (path_start == absl::string_view::npos) {
     host_ = std::string(base);
     path_ = "";
     return;
@@ -121,8 +120,8 @@
   }
 }
 
-quiche::QuicheStringPiece QuicMemoryCacheBackend::ResourceFile::RemoveScheme(
-    quiche::QuicheStringPiece url) {
+absl::string_view QuicMemoryCacheBackend::ResourceFile::RemoveScheme(
+    absl::string_view url) {
   if (quiche::QuicheTextUtils::StartsWith(url, "https://")) {
     url.remove_prefix(8);
   } else if (quiche::QuicheTextUtils::StartsWith(url, "http://")) {
@@ -132,13 +131,13 @@
 }
 
 void QuicMemoryCacheBackend::ResourceFile::HandleXOriginalUrl() {
-  quiche::QuicheStringPiece url(x_original_url_);
+  absl::string_view url(x_original_url_);
   SetHostPathFromBase(RemoveScheme(url));
 }
 
 const QuicBackendResponse* QuicMemoryCacheBackend::GetResponse(
-    quiche::QuicheStringPiece host,
-    quiche::QuicheStringPiece path) const {
+    absl::string_view host,
+    absl::string_view path) const {
   QuicWriterMutexLock lock(&response_mutex_);
 
   auto it = responses_.find(GetKey(host, path));
@@ -146,8 +145,7 @@
     uint64_t ignored = 0;
     if (generate_bytes_response_) {
       if (quiche::QuicheTextUtils::StringToUint64(
-              quiche::QuicheStringPiece(path.data() + 1, path.size() - 1),
-              &ignored)) {
+              absl::string_view(path.data() + 1, path.size() - 1), &ignored)) {
         // The actual parsed length is ignored here and will be recomputed
         // by the caller.
         return generate_bytes_response_.get();
@@ -166,10 +164,10 @@
 typedef QuicBackendResponse::ServerPushInfo ServerPushInfo;
 typedef QuicBackendResponse::SpecialResponseType SpecialResponseType;
 
-void QuicMemoryCacheBackend::AddSimpleResponse(quiche::QuicheStringPiece host,
-                                               quiche::QuicheStringPiece path,
+void QuicMemoryCacheBackend::AddSimpleResponse(absl::string_view host,
+                                               absl::string_view path,
                                                int response_code,
-                                               quiche::QuicheStringPiece body) {
+                                               absl::string_view body) {
   SpdyHeaderBlock response_headers;
   response_headers[":status"] =
       quiche::QuicheTextUtils::Uint64ToString(response_code);
@@ -179,10 +177,10 @@
 }
 
 void QuicMemoryCacheBackend::AddSimpleResponseWithServerPushResources(
-    quiche::QuicheStringPiece host,
-    quiche::QuicheStringPiece path,
+    absl::string_view host,
+    absl::string_view path,
     int response_code,
-    quiche::QuicheStringPiece body,
+    absl::string_view body,
     std::list<ServerPushInfo> push_resources) {
   AddSimpleResponse(host, path, response_code, body);
   MaybeAddServerPushResources(host, path, push_resources);
@@ -193,40 +191,38 @@
   default_response_.reset(response);
 }
 
-void QuicMemoryCacheBackend::AddResponse(
-    quiche::QuicheStringPiece host,
-    quiche::QuicheStringPiece path,
-    SpdyHeaderBlock response_headers,
-    quiche::QuicheStringPiece response_body) {
+void QuicMemoryCacheBackend::AddResponse(absl::string_view host,
+                                         absl::string_view path,
+                                         SpdyHeaderBlock response_headers,
+                                         absl::string_view response_body) {
   AddResponseImpl(host, path, QuicBackendResponse::REGULAR_RESPONSE,
                   std::move(response_headers), response_body,
                   SpdyHeaderBlock());
 }
 
-void QuicMemoryCacheBackend::AddResponse(
-    quiche::QuicheStringPiece host,
-    quiche::QuicheStringPiece path,
-    SpdyHeaderBlock response_headers,
-    quiche::QuicheStringPiece response_body,
-    SpdyHeaderBlock response_trailers) {
+void QuicMemoryCacheBackend::AddResponse(absl::string_view host,
+                                         absl::string_view path,
+                                         SpdyHeaderBlock response_headers,
+                                         absl::string_view response_body,
+                                         SpdyHeaderBlock response_trailers) {
   AddResponseImpl(host, path, QuicBackendResponse::REGULAR_RESPONSE,
                   std::move(response_headers), response_body,
                   std::move(response_trailers));
 }
 
 void QuicMemoryCacheBackend::AddSpecialResponse(
-    quiche::QuicheStringPiece host,
-    quiche::QuicheStringPiece path,
+    absl::string_view host,
+    absl::string_view path,
     SpecialResponseType response_type) {
   AddResponseImpl(host, path, response_type, SpdyHeaderBlock(), "",
                   SpdyHeaderBlock());
 }
 
 void QuicMemoryCacheBackend::AddSpecialResponse(
-    quiche::QuicheStringPiece host,
-    quiche::QuicheStringPiece path,
+    absl::string_view host,
+    absl::string_view path,
     spdy::SpdyHeaderBlock response_headers,
-    quiche::QuicheStringPiece response_body,
+    absl::string_view response_body,
     SpecialResponseType response_type) {
   AddResponseImpl(host, path, response_type, std::move(response_headers),
                   response_body, SpdyHeaderBlock());
@@ -353,11 +349,11 @@
 }
 
 void QuicMemoryCacheBackend::AddResponseImpl(
-    quiche::QuicheStringPiece host,
-    quiche::QuicheStringPiece path,
+    absl::string_view host,
+    absl::string_view path,
     SpecialResponseType response_type,
     SpdyHeaderBlock response_headers,
-    quiche::QuicheStringPiece response_body,
+    absl::string_view response_body,
     SpdyHeaderBlock response_trailers) {
   QuicWriterMutexLock lock(&response_mutex_);
 
@@ -376,9 +372,8 @@
   responses_[key] = std::move(new_response);
 }
 
-std::string QuicMemoryCacheBackend::GetKey(
-    quiche::QuicheStringPiece host,
-    quiche::QuicheStringPiece path) const {
+std::string QuicMemoryCacheBackend::GetKey(absl::string_view host,
+                                           absl::string_view path) const {
   std::string host_string = std::string(host);
   size_t port = host_string.find(':');
   if (port != std::string::npos)
@@ -387,8 +382,8 @@
 }
 
 void QuicMemoryCacheBackend::MaybeAddServerPushResources(
-    quiche::QuicheStringPiece request_host,
-    quiche::QuicheStringPiece request_path,
+    absl::string_view request_host,
+    absl::string_view request_path,
     std::list<ServerPushInfo> push_resources) {
   std::string request_url = GetKey(request_host, request_path);
 
@@ -418,7 +413,7 @@
     }
     if (!found_existing_response) {
       // Add a server push response to responses map, if it is not in the map.
-      quiche::QuicheStringPiece body = push_resource.body;
+      absl::string_view body = push_resource.body;
       QUIC_DVLOG(1) << "Add response for push resource: host " << host
                     << " path " << path;
       AddResponse(host, path, push_resource.headers.Clone(), body);