OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/app/breakpad_field_trial_win.h" |
| 6 |
| 7 #include "base/lazy_instance.h" |
| 8 #include "base/string_util.h" |
| 9 #include "base/string16.h" |
| 10 #include "base/stringprintf.h" |
| 11 #include "breakpad/src/client/windows/common/ipc_protocol.h" |
| 12 #include "chrome/app/breakpad_win.h" |
| 13 #include "chrome/common/child_process_logging.h" |
| 14 |
| 15 extern "C" void __declspec(dllexport) __cdecl SetExperimentList( |
| 16 const std::vector<string16>& experiment_strings) { |
| 17 // Make sure we were initialized before we start writing data |
| 18 if (breakpad_win::g_experiment_chunks_offset == 0) |
| 19 return; |
| 20 |
| 21 size_t num_chunks = 0; |
| 22 size_t current_experiment = 0; |
| 23 string16 current_chunk(google_breakpad::CustomInfoEntry::kValueMaxLength, 0); |
| 24 while (current_experiment < experiment_strings.size() && |
| 25 num_chunks < kMaxReportedExperimentChunks) { |
| 26 // Check if we have enough room to add another experiment to the current |
| 27 // chunk string. If not, we commit the current chunk string and start over. |
| 28 if (current_chunk.size() + experiment_strings[current_experiment].size() > |
| 29 google_breakpad::CustomInfoEntry::kValueMaxLength) { |
| 30 base::wcslcpy( |
| 31 (*breakpad_win::g_custom_entries)[ |
| 32 breakpad_win::g_experiment_chunks_offset + num_chunks].value, |
| 33 current_chunk.c_str(), |
| 34 current_chunk.size() + 1); // This must include the NULL termination. |
| 35 ++num_chunks; |
| 36 current_chunk = experiment_strings[current_experiment]; |
| 37 } else { |
| 38 if (!current_chunk.empty()) |
| 39 current_chunk += L","; |
| 40 current_chunk += experiment_strings[current_experiment]; |
| 41 } |
| 42 ++current_experiment; |
| 43 } |
| 44 |
| 45 // Commit the last chunk that didn't get big enough yet. |
| 46 if (!current_chunk.empty() && num_chunks < kMaxReportedExperimentChunks) { |
| 47 base::wcslcpy( |
| 48 (*breakpad_win::g_custom_entries)[ |
| 49 breakpad_win::g_experiment_chunks_offset + num_chunks].value, |
| 50 current_chunk.c_str(), |
| 51 current_chunk.size() + 1); // This must include the NULL termination. |
| 52 } |
| 53 |
| 54 // Make note of the total number of experiments, |
| 55 // even if it's > kMaxReportedExperimentChunks. This is useful when |
| 56 // correlating stability with the number of experiments running |
| 57 // simultaneously. |
| 58 base::wcslcpy( |
| 59 (*breakpad_win::g_custom_entries)[ |
| 60 breakpad_win::g_num_of_experiments_offset].value, |
| 61 base::StringPrintf(L"%d", experiment_strings.size()).c_str(), |
| 62 google_breakpad::CustomInfoEntry::kValueMaxLength); |
| 63 } |
| 64 |
| 65 namespace testing { |
| 66 |
| 67 void SetExperimentList(const std::vector<string16>& experiment_strings) { |
| 68 ::SetExperimentList(experiment_strings); |
| 69 } |
| 70 |
| 71 } // namespace testing |
OLD | NEW |