diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-04 08:38:48 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-04 08:38:48 +0000 |
commit | 64e0b0256a9b537e2bb2d133634596f67960eedd (patch) | |
tree | a95e864cfd1e3f2ccb7a3e2d62abac003dccf440 /net/tools/flip_server | |
parent | 0db5ea2be32e83f95e061400ae8e20aa6e25c1a4 (diff) | |
download | chromium_src-64e0b0256a9b537e2bb2d133634596f67960eedd.zip chromium_src-64e0b0256a9b537e2bb2d133634596f67960eedd.tar.gz chromium_src-64e0b0256a9b537e2bb2d133634596f67960eedd.tar.bz2 |
flip_server: Use base's SplitString() function in LoadTimeMeasurement.
This uses the SplitString() function from base, which has unit tests in place.
TEST=flip_in_mem_edsm_server_unittests
R=wtc@chromium.org
Review URL: https://codereview.chromium.org/185523002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254731 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools/flip_server')
-rw-r--r-- | net/tools/flip_server/loadtime_measurement.h | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/net/tools/flip_server/loadtime_measurement.h b/net/tools/flip_server/loadtime_measurement.h index ccbb2e5..84a8d3a 100644 --- a/net/tools/flip_server/loadtime_measurement.h +++ b/net/tools/flip_server/loadtime_measurement.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef NET_TOOLS_FLIP_SERVER_LOADTIME_MEASUREMENT_H__ -#define NET_TOOLS_FLIP_SERVER_LOADTIME_MEASUREMENT_H__ +#ifndef NET_TOOLS_FLIP_SERVER_LOADTIME_MEASUREMENT_H_ +#define NET_TOOLS_FLIP_SERVER_LOADTIME_MEASUREMENT_H_ #include <errno.h> #include <fcntl.h> @@ -15,6 +15,8 @@ #include <string> #include <vector> +#include "base/strings/string_split.h" + // Class to handle loadtime measure related urls, which all start with testing // The in memory server has a singleton object of this class. It includes a // html file containing javascript to go through a list of urls and upload the @@ -27,7 +29,7 @@ class LoadtimeMeasurement { : num_urls_(0), pageload_html_file_(pageload_html_file) { std::string urls_string; read_file_to_string(urls_file.c_str(), &urls_string); - split_string(urls_string, '\n', &urls_); + base::SplitString(urls_string, '\n', &urls_); num_urls_ = urls_.size(); } @@ -70,13 +72,13 @@ class LoadtimeMeasurement { } if (action.find("record_page_load") == 0) { std::vector<std::string> query; - split_string(action, '?', &query); + base::SplitString(action, '?', &query); std::vector<std::string> params; - split_string(query[1], '&', ¶ms); + base::SplitString(query[1], '&', ¶ms); std::vector<std::string> url; std::vector<std::string> loadtime; - split_string(params[1], '=', &url); - split_string(params[2], '=', &loadtime); + base::SplitString(params[1], '=', &url); + base::SplitString(params[2], '=', &loadtime); loadtimes_[url[1]] = atoi(loadtime[1].c_str()); output.append("OK"); return; @@ -100,25 +102,10 @@ class LoadtimeMeasurement { close(fd); } - void split_string(const std::string& str, - char sepa, - std::vector<std::string>* sub_strs) { - size_t b = 0; - size_t e = str.find_first_of(sepa, b); - while (e != std::string::npos && e > b) { - sub_strs->push_back(str.substr(b, e - b)); - b = e + 1; - e = str.find_first_of(sepa, b); - } - if (b < str.size()) { - sub_strs->push_back(str.substr(b)); - } - } - int num_urls_; std::vector<std::string> urls_; std::map<std::string, int> loadtimes_; const std::string pageload_html_file_; }; -#endif // NET_TOOLS_FLIP_SERVER_LOADTIME_MEASUREMENT_H__ +#endif // NET_TOOLS_FLIP_SERVER_LOADTIME_MEASUREMENT_H_ |