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