Commit 91523ca2 authored by Kartik Hegde's avatar Kartik Hegde Committed by Commit Bot

network_diagnostics: Add GetRandomAndFixedHostsWithSchemeAndPort()

Add GetRandomAndFixedHostsWithSchemeAndPort() which will be used by network
diagnostics routines.

TEST=none
BUG=chromium:956783

Change-Id: Idca59b4f7c0a05043a8ce8b62465ce696d04be9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462275
Commit-Queue: Kartik Hegde <khegde@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815322}
parent f6e6d462
......@@ -10,6 +10,7 @@
#include "base/no_destructor.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "content/public/browser/storage_partition.h"
......@@ -101,6 +102,19 @@ std::vector<std::string> GetRandomAndFixedHostsWithScheme(int num_random_hosts,
return hosts;
}
std::vector<std::string> GetRandomAndFixedHostsWithSchemeAndPort(
int num_random_hosts,
int prefix_length,
std::string scheme,
int port_number) {
std::vector<std::string> hosts =
GetRandomAndFixedHostsWithScheme(num_random_hosts, prefix_length, scheme);
for (auto& host : hosts) {
host = host + ":" + base::NumberToString(port_number) + "/";
}
return hosts;
}
std::vector<std::string> GetRandomHostsWithSchemeAndGenerate204Path(
int num_hosts,
int prefix_length,
......
......@@ -49,6 +49,15 @@ std::vector<std::string> GetRandomAndFixedHostsWithScheme(int num_random_hosts,
int prefix_length,
std::string scheme);
// Similar to GetRandomAndFixedHostsWithSchemeAndPort, but with |port|, followed
// by "/", appended to the hosts. E.g. A host will look like:
// "https://www.google.com:443/".
std::vector<std::string> GetRandomAndFixedHostsWithSchemeAndPort(
int num_random_hosts,
int prefix_length,
std::string scheme,
int port_number);
// Similar to GetRandomHostsWithScheme, but with the 204 path appended to hosts.
std::vector<std::string> GetRandomHostsWithSchemeAndGenerate204Path(
int num_hosts,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment