Chromium Code Reviews| 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/common/child_process_logging.h" | 5 #include "chrome/common/child_process_logging.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/common/metrics/experiments_helper.h" | |
| 16 #include "chrome/installer/util/google_update_settings.h" | 17 #include "chrome/installer/util/google_update_settings.h" |
| 17 #include "content/public/common/gpu_info.h" | 18 #include "content/public/common/gpu_info.h" |
| 18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 19 | 20 |
| 20 namespace child_process_logging { | 21 namespace child_process_logging { |
| 21 | 22 |
| 22 using base::mac::SetCrashKeyValueFuncPtr; | 23 using base::mac::SetCrashKeyValueFuncPtr; |
| 23 using base::mac::ClearCrashKeyValueFuncPtr; | 24 using base::mac::ClearCrashKeyValueFuncPtr; |
| 24 using base::mac::SetCrashKeyValue; | 25 using base::mac::SetCrashKeyValue; |
| 25 using base::mac::ClearCrashKey; | 26 using base::mac::ClearCrashKey; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 key_i++; | 214 key_i++; |
| 214 } | 215 } |
| 215 | 216 |
| 216 // Clear out any stale keys. | 217 // Clear out any stale keys. |
| 217 for (; key_i < kMaxSwitches; ++key_i) { | 218 for (; key_i < kMaxSwitches; ++key_i) { |
| 218 NSString* key = [NSString stringWithFormat:kSwitchKeyFormat, (key_i + 1)]; | 219 NSString* key = [NSString stringWithFormat:kSwitchKeyFormat, (key_i + 1)]; |
| 219 ClearCrashKey(key); | 220 ClearCrashKey(key); |
| 220 } | 221 } |
| 221 } | 222 } |
| 222 | 223 |
| 223 void SetExperimentList(const std::vector<string16>& state) { | 224 void SetExperimentList(const std::vector<string16>& experiments) { |
| 224 // TODO(mad): Implement this. | 225 // These should match the corresponding strings in breakpad_win.cc. |
| 226 NSString* const kNumExperimentsKey = @"num-experiments"; | |
| 227 NSString* const kExperimentChunkFormat = @"experiment-chunk-%zu"; // 1-based. | |
| 228 | |
| 229 std::vector<string16> chunks; | |
| 230 experiments_helper::GenerateExperimentChunks(experiments, &chunks); | |
| 231 | |
| 232 // Store up to |kMaxReportedExperimentChunks| chunks. | |
| 233 for (size_t i = 0; i < kMaxReportedExperimentChunks; ++i) { | |
| 234 NSString* key = [NSString stringWithFormat:kExperimentChunkFormat, i + 1]; | |
| 235 if (i < chunks.size()) { | |
|
MAD
2012/06/28 13:03:38
Why not run until the min of kMaxReportedExperimen
Alexei Svitkine (slow)
2012/06/28 14:56:09
I originally had it like that, but then I noticed
Scott Hess - ex-Googler
2012/06/29 00:37:07
Yes, this is the correct approach to take.
| |
| 236 NSString* value = base::SysUTF16ToNSString(chunks[i]); | |
| 237 SetCrashKeyValue(key, value); | |
| 238 } else { | |
| 239 ClearCrashKey(key); | |
|
MAD
2012/06/28 13:03:38
If you keep this, break?
Alexei Svitkine (slow)
2012/06/28 14:56:09
See above. (Break does not achieve the result we w
| |
| 240 } | |
| 241 } | |
| 242 | |
| 243 // Make note of the total number of experiments, which may be greater than | |
| 244 // what was able to fit in |kMaxReportedExperimentChunks|. This is useful | |
| 245 // when correlating stability with the number of experiments running | |
| 246 // simultaneously. | |
| 247 SetCrashKeyValue(kNumExperimentsKey, | |
| 248 [NSString stringWithFormat:@"%zu", experiments.size()]); | |
| 225 } | 249 } |
| 226 | 250 |
| 227 void SetChannel(const std::string& channel) { | 251 void SetChannel(const std::string& channel) { |
| 228 // This should match the corresponding string in breakpad_win.cc. | 252 // This should match the corresponding string in breakpad_win.cc. |
| 229 NSString* const kChannelKey = @"channel"; | 253 NSString* const kChannelKey = @"channel"; |
| 230 | 254 |
| 231 SetCrashKeyValue(kChannelKey, base::SysUTF8ToNSString(channel)); | 255 SetCrashKeyValue(kChannelKey, base::SysUTF8ToNSString(channel)); |
| 232 } | 256 } |
| 233 | 257 |
| 234 } // namespace child_process_logging | 258 } // namespace child_process_logging |
| OLD | NEW |