Set the experiment/variation info in crash reports using the crash key logging system.
[chromium-blink-merge.git] / chrome / common / child_process_logging_mac.mm
blob5747945a5944be690091ed1832cb30b426765e1d
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.
5 #include "chrome/common/child_process_logging.h"
7 #import <Foundation/Foundation.h>
9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/installer/util/google_update_settings.h"
13 namespace child_process_logging {
15 using base::debug::SetCrashKeyValueFuncT;
16 using base::debug::ClearCrashKeyValueFuncT;
17 using base::debug::SetCrashKeyValue;
18 using base::debug::ClearCrashKey;
20 const char* kGuidParamName = "guid";
22 // Account for the terminating null character.
23 static const size_t kClientIdSize = 32 + 1;
24 static char g_client_id[kClientIdSize];
26 void SetClientIdImpl(const std::string& client_id,
27                      SetCrashKeyValueFuncT set_key_func) {
28   set_key_func(kGuidParamName, client_id);
31 void SetClientId(const std::string& client_id) {
32   std::string str(client_id);
33   ReplaceSubstringsAfterOffset(&str, 0, "-", "");
35   base::strlcpy(g_client_id, str.c_str(), kClientIdSize);
36     SetClientIdImpl(str, SetCrashKeyValue);
38   std::wstring wstr = ASCIIToWide(str);
39   GoogleUpdateSettings::SetMetricsId(wstr);
42 std::string GetClientId() {
43   return std::string(g_client_id);
46 }  // namespace child_process_logging