diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-02 17:12:29 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-02 17:12:29 +0000 |
commit | 5d95318be4b6988da2cd840db9c6f5c4aee488b5 (patch) | |
tree | 75c3ff02ac0f2c9858b7836fb1d6edda87cd87fb /net/tools/flip_server | |
parent | 01f969dc207201787473e446813929f6c6d721bd (diff) | |
download | chromium_src-5d95318be4b6988da2cd840db9c6f5c4aee488b5.zip chromium_src-5d95318be4b6988da2cd840db9c6f5c4aee488b5.tar.gz chromium_src-5d95318be4b6988da2cd840db9c6f5c4aee488b5.tar.bz2 |
flip_server: Use base's ReadFileToString() function in LoadTimeMeasurement.
Instead of using a custom, hand-made function, it is better to use a
function which has unit tests (in base_unittests) and thus is more
likely to have less bugs.
TEST=flip_in_mem_edsm_server_unittests
R=wtc@chromium.org
Review URL: https://codereview.chromium.org/261063002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools/flip_server')
-rw-r--r-- | net/tools/flip_server/loadtime_measurement.h | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/net/tools/flip_server/loadtime_measurement.h b/net/tools/flip_server/loadtime_measurement.h index 84a8d3a..59fcc0b 100644 --- a/net/tools/flip_server/loadtime_measurement.h +++ b/net/tools/flip_server/loadtime_measurement.h @@ -15,6 +15,7 @@ #include <string> #include <vector> +#include "base/file_util.h" #include "base/strings/string_split.h" // Class to handle loadtime measure related urls, which all start with testing @@ -28,7 +29,7 @@ class LoadtimeMeasurement { const std::string& pageload_html_file) : num_urls_(0), pageload_html_file_(pageload_html_file) { std::string urls_string; - read_file_to_string(urls_file.c_str(), &urls_string); + base::ReadFileToString(urls_file, &urls_string); base::SplitString(urls_string, '\n', &urls_); num_urls_ = urls_.size(); } @@ -41,7 +42,7 @@ class LoadtimeMeasurement { // remove "/testing/" from uri to get the action std::string action = uri.substr(9); if (pageload_html_file_.find(action) != std::string::npos) { - read_file_to_string(pageload_html_file_.c_str(), &output); + base::ReadFileToString(pageload_html_file_, &output); return; } if (action.find("get_total_iteration") == 0) { @@ -86,22 +87,6 @@ class LoadtimeMeasurement { } private: - void read_file_to_string(const char* filename, std::string* output) { - output->clear(); - int fd = open(filename, 0, "r"); - if (fd == -1) - return; - char buffer[4096]; - ssize_t read_status = read(fd, buffer, sizeof(buffer)); - while (read_status > 0) { - output->append(buffer, static_cast<size_t>(read_status)); - do { - read_status = read(fd, buffer, sizeof(buffer)); - } while (read_status <= 0 && errno == EINTR); - } - close(fd); - } - int num_urls_; std::vector<std::string> urls_; std::map<std::string, int> loadtimes_; |