diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-20 15:06:40 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-22 11:48:58 +0000 |
commit | daa093eea7c773db06799a13bd7e4e2e2a9f8f14 (patch) | |
tree | 96cc5e7b9194c1b29eab927730bfa419e7111c25 /chromium/base/linux_util.cc | |
parent | be59a35641616a4cf23c4a13fa0632624b021c1b (diff) | |
download | qtwebengine-chromium-daa093eea7c773db06799a13bd7e4e2e2a9f8f14.tar.gz |
BASELINE: Update Chromium to 63.0.3239.58
Change-Id: Ia93b322a00ba4dd4004f3bcf1254063ba90e1605
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/base/linux_util.cc')
-rw-r--r-- | chromium/base/linux_util.cc | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/chromium/base/linux_util.cc b/chromium/base/linux_util.cc index bf504718f06..851a6c67ab0 100644 --- a/chromium/base/linux_util.cc +++ b/chromium/base/linux_util.cc @@ -22,6 +22,7 @@ #include "base/process/launch.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" +#include "base/strings/string_tokenizer.h" #include "base/strings/string_util.h" #include "base/synchronization/lock.h" #include "build/build_config.h" @@ -199,25 +200,24 @@ pid_t FindThreadID(pid_t pid, pid_t ns_tid, bool* ns_pid_supported) { std::string status; if (!ReadFileToString(FilePath(buf), &status)) return -1; - StringPairs pairs; - SplitStringIntoKeyValuePairs(status, ':', '\n', &pairs); - for (const auto& pair : pairs) { - const std::string& key = pair.first; - const std::string& value_str = pair.second; - if (key == "NSpid") { - if (ns_pid_supported) - *ns_pid_supported = true; - std::vector<StringPiece> split_value_str = SplitStringPiece( - value_str, "\t", TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY); - DCHECK_NE(split_value_str.size(), 0u); - int value; - // The last value in the list is the PID in the namespace. - if (StringToInt(split_value_str.back(), &value) && value == ns_tid) { - // The first value in the list is the real PID. - if (StringToInt(split_value_str.front(), &value)) - return value; - } + StringTokenizer tokenizer(status, "\n"); + while (tokenizer.GetNext()) { + StringPiece value_str(tokenizer.token_piece()); + if (!value_str.starts_with("NSpid")) + continue; + if (ns_pid_supported) + *ns_pid_supported = true; + std::vector<StringPiece> split_value_str = SplitStringPiece( + value_str, "\t", TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY); + DCHECK_GE(split_value_str.size(), 2u); + int value; + // The last value in the list is the PID in the namespace. + if (StringToInt(split_value_str.back(), &value) && value == ns_tid) { + // The second value in the list is the real PID. + if (StringToInt(split_value_str[1], &value)) + return value; } + break; } } return -1; |