Replace QuicString with std::string, pass 1 This replaces QuicString with std::string in all of the "QUIC proper". I will delete QuicString once all code using it is gone. gfe-relnote: n/a (no functional change) PiperOrigin-RevId: 237872023 Change-Id: I82de62c9855516b15039734d05155917e68ff4ee
diff --git a/quic/tools/quic_backend_response.cc b/quic/tools/quic_backend_response.cc index 4ef00a0..7900683 100644 --- a/quic/tools/quic_backend_response.cc +++ b/quic/tools/quic_backend_response.cc
@@ -10,7 +10,7 @@ QuicUrl request_url, spdy::SpdyHeaderBlock headers, spdy::SpdyPriority priority, - QuicString body) + std::string body) : request_url(request_url), headers(std::move(headers)), priority(priority),
diff --git a/quic/tools/quic_backend_response.h b/quic/tools/quic_backend_response.h index cd052c8..4ef0fdc 100644 --- a/quic/tools/quic_backend_response.h +++ b/quic/tools/quic_backend_response.h
@@ -20,13 +20,13 @@ ServerPushInfo(QuicUrl request_url, spdy::SpdyHeaderBlock headers, spdy::SpdyPriority priority, - QuicString body); + std::string body); ServerPushInfo(const ServerPushInfo& other); QuicUrl request_url; spdy::SpdyHeaderBlock headers; spdy::SpdyPriority priority; - QuicString body; + std::string body; }; enum SpecialResponseType { @@ -75,7 +75,7 @@ SpecialResponseType response_type_; spdy::SpdyHeaderBlock headers_; spdy::SpdyHeaderBlock trailers_; - QuicString body_; + std::string body_; uint16_t stop_sending_code_; };
diff --git a/quic/tools/quic_client_base.h b/quic/tools/quic_client_base.h index 3b09e18..261fc2b 100644 --- a/quic/tools/quic_client_base.h +++ b/quic/tools/quic_client_base.h
@@ -127,7 +127,7 @@ // This should only be set before the initial Connect() void set_server_id(const QuicServerId& server_id) { server_id_ = server_id; } - void SetUserAgentID(const QuicString& user_agent_id) { + void SetUserAgentID(const std::string& user_agent_id) { crypto_config_.set_user_agent_id(user_agent_id); }
diff --git a/quic/tools/quic_client_bin.cc b/quic/tools/quic_client_bin.cc index 1083f0d..412fb8e 100644 --- a/quic/tools/quic_client_bin.cc +++ b/quic/tools/quic_client_bin.cc
@@ -60,7 +60,6 @@ namespace { using quic::QuicSocketAddress; -using quic::QuicString; using quic::QuicStringPiece; using quic::QuicTextUtils; using quic::QuicUrl; @@ -97,7 +96,7 @@ } }; -QuicSocketAddress LookupAddress(QuicString host, QuicString port) { +QuicSocketAddress LookupAddress(std::string host, std::string port) { addrinfo hint; memset(&hint, 0, sizeof(hint)); hint.ai_protocol = IPPROTO_UDP; @@ -200,7 +199,7 @@ const char* usage = "Usage: quic_client [options] <url>"; // All non-flag arguments should be interpreted as URLs to fetch. - std::vector<QuicString> urls = + std::vector<std::string> urls = quic::QuicParseCommandLineFlags(usage, argc, argv); if (urls.size() != 1) { quic::QuicPrintCommandLineFlagHelp(usage);
diff --git a/quic/tools/quic_client_epoll_network_helper.cc b/quic/tools/quic_client_epoll_network_helper.cc index 846911f..e545ee2 100644 --- a/quic/tools/quic_client_epoll_network_helper.cc +++ b/quic/tools/quic_client_epoll_network_helper.cc
@@ -55,7 +55,7 @@ CleanUpAllUDPSockets(); } -QuicString QuicClientEpollNetworkHelper::Name() const { +std::string QuicClientEpollNetworkHelper::Name() const { return "QuicClientEpollNetworkHelper"; }
diff --git a/quic/tools/quic_client_epoll_network_helper.h b/quic/tools/quic_client_epoll_network_helper.h index e0f8cf3..d66dbb1 100644 --- a/quic/tools/quic_client_epoll_network_helper.h +++ b/quic/tools/quic_client_epoll_network_helper.h
@@ -44,7 +44,7 @@ ~QuicClientEpollNetworkHelper() override; // Return a name describing the class for use in debug/error reporting. - QuicString Name() const override; + std::string Name() const override; // From EpollCallbackInterface void OnRegistration(QuicEpollServer* eps, int fd, int event_mask) override;
diff --git a/quic/tools/quic_client_test.cc b/quic/tools/quic_client_test.cc index 7977f05..12a687c 100644 --- a/quic/tools/quic_client_test.cc +++ b/quic/tools/quic_client_test.cc
@@ -24,8 +24,8 @@ const char* kPathToFds = "/proc/self/fd"; -QuicString ReadLink(const QuicString& path) { - QuicString result(PATH_MAX, '\0'); +std::string ReadLink(const std::string& path) { + std::string result(PATH_MAX, '\0'); ssize_t result_size = readlink(path.c_str(), &result[0], result.size()); CHECK(result_size > 0 && static_cast<size_t>(result_size) < result.size()); result.resize(result_size); @@ -44,7 +44,7 @@ continue; } - QuicString fd_path = ReadLink(QuicStrCat(kPathToFds, "/", name)); + std::string fd_path = ReadLink(QuicStrCat(kPathToFds, "/", name)); if (QuicTextUtils::StartsWith(fd_path, "socket:")) { socket_count++; }
diff --git a/quic/tools/quic_memory_cache_backend.cc b/quic/tools/quic_memory_cache_backend.cc index 9f333dd..76a52c3 100644 --- a/quic/tools/quic_memory_cache_backend.cc +++ b/quic/tools/quic_memory_cache_backend.cc
@@ -19,7 +19,7 @@ namespace quic { -QuicMemoryCacheBackend::ResourceFile::ResourceFile(const QuicString& file_name) +QuicMemoryCacheBackend::ResourceFile::ResourceFile(const std::string& file_name) : file_name_(file_name) {} QuicMemoryCacheBackend::ResourceFile::~ResourceFile() = default; @@ -31,7 +31,7 @@ size_t start = 0; while (start < file_contents_.length()) { size_t pos = file_contents_.find("\n", start); - if (pos == QuicString::npos) { + if (pos == std::string::npos) { QUIC_LOG(DFATAL) << "Headers invalid or empty, ignoring: " << file_name_; return; } @@ -49,7 +49,7 @@ // Extract the status from the HTTP first line. if (line.substr(0, 4) == "HTTP") { pos = line.find(" "); - if (pos == QuicString::npos) { + if (pos == std::string::npos) { QUIC_LOG(DFATAL) << "Headers invalid or empty, ignoring: " << file_name_; return; @@ -59,7 +59,7 @@ } // Headers are "key: value". pos = line.find(": "); - if (pos == QuicString::npos) { + if (pos == std::string::npos) { QUIC_LOG(DFATAL) << "Headers invalid or empty, ignoring: " << file_name_; return; } @@ -86,7 +86,7 @@ size_t start = 0; while (start < push_urls.length()) { size_t pos = push_urls.find('\0', start); - if (pos == QuicString::npos) { + if (pos == std::string::npos) { push_urls_.push_back(QuicStringPiece(push_urls.data() + start, push_urls.length() - start)); break; @@ -227,7 +227,7 @@ QuicMemoryCacheBackend::QuicMemoryCacheBackend() : cache_initialized_(false) {} bool QuicMemoryCacheBackend::InitializeBackend( - const QuicString& cache_directory) { + const std::string& cache_directory) { if (cache_directory.empty()) { QUIC_BUG << "cache_directory must not be empty."; return false; @@ -235,7 +235,7 @@ QUIC_LOG(INFO) << "Attempting to initialize QuicMemoryCacheBackend from directory: " << cache_directory; - std::vector<QuicString> files = ReadFileContents(cache_directory); + std::vector<std::string> files = ReadFileContents(cache_directory); std::list<std::unique_ptr<ResourceFile>> resource_files; for (const auto& filename : files) { std::unique_ptr<ResourceFile> resource_file(new ResourceFile(filename)); @@ -267,7 +267,7 @@ } push_resources.push_back(ServerPushInfo(url, response->headers().Clone(), kV3LowestPriority, - (QuicString(response->body())))); + (std::string(response->body())))); } MaybeAddServerPushResources(resource_file->host(), resource_file->path(), push_resources); @@ -282,7 +282,7 @@ void QuicMemoryCacheBackend::FetchResponseFromBackend( const SpdyHeaderBlock& request_headers, - const QuicString& request_body, + const std::string& request_body, QuicSimpleServerBackend::RequestHandler* quic_stream) { const QuicBackendResponse* quic_response = nullptr; // Find response in cache. If not found, send error response. @@ -292,8 +292,8 @@ quic_response = GetResponse(authority->second, path->second); } - QuicString request_url = - QuicString(authority->second) + QuicString(path->second); + std::string request_url = + std::string(authority->second) + std::string(path->second); std::list<ServerPushInfo> resources = GetServerPushResources(request_url); QUIC_DVLOG(1) << "Fetching QUIC response from backend in-memory cache for url " @@ -306,7 +306,7 @@ QuicSimpleServerBackend::RequestHandler* quic_stream) {} std::list<ServerPushInfo> QuicMemoryCacheBackend::GetServerPushResources( - QuicString request_url) { + std::string request_url) { QuicWriterMutexLock lock(&response_mutex_); std::list<ServerPushInfo> resources; @@ -336,7 +336,7 @@ QuicWriterMutexLock lock(&response_mutex_); DCHECK(!host.empty()) << "Host must be populated, e.g. \"www.google.com\""; - QuicString key = GetKey(host, path); + std::string key = GetKey(host, path); if (QuicContainsKey(responses_, key)) { QUIC_BUG << "Response for '" << key << "' already exists!"; return; @@ -351,20 +351,20 @@ responses_[key] = std::move(new_response); } -QuicString QuicMemoryCacheBackend::GetKey(QuicStringPiece host, - QuicStringPiece path) const { - QuicString host_string = QuicString(host); +std::string QuicMemoryCacheBackend::GetKey(QuicStringPiece host, + QuicStringPiece path) const { + std::string host_string = std::string(host); size_t port = host_string.find(':'); - if (port != QuicString::npos) - host_string = QuicString(host_string.c_str(), port); - return host_string + QuicString(path); + if (port != std::string::npos) + host_string = std::string(host_string.c_str(), port); + return host_string + std::string(path); } void QuicMemoryCacheBackend::MaybeAddServerPushResources( QuicStringPiece request_host, QuicStringPiece request_path, std::list<ServerPushInfo> push_resources) { - QuicString request_url = GetKey(request_host, request_path); + std::string request_url = GetKey(request_host, request_path); for (const auto& push_resource : push_resources) { if (PushResourceExistsInCache(request_url, push_resource)) { @@ -380,11 +380,11 @@ QuicWriterMutexLock lock(&response_mutex_); server_push_resources_.insert(std::make_pair(request_url, push_resource)); } - QuicString host = push_resource.request_url.host(); + std::string host = push_resource.request_url.host(); if (host.empty()) { - host = QuicString(request_host); + host = std::string(request_host); } - QuicString path = push_resource.request_url.path(); + std::string path = push_resource.request_url.path(); bool found_existing_response = false; { QuicWriterMutexLock lock(&response_mutex_); @@ -401,7 +401,7 @@ } bool QuicMemoryCacheBackend::PushResourceExistsInCache( - QuicString original_request_url, + std::string original_request_url, ServerPushInfo resource) { QuicWriterMutexLock lock(&response_mutex_); auto resource_range =
diff --git a/quic/tools/quic_memory_cache_backend.h b/quic/tools/quic_memory_cache_backend.h index 1417349..ff76c9a 100644 --- a/quic/tools/quic_memory_cache_backend.h +++ b/quic/tools/quic_memory_cache_backend.h
@@ -32,7 +32,7 @@ // server push associations. class ResourceFile { public: - explicit ResourceFile(const QuicString& file_name); + explicit ResourceFile(const std::string& file_name); ResourceFile(const ResourceFile&) = delete; ResourceFile& operator=(const ResourceFile&) = delete; virtual ~ResourceFile(); @@ -42,7 +42,7 @@ // |base| is |file_name_| with |cache_directory| prefix stripped. void SetHostPathFromBase(QuicStringPiece base); - const QuicString& file_name() { return file_name_; } + const std::string& file_name() { return file_name_; } QuicStringPiece host() { return host_; } @@ -58,8 +58,8 @@ void HandleXOriginalUrl(); QuicStringPiece RemoveScheme(QuicStringPiece url); - QuicString file_name_; - QuicString file_contents_; + std::string file_name_; + std::string file_contents_; QuicStringPiece body_; spdy::SpdyHeaderBlock spdy_headers_; QuicStringPiece x_original_url_; @@ -135,19 +135,19 @@ void AddDefaultResponse(QuicBackendResponse* response); // |cache_cirectory| can be generated using `wget -p --save-headers <url>`. - void InitializeFromDirectory(const QuicString& cache_directory); + void InitializeFromDirectory(const std::string& cache_directory); // Find all the server push resources associated with |request_url|. std::list<QuicBackendResponse::ServerPushInfo> GetServerPushResources( - QuicString request_url); + std::string request_url); // Implements the functions for interface QuicSimpleServerBackend // |cache_cirectory| can be generated using `wget -p --save-headers <url>`. - bool InitializeBackend(const QuicString& cache_directory) override; + bool InitializeBackend(const std::string& cache_directory) override; bool IsBackendInitialized() const override; void FetchResponseFromBackend( const spdy::SpdyHeaderBlock& request_headers, - const QuicString& request_body, + const std::string& request_body, QuicSimpleServerBackend::RequestHandler* quic_server_stream) override; void CloseBackendResponseStream( QuicSimpleServerBackend::RequestHandler* quic_server_stream) override; @@ -161,7 +161,7 @@ spdy::SpdyHeaderBlock response_trailers, uint16_t stop_sending_code); - QuicString GetKey(QuicStringPiece host, QuicStringPiece path) const; + std::string GetKey(QuicStringPiece host, QuicStringPiece path) const; // Add some server push urls with given responses for specified // request if these push resources are not associated with this request yet. @@ -172,11 +172,11 @@ // Check if push resource(push_host/push_path) associated with given request // url already exists in server push map. - bool PushResourceExistsInCache(QuicString original_request_url, + bool PushResourceExistsInCache(std::string original_request_url, QuicBackendResponse::ServerPushInfo resource); // Cached responses. - QuicUnorderedMap<QuicString, std::unique_ptr<QuicBackendResponse>> responses_ + QuicUnorderedMap<std::string, std::unique_ptr<QuicBackendResponse>> responses_ GUARDED_BY(response_mutex_); // The default response for cache misses, if set. @@ -184,7 +184,7 @@ GUARDED_BY(response_mutex_); // A map from request URL to associated server push responses (if any). - std::multimap<QuicString, QuicBackendResponse::ServerPushInfo> + std::multimap<std::string, QuicBackendResponse::ServerPushInfo> server_push_resources_ GUARDED_BY(response_mutex_); // Protects against concurrent access from test threads setting responses, and
diff --git a/quic/tools/quic_memory_cache_backend_test.cc b/quic/tools/quic_memory_cache_backend_test.cc index e5f5db1..80b1b29 100644 --- a/quic/tools/quic_memory_cache_backend_test.cc +++ b/quic/tools/quic_memory_cache_backend_test.cc
@@ -20,8 +20,8 @@ class QuicMemoryCacheBackendTest : public QuicTest { protected: - void CreateRequest(QuicString host, - QuicString path, + void CreateRequest(std::string host, + std::string path, spdy::SpdyHeaderBlock* headers) { (*headers)[":method"] = "GET"; (*headers)[":path"] = path; @@ -29,7 +29,7 @@ (*headers)[":scheme"] = "https"; } - QuicString CacheDirectory() { return QuicGetTestMemoryCachePath(); } + std::string CacheDirectory() { return QuicGetTestMemoryCachePath(); } QuicMemoryCacheBackend cache_; }; @@ -41,7 +41,7 @@ } TEST_F(QuicMemoryCacheBackendTest, AddSimpleResponseGetResponse) { - QuicString response_body("hello response"); + std::string response_body("hello response"); cache_.AddSimpleResponse("www.google.com", "/", 200, response_body); spdy::SpdyHeaderBlock request_headers; @@ -54,9 +54,9 @@ } TEST_F(QuicMemoryCacheBackendTest, AddResponse) { - const QuicString kRequestHost = "www.foo.com"; - const QuicString kRequestPath = "/"; - const QuicString kResponseBody("hello response"); + const std::string kRequestHost = "www.foo.com"; + const std::string kRequestPath = "/"; + const std::string kResponseBody("hello response"); spdy::SpdyHeaderBlock response_headers; response_headers[":version"] = "HTTP/1.1"; @@ -151,17 +151,17 @@ } TEST_F(QuicMemoryCacheBackendTest, AddSimpleResponseWithServerPushResources) { - QuicString request_host = "www.foo.com"; - QuicString response_body("hello response"); + std::string request_host = "www.foo.com"; + std::string response_body("hello response"); const size_t kNumResources = 5; int NumResources = 5; std::list<ServerPushInfo> push_resources; - QuicString scheme = "http"; + std::string scheme = "http"; for (int i = 0; i < NumResources; ++i) { - QuicString path = "/server_push_src" + QuicTextUtils::Uint64ToString(i); - QuicString url = scheme + "://" + request_host + path; + std::string path = "/server_push_src" + QuicTextUtils::Uint64ToString(i); + std::string url = scheme + "://" + request_host + path; QuicUrl resource_url(url); - QuicString body = + std::string body = QuicStrCat("This is server push response body for ", path); spdy::SpdyHeaderBlock response_headers; response_headers[":version"] = "HTTP/1.1"; @@ -175,7 +175,7 @@ cache_.AddSimpleResponseWithServerPushResources( request_host, "/", 200, response_body, push_resources); - QuicString request_url = request_host + "/"; + std::string request_url = request_host + "/"; std::list<ServerPushInfo> resources = cache_.GetServerPushResources(request_url); ASSERT_EQ(kNumResources, resources.size()); @@ -189,18 +189,19 @@ } TEST_F(QuicMemoryCacheBackendTest, GetServerPushResourcesAndPushResponses) { - QuicString request_host = "www.foo.com"; - QuicString response_body("hello response"); + std::string request_host = "www.foo.com"; + std::string response_body("hello response"); const size_t kNumResources = 4; int NumResources = 4; - QuicString scheme = "http"; - QuicString push_response_status[kNumResources] = {"200", "200", "301", "404"}; + std::string scheme = "http"; + std::string push_response_status[kNumResources] = {"200", "200", "301", + "404"}; std::list<ServerPushInfo> push_resources; for (int i = 0; i < NumResources; ++i) { - QuicString path = "/server_push_src" + QuicTextUtils::Uint64ToString(i); - QuicString url = scheme + "://" + request_host + path; + std::string path = "/server_push_src" + QuicTextUtils::Uint64ToString(i); + std::string url = scheme + "://" + request_host + path; QuicUrl resource_url(url); - QuicString body = "This is server push response body for " + path; + std::string body = "This is server push response body for " + path; spdy::SpdyHeaderBlock response_headers; response_headers[":version"] = "HTTP/1.1"; response_headers[":status"] = push_response_status[i]; @@ -211,15 +212,15 @@ } cache_.AddSimpleResponseWithServerPushResources( request_host, "/", 200, response_body, push_resources); - QuicString request_url = request_host + "/"; + std::string request_url = request_host + "/"; std::list<ServerPushInfo> resources = cache_.GetServerPushResources(request_url); ASSERT_EQ(kNumResources, resources.size()); int i = 0; for (const auto& push_resource : push_resources) { QuicUrl url = resources.front().request_url; - QuicString host = url.host(); - QuicString path = url.path(); + std::string host = url.host(); + std::string path = url.path(); const Response* response = cache_.GetResponse(host, path); ASSERT_TRUE(response); ASSERT_TRUE(QuicContainsKey(response->headers(), ":status"));
diff --git a/quic/tools/quic_packet_printer_bin.cc b/quic/tools/quic_packet_printer_bin.cc index c632195..77906a1 100644 --- a/quic/tools/quic_packet_printer_bin.cc +++ b/quic/tools/quic_packet_printer_bin.cc
@@ -208,7 +208,7 @@ int main(int argc, char* argv[]) { const char* usage = "Usage: quic_packet_printer client|server <hex>"; - std::vector<quic::QuicString> args = + std::vector<std::string> args = quic::QuicParseCommandLineFlags(usage, argc, argv); if (args.size() < 2) { @@ -216,7 +216,7 @@ return 1; } - quic::QuicString perspective_string = args[0]; + std::string perspective_string = args[0]; quic::Perspective perspective; if (perspective_string == "client") { perspective = quic::Perspective::IS_CLIENT; @@ -227,7 +227,7 @@ quic::QuicPrintCommandLineFlagHelp(usage); return 1; } - quic::QuicString hex = quic::QuicTextUtils::HexDecode(args[1]); + std::string hex = quic::QuicTextUtils::HexDecode(args[1]); quic::ParsedQuicVersionVector versions = quic::AllSupportedVersions(); // Fake a time since we're not actually generating acks. quic::QuicTime start(quic::QuicTime::Zero());
diff --git a/quic/tools/quic_reject_reason_decoder_bin.cc b/quic/tools/quic_reject_reason_decoder_bin.cc index 14590b6..de66774 100644 --- a/quic/tools/quic_reject_reason_decoder_bin.cc +++ b/quic/tools/quic_reject_reason_decoder_bin.cc
@@ -18,7 +18,7 @@ int main(int argc, char* argv[]) { const char* usage = "Usage: quic_reject_reason_decoder <packed_reason>"; - std::vector<quic::QuicString> args = + std::vector<std::string> args = quic::QuicParseCommandLineFlags(usage, argc, argv); if (args.size() != 1) {
diff --git a/quic/tools/quic_server.h b/quic/tools/quic_server.h index 9ef5f0c..a339d1e 100644 --- a/quic/tools/quic_server.h +++ b/quic/tools/quic_server.h
@@ -48,7 +48,7 @@ ~QuicServer() override; - QuicString Name() const override { return "QuicServer"; } + std::string Name() const override { return "QuicServer"; } // Start listening on the specified address. bool CreateUDPSocketAndListen(const QuicSocketAddress& address);
diff --git a/quic/tools/quic_server_bin.cc b/quic/tools/quic_server_bin.cc index fde94a3..1029fbd 100644 --- a/quic/tools/quic_server_bin.cc +++ b/quic/tools/quic_server_bin.cc
@@ -28,7 +28,7 @@ int main(int argc, char* argv[]) { const char* usage = "Usage: quic_server [options]"; - std::vector<quic::QuicString> non_option_args = + std::vector<std::string> non_option_args = quic::QuicParseCommandLineFlags(usage, argc, argv); if (!non_option_args.empty()) { quic::QuicPrintCommandLineFlagHelp(usage);
diff --git a/quic/tools/quic_simple_crypto_server_stream_helper.cc b/quic/tools/quic_simple_crypto_server_stream_helper.cc index bdd6731..2bb9656 100644 --- a/quic/tools/quic_simple_crypto_server_stream_helper.cc +++ b/quic/tools/quic_simple_crypto_server_stream_helper.cc
@@ -27,7 +27,7 @@ const QuicSocketAddress& client_address, const QuicSocketAddress& peer_address, const QuicSocketAddress& self_address, - QuicString* error_details) const { + std::string* error_details) const { return true; }
diff --git a/quic/tools/quic_simple_crypto_server_stream_helper.h b/quic/tools/quic_simple_crypto_server_stream_helper.h index c058f1a..f8a58f6 100644 --- a/quic/tools/quic_simple_crypto_server_stream_helper.h +++ b/quic/tools/quic_simple_crypto_server_stream_helper.h
@@ -27,7 +27,7 @@ const QuicSocketAddress& client_address, const QuicSocketAddress& peer_address, const QuicSocketAddress& self_address, - QuicString* error_details) const override; + std::string* error_details) const override; private: QuicRandom* random_; // Unowned.
diff --git a/quic/tools/quic_simple_server_backend.h b/quic/tools/quic_simple_server_backend.h index a75143a..74afb60 100644 --- a/quic/tools/quic_simple_server_backend.h +++ b/quic/tools/quic_simple_server_backend.h
@@ -27,7 +27,7 @@ virtual QuicConnectionId connection_id() const = 0; virtual QuicStreamId stream_id() const = 0; - virtual QuicString peer_host() const = 0; + virtual std::string peer_host() const = 0; // Called when the response is ready at the backend and can be send back to // the QUIC client. virtual void OnResponseBackendComplete( @@ -38,7 +38,7 @@ virtual ~QuicSimpleServerBackend() = default; // This method initializes the backend instance to fetch responses // from a backend server, in-memory cache etc. - virtual bool InitializeBackend(const QuicString& backend_url) = 0; + virtual bool InitializeBackend(const std::string& backend_url) = 0; // Returns true if the backend has been successfully initialized // and could be used to fetch HTTP requests virtual bool IsBackendInitialized() const = 0; @@ -49,7 +49,7 @@ // asynchronously calls |request_handler| with the HTTP response. virtual void FetchResponseFromBackend( const spdy::SpdyHeaderBlock& request_headers, - const QuicString& request_body, + const std::string& request_body, RequestHandler* request_handler) = 0; // Clears the state of the backend instance virtual void CloseBackendResponseStream(RequestHandler* request_handler) = 0;
diff --git a/quic/tools/quic_simple_server_session.cc b/quic/tools/quic_simple_server_session.cc index 7e2e3bf..a722d37 100644 --- a/quic/tools/quic_simple_server_session.cc +++ b/quic/tools/quic_simple_server_session.cc
@@ -61,7 +61,7 @@ } void QuicSimpleServerSession::PromisePushResources( - const QuicString& request_url, + const std::string& request_url, const std::list<QuicBackendResponse::ServerPushInfo>& resources, QuicStreamId original_stream_id, const spdy::SpdyHeaderBlock& original_request_headers) { @@ -160,7 +160,7 @@ } spdy::SpdyHeaderBlock QuicSimpleServerSession::SynthesizePushRequestHeaders( - QuicString request_url, + std::string request_url, QuicBackendResponse::ServerPushInfo resource, const spdy::SpdyHeaderBlock& original_request_headers) { QuicUrl push_request_url = resource.request_url;
diff --git a/quic/tools/quic_simple_server_session.h b/quic/tools/quic_simple_server_session.h index 45c97d0..81e067d 100644 --- a/quic/tools/quic_simple_server_session.h +++ b/quic/tools/quic_simple_server_session.h
@@ -74,7 +74,7 @@ // And enqueue HEADERS block in those PUSH_PROMISED for sending push response // later. virtual void PromisePushResources( - const QuicString& request_url, + const std::string& request_url, const std::list<QuicBackendResponse::ServerPushInfo>& resources, QuicStreamId original_stream_id, const spdy::SpdyHeaderBlock& original_request_headers); @@ -112,7 +112,7 @@ // Copying the rest headers ensures they are the same as the original // request, especially cookies. spdy::SpdyHeaderBlock SynthesizePushRequestHeaders( - QuicString request_url, + std::string request_url, QuicBackendResponse::ServerPushInfo resource, const spdy::SpdyHeaderBlock& original_request_headers);
diff --git a/quic/tools/quic_simple_server_session_test.cc b/quic/tools/quic_simple_server_session_test.cc index b2ef667..8d5b05c 100644 --- a/quic/tools/quic_simple_server_session_test.cc +++ b/quic/tools/quic_simple_server_session_test.cc
@@ -601,28 +601,28 @@ // than stream flow control window so stream won't send the full body. size_t body_size = 2 * kStreamFlowControlWindowSize; // 64KB. - QuicString request_url = "mail.google.com/"; + std::string request_url = "mail.google.com/"; spdy::SpdyHeaderBlock request_headers; - QuicString resource_host = "www.google.com"; - QuicString partial_push_resource_path = "/server_push_src"; + std::string resource_host = "www.google.com"; + std::string partial_push_resource_path = "/server_push_src"; std::list<QuicBackendResponse::ServerPushInfo> push_resources; - QuicString scheme = "http"; + std::string scheme = "http"; QuicByteCount header_length = 0; for (unsigned int i = 1; i <= num_resources; ++i) { QuicStreamId stream_id = GetNthServerInitiatedUnidirectionalId(i - 1); - QuicString path = + std::string path = partial_push_resource_path + QuicTextUtils::Uint64ToString(i); - QuicString url = scheme + "://" + resource_host + path; + std::string url = scheme + "://" + resource_host + path; QuicUrl resource_url = QuicUrl(url); - QuicString body(body_size, 'a'); - QuicString data; + std::string body(body_size, 'a'); + std::string data; header_length = 0; if (VersionHasDataFrameHeader(connection_->transport_version())) { HttpEncoder encoder; std::unique_ptr<char[]> buffer; header_length = encoder.SerializeDataFrameHeader(body.length(), &buffer); - QuicString header = QuicString(buffer.get(), header_length); + std::string header = std::string(buffer.get(), header_length); data = header + body; } else { data = body;
diff --git a/quic/tools/quic_simple_server_stream.cc b/quic/tools/quic_simple_server_stream.cc index 541ff32..4e25552 100644 --- a/quic/tools/quic_simple_server_stream.cc +++ b/quic/tools/quic_simple_server_stream.cc
@@ -155,7 +155,7 @@ return id(); } -QuicString QuicSimpleServerStream::peer_host() const { +std::string QuicSimpleServerStream::peer_host() const { return spdy_session()->peer_address().host().ToString(); } @@ -192,8 +192,8 @@ // response status, send error response. Notice that // QuicHttpResponseCache push urls are strictly authority + path only, // scheme is not included (see |QuicHttpResponseCache::GetKey()|). - QuicString request_url = request_headers_[":authority"].as_string() + - request_headers_[":path"].as_string(); + std::string request_url = request_headers_[":authority"].as_string() + + request_headers_[":path"].as_string(); int response_code; const SpdyHeaderBlock& response_headers = response->headers(); if (!ParseHeaderStatusCode(response_headers, &response_code)) {
diff --git a/quic/tools/quic_simple_server_stream.h b/quic/tools/quic_simple_server_stream.h index 2e6826f..4472262 100644 --- a/quic/tools/quic_simple_server_stream.h +++ b/quic/tools/quic_simple_server_stream.h
@@ -56,7 +56,7 @@ // Implements QuicSimpleServerBackend::RequestHandler callbacks QuicConnectionId connection_id() const override; QuicStreamId stream_id() const override; - QuicString peer_host() const override; + std::string peer_host() const override; void OnResponseBackendComplete( const QuicBackendResponse* response, std::list<QuicBackendResponse::ServerPushInfo> resources) override; @@ -87,12 +87,12 @@ spdy::SpdyHeaderBlock* request_headers() { return &request_headers_; } - const QuicString& body() { return body_; } + const std::string& body() { return body_; } // The parsed headers received from the client. spdy::SpdyHeaderBlock request_headers_; int64_t content_length_; - QuicString body_; + std::string body_; private: QuicSimpleServerBackend* quic_simple_server_backend_; // Not owned.
diff --git a/quic/tools/quic_simple_server_stream_test.cc b/quic/tools/quic_simple_server_stream_test.cc index 88c85e4..7572a75 100644 --- a/quic/tools/quic_simple_server_stream_test.cc +++ b/quic/tools/quic_simple_server_stream_test.cc
@@ -68,8 +68,8 @@ void DoSendErrorResponse() { SendErrorResponse(); } spdy::SpdyHeaderBlock* mutable_headers() { return &request_headers_; } - void set_body(QuicString body) { body_ = std::move(body); } - const QuicString& body() const { return body_; } + void set_body(std::string body) { body_ = std::move(body); } + const std::string& body() const { return body_; } int content_length() const { return content_length_; } QuicStringPiece GetHeader(QuicStringPiece key) const { @@ -113,7 +113,7 @@ MOCK_METHOD3(OnConnectionClosed, void(QuicErrorCode error, - const QuicString& error_details, + const std::string& error_details, ConnectionCloseSource source)); MOCK_METHOD1(CreateIncomingStream, QuicSpdyStream*(QuicStreamId id)); MOCK_METHOD5(WritevData, @@ -136,7 +136,7 @@ MOCK_METHOD1(OnHeadersHeadOfLineBlocking, void(QuicTime::Delta delta)); // Matchers cannot be used on non-copyable types like SpdyHeaderBlock. void PromisePushResources( - const QuicString& request_url, + const std::string& request_url, const std::list<QuicBackendResponse::ServerPushInfo>& resources, QuicStreamId original_stream_id, const spdy::SpdyHeaderBlock& original_request_headers) override { @@ -145,7 +145,7 @@ original_request_headers); } MOCK_METHOD4(PromisePushResourcesMock, - void(const QuicString&, + void(const std::string&, const std::list<QuicBackendResponse::ServerPushInfo>&, QuicStreamId, const spdy::SpdyHeaderBlock&)); @@ -206,9 +206,9 @@ connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); } - const QuicString& StreamBody() { return stream_->body(); } + const std::string& StreamBody() { return stream_->body(); } - QuicString StreamHeadersValue(const QuicString& key) { + std::string StreamHeadersValue(const std::string& key) { return (*stream_->mutable_headers())[key].as_string(); } @@ -232,7 +232,7 @@ StrictMock<MockQuicSimpleServerSession> session_; StrictMock<TestStream>* stream_; // Owned by session_. std::unique_ptr<QuicBackendResponse> quic_response_; - QuicString body_; + std::string body_; QuicHeaderList header_list_; HttpEncoder encoder_; }; @@ -248,8 +248,8 @@ std::unique_ptr<char[]> buffer; QuicByteCount header_length = encoder_.SerializeDataFrameHeader(body_.length(), &buffer); - QuicString header = QuicString(buffer.get(), header_length); - QuicString data = HasFrameHeader() ? header + body_ : body_; + std::string header = std::string(buffer.get(), header_length); + std::string data = HasFrameHeader() ? header + body_ : body_; stream_->OnStreamFrame( QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, data)); EXPECT_EQ("11", StreamHeadersValue("content-length")); @@ -266,8 +266,8 @@ std::unique_ptr<char[]> buffer; QuicByteCount header_length = encoder_.SerializeDataFrameHeader(body_.length(), &buffer); - QuicString header = QuicString(buffer.get(), header_length); - QuicString data = HasFrameHeader() ? header + body_ : body_; + std::string header = std::string(buffer.get(), header_length); + std::string data = HasFrameHeader() ? header + body_ : body_; stream_->OnStreamFrame( QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, data)); EXPECT_EQ("11", StreamHeadersValue("content-length")); @@ -292,7 +292,7 @@ TEST_P(QuicSimpleServerStreamTest, TestFramingExtraData) { InSequence seq; - QuicString large_body = "hello world!!!!!!"; + std::string large_body = "hello world!!!!!!"; // We'll automatically write out an error (headers + body) EXPECT_CALL(*stream_, WriteHeadersMock(false)); @@ -307,8 +307,8 @@ std::unique_ptr<char[]> buffer; QuicByteCount header_length = encoder_.SerializeDataFrameHeader(body_.length(), &buffer); - QuicString header = QuicString(buffer.get(), header_length); - QuicString data = HasFrameHeader() ? header + body_ : body_; + std::string header = std::string(buffer.get(), header_length); + std::string data = HasFrameHeader() ? header + body_ : body_; stream_->OnStreamFrame( QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, data)); @@ -316,8 +316,8 @@ // accept the bytes. header_length = encoder_.SerializeDataFrameHeader(large_body.length(), &buffer); - header = QuicString(buffer.get(), header_length); - QuicString data2 = HasFrameHeader() ? header + large_body : large_body; + header = std::string(buffer.get(), header_length); + std::string data2 = HasFrameHeader() ? header + large_body : large_body; stream_->OnStreamFrame( QuicStreamFrame(stream_->id(), /*fin=*/true, data.size(), data2)); EXPECT_EQ("11", StreamHeadersValue("content-length")); @@ -337,7 +337,7 @@ // HTTP/2 only supports integer responsecode, so "200 OK" is illegal. response_headers_[":status"] = "200 OK"; response_headers_["content-length"] = "5"; - QuicString body = "Yummm"; + std::string body = "Yummm"; std::unique_ptr<char[]> buffer; QuicByteCount header_length = encoder_.SerializeDataFrameHeader(body.length(), &buffer); @@ -371,7 +371,7 @@ // HTTP/2 only supports 3-digit-integer, so "+200" is illegal. response_headers_[":status"] = "+200"; response_headers_["content-length"] = "5"; - QuicString body = "Yummm"; + std::string body = "Yummm"; std::unique_ptr<char[]> buffer; QuicByteCount header_length = @@ -413,7 +413,7 @@ response_headers_[":version"] = "HTTP/1.1"; response_headers_[":status"] = "404"; response_headers_["content-length"] = "8"; - QuicString body = "NotFound"; + std::string body = "NotFound"; memory_cache_backend_.AddResponse("www.google.com", "/bar", std::move(response_headers_), body); @@ -436,7 +436,7 @@ response_headers_[":version"] = "HTTP/1.1"; response_headers_[":status"] = "200"; response_headers_["content-length"] = "5"; - QuicString body = "Yummm"; + std::string body = "Yummm"; std::unique_ptr<char[]> buffer; QuicByteCount header_length = @@ -463,9 +463,9 @@ // call PromisePushResources() to handle these resources. // Add a request and response with valid headers into cache. - QuicString host = "www.google.com"; - QuicString request_path = "/foo"; - QuicString body = "Yummm"; + std::string host = "www.google.com"; + std::string request_path = "/foo"; + std::string body = "Yummm"; std::unique_ptr<char[]> buffer; QuicByteCount header_length = encoder_.SerializeDataFrameHeader(body.length(), &buffer); @@ -526,8 +526,8 @@ WRITE_UNIDIRECTIONAL, &memory_cache_backend_); session_.ActivateStream(QuicWrapUnique(server_initiated_stream)); - const QuicString kHost = "www.foo.com"; - const QuicString kPath = "/bar"; + const std::string kHost = "www.foo.com"; + const std::string kPath = "/bar"; spdy::SpdyHeaderBlock headers; headers[":path"] = kPath; headers[":authority"] = kHost; @@ -537,7 +537,7 @@ response_headers_[":version"] = "HTTP/1.1"; response_headers_[":status"] = "200"; response_headers_["content-length"] = "5"; - const QuicString kBody = "Hello"; + const std::string kBody = "Hello"; std::unique_ptr<char[]> buffer; QuicByteCount header_length = encoder_.SerializeDataFrameHeader(kBody.length(), &buffer);
diff --git a/quic/tools/quic_spdy_client_base.cc b/quic/tools/quic_spdy_client_base.cc index b9b0bd2..3d7ef02 100644 --- a/quic/tools/quic_spdy_client_base.cc +++ b/quic/tools/quic_spdy_client_base.cc
@@ -132,7 +132,7 @@ } void QuicSpdyClientBase::SendRequestsAndWaitForResponse( - const std::vector<QuicString>& url_list) { + const std::vector<std::string>& url_list) { for (size_t i = 0; i < url_list.size(); ++i) { SpdyHeaderBlock headers; if (!SpdyUtils::PopulateHeaderBlockFromUrl(url_list[i], &headers)) { @@ -240,12 +240,12 @@ return latest_response_code_; } -const QuicString& QuicSpdyClientBase::latest_response_headers() const { +const std::string& QuicSpdyClientBase::latest_response_headers() const { QUIC_BUG_IF(!store_response_) << "Response not stored!"; return latest_response_headers_; } -const QuicString& QuicSpdyClientBase::preliminary_response_headers() const { +const std::string& QuicSpdyClientBase::preliminary_response_headers() const { QUIC_BUG_IF(!store_response_) << "Response not stored!"; return preliminary_response_headers_; } @@ -256,12 +256,12 @@ return latest_response_header_block_; } -const QuicString& QuicSpdyClientBase::latest_response_body() const { +const std::string& QuicSpdyClientBase::latest_response_body() const { QUIC_BUG_IF(!store_response_) << "Response not stored!"; return latest_response_body_; } -const QuicString& QuicSpdyClientBase::latest_response_trailers() const { +const std::string& QuicSpdyClientBase::latest_response_trailers() const { QUIC_BUG_IF(!store_response_) << "Response not stored!"; return latest_response_trailers_; }
diff --git a/quic/tools/quic_spdy_client_base.h b/quic/tools/quic_spdy_client_base.h index 3112f9c..a9aadb9 100644 --- a/quic/tools/quic_spdy_client_base.h +++ b/quic/tools/quic_spdy_client_base.h
@@ -37,7 +37,7 @@ virtual void OnCompleteResponse( QuicStreamId id, const spdy::SpdyHeaderBlock& response_headers, - const QuicString& response_body) = 0; + const std::string& response_body) = 0; }; // The client uses these objects to keep track of any data to resend upon @@ -99,7 +99,7 @@ // Sends a request simple GET for each URL in |url_list|, and then waits for // each to complete. - void SendRequestsAndWaitForResponse(const std::vector<QuicString>& url_list); + void SendRequestsAndWaitForResponse(const std::vector<std::string>& url_list); // Returns a newly created QuicSpdyClientStream. QuicSpdyClientStream* CreateClientStream(); @@ -126,11 +126,11 @@ void set_store_response(bool val) { store_response_ = val; } size_t latest_response_code() const; - const QuicString& latest_response_headers() const; - const QuicString& preliminary_response_headers() const; + const std::string& latest_response_headers() const; + const std::string& preliminary_response_headers() const; const spdy::SpdyHeaderBlock& latest_response_header_block() const; - const QuicString& latest_response_body() const; - const QuicString& latest_response_trailers() const; + const std::string& latest_response_body() const; + const std::string& latest_response_trailers() const; void set_response_listener(std::unique_ptr<ResponseListener> listener) { response_listener_ = std::move(listener); @@ -192,15 +192,15 @@ // HTTP response code from most recent response. int latest_response_code_; // HTTP/2 headers from most recent response. - QuicString latest_response_headers_; + std::string latest_response_headers_; // preliminary 100 Continue HTTP/2 headers from most recent response, if any. - QuicString preliminary_response_headers_; + std::string preliminary_response_headers_; // HTTP/2 headers from most recent response. spdy::SpdyHeaderBlock latest_response_header_block_; // Body of most recent response. - QuicString latest_response_body_; + std::string latest_response_body_; // HTTP/2 trailers from most recent response. - QuicString latest_response_trailers_; + std::string latest_response_trailers_; // Listens for full responses. std::unique_ptr<ResponseListener> response_listener_;
diff --git a/quic/tools/quic_url.cc b/quic/tools/quic_url.cc index 675cafe..4094ffe 100644 --- a/quic/tools/quic_url.cc +++ b/quic/tools/quic_url.cc
@@ -11,7 +11,7 @@ static constexpr size_t kMaxHostNameLength = 256; -QuicUrl::QuicUrl(QuicStringPiece url) : url_(static_cast<QuicString>(url)) {} +QuicUrl::QuicUrl(QuicStringPiece url) : url_(static_cast<std::string>(url)) {} QuicUrl::QuicUrl(QuicStringPiece url, QuicStringPiece default_scheme) : QuicUrl(url) { @@ -22,7 +22,7 @@ url_ = GURL(QuicStrCat(default_scheme, "://", url)); } -QuicString QuicUrl::ToString() const { +std::string QuicUrl::ToString() const { if (IsValid()) { return url_.spec(); } @@ -41,12 +41,12 @@ return true; } -QuicString QuicUrl::HostPort() const { +std::string QuicUrl::HostPort() const { if (!IsValid() || !url_.has_host()) { return ""; } - QuicString host = url_.host(); + std::string host = url_.host(); int port = url_.IntPort(); if (port == url::PORT_UNSPECIFIED) { return host; @@ -54,7 +54,7 @@ return QuicStrCat(host, ":", port); } -QuicString QuicUrl::PathParamsQuery() const { +std::string QuicUrl::PathParamsQuery() const { if (!IsValid() || !url_.has_path()) { return "/"; } @@ -62,7 +62,7 @@ return url_.PathForRequest(); } -QuicString QuicUrl::scheme() const { +std::string QuicUrl::scheme() const { if (!IsValid()) { return ""; } @@ -70,7 +70,7 @@ return url_.scheme(); } -QuicString QuicUrl::host() const { +std::string QuicUrl::host() const { if (!IsValid()) { return ""; } @@ -78,7 +78,7 @@ return url_.HostNoBrackets(); } -QuicString QuicUrl::path() const { +std::string QuicUrl::path() const { if (!IsValid()) { return ""; }
diff --git a/quic/tools/quic_url.h b/quic/tools/quic_url.h index f632a9a..7ed190d 100644 --- a/quic/tools/quic_url.h +++ b/quic/tools/quic_url.h
@@ -34,21 +34,21 @@ // Returns full text of the QuicUrl if it is valid. Return empty string // otherwise. - QuicString ToString() const; + std::string ToString() const; // Returns host:port. // If the host is empty, it will return an empty string. // If the host is an IPv6 address, it will be bracketed. // If port is not present or is equal to default_port of scheme (e.g., port // 80 for HTTP), it won't be returned. - QuicString HostPort() const; + std::string HostPort() const; // Returns a string assembles path, parameters and query. - QuicString PathParamsQuery() const; + std::string PathParamsQuery() const; - QuicString scheme() const; - QuicString host() const; - QuicString path() const; + std::string scheme() const; + std::string host() const; + std::string path() const; uint16_t port() const; private:
diff --git a/quic/tools/quic_url_test.cc b/quic/tools/quic_url_test.cc index 384dc2a..3af0be7 100644 --- a/quic/tools/quic_url_test.cc +++ b/quic/tools/quic_url_test.cc
@@ -16,7 +16,7 @@ TEST_F(QuicUrlTest, Basic) { // No scheme specified. - QuicString url_str = "www.example.com"; + std::string url_str = "www.example.com"; QuicUrl url(url_str); EXPECT_FALSE(url.IsValid()); @@ -54,7 +54,7 @@ TEST_F(QuicUrlTest, DefaultScheme) { // Default scheme to HTTP. - QuicString url_str = "www.example.com"; + std::string url_str = "www.example.com"; QuicUrl url(url_str, "http"); EXPECT_EQ("http://www.example.com/", url.ToString()); EXPECT_EQ("http", url.scheme()); @@ -73,7 +73,7 @@ } TEST_F(QuicUrlTest, IsValid) { - QuicString url_str = + std::string url_str = "ftp://www.example.com:12345/path/to/resource?a=1&campaign=2"; EXPECT_TRUE(QuicUrl(url_str).IsValid()); @@ -86,7 +86,7 @@ EXPECT_FALSE(QuicUrl(url_str).IsValid()); // Host name too long. - QuicString host(1024, 'a'); + std::string host(1024, 'a'); url_str = "https://" + host; EXPECT_FALSE(QuicUrl(url_str).IsValid()); @@ -96,7 +96,7 @@ } TEST_F(QuicUrlTest, HostPort) { - QuicString url_str = "http://www.example.com/"; + std::string url_str = "http://www.example.com/"; QuicUrl url(url_str); EXPECT_EQ("www.example.com", url.HostPort()); EXPECT_EQ("www.example.com", url.host()); @@ -134,7 +134,7 @@ } TEST_F(QuicUrlTest, PathParamsQuery) { - QuicString url_str = + std::string url_str = "https://www.example.com:12345/path/to/resource?a=1&campaign=2"; QuicUrl url(url_str); EXPECT_EQ("/path/to/resource?a=1&campaign=2", url.PathParamsQuery());