| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/metrics/perf/perf_provider_chromeos.h" | 5 #include "chrome/browser/metrics/perf/perf_provider_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // NB: StringToInt64 will set value even if the conversion fails. | 91 // NB: StringToInt64 will set value even if the conversion fails. |
| 92 if (!base::StringToInt64(it->second, &value)) | 92 if (!base::StringToInt64(it->second, &value)) |
| 93 return false; | 93 return false; |
| 94 *out = value; | 94 *out = value; |
| 95 return true; | 95 return true; |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Parses the key. e.g.: "PerfCommand::arm::0" returns "arm" | 98 // Parses the key. e.g.: "PerfCommand::arm::0" returns "arm" |
| 99 bool ExtractPerfCommandCpuSpecifier(const std::string& key, | 99 bool ExtractPerfCommandCpuSpecifier(const std::string& key, |
| 100 std::string* cpu_specifier) { | 100 std::string* cpu_specifier) { |
| 101 std::vector<std::string> tokens; | 101 std::vector<std::string> tokens = base::SplitStringUsingSubstr( |
| 102 base::SplitStringUsingSubstr(key, "::", &tokens); | 102 key, "::", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 103 if (tokens.size() != 3) | 103 if (tokens.size() != 3) |
| 104 return false; | 104 return false; |
| 105 if (tokens[0] != "PerfCommand") | 105 if (tokens[0] != "PerfCommand") |
| 106 return false; | 106 return false; |
| 107 *cpu_specifier = tokens[1]; | 107 *cpu_specifier = tokens[1]; |
| 108 // tokens[2] is just a unique string (usually an index). | 108 // tokens[2] is just a unique string (usually an index). |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Hopefully we never need a space in a command argument. | 112 // Hopefully we never need a space in a command argument. |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 std::unique_ptr<SampledProfile> sampled_profile(new SampledProfile); | 662 std::unique_ptr<SampledProfile> sampled_profile(new SampledProfile); |
| 663 sampled_profile->set_trigger_event(SampledProfile::RESTORE_SESSION); | 663 sampled_profile->set_trigger_event(SampledProfile::RESTORE_SESSION); |
| 664 sampled_profile->set_ms_after_restore(time_after_restore.InMilliseconds()); | 664 sampled_profile->set_ms_after_restore(time_after_restore.InMilliseconds()); |
| 665 sampled_profile->set_num_tabs_restored(num_tabs_restored); | 665 sampled_profile->set_num_tabs_restored(num_tabs_restored); |
| 666 | 666 |
| 667 CollectIfNecessary(std::move(sampled_profile)); | 667 CollectIfNecessary(std::move(sampled_profile)); |
| 668 last_session_restore_collection_time_ = base::TimeTicks::Now(); | 668 last_session_restore_collection_time_ = base::TimeTicks::Now(); |
| 669 } | 669 } |
| 670 | 670 |
| 671 } // namespace metrics | 671 } // namespace metrics |
| OLD | NEW |