OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/common/gpu_info.h" | 10 #include "chrome/common/gpu_info.h" |
11 #include "chrome/installer/util/google_update_settings.h" | 11 #include "chrome/installer/util/google_update_settings.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 | 13 |
14 namespace child_process_logging { | 14 namespace child_process_logging { |
15 | 15 |
16 // We use a static string to hold the most recent active url. If we crash, the | 16 // Account for the terminating null character. |
17 // crash handler code will send the contents of this string to the browser. | 17 static const size_t kMaxActiveURLSize = 1024 + 1; |
18 std::string active_url; | 18 static const size_t kClientIdSize = 32 + 1; |
| 19 |
| 20 // We use static strings to hold the most recent active url and the client |
| 21 // identifier. If we crash, the crash handler code will send the contents of |
| 22 // these strings to the browser. |
| 23 char g_active_url[kMaxActiveURLSize]; |
| 24 char g_client_id[kClientIdSize]; |
19 | 25 |
20 void SetActiveURL(const GURL& url) { | 26 void SetActiveURL(const GURL& url) { |
21 active_url = url.possibly_invalid_spec(); | 27 base::strlcpy(g_active_url, |
| 28 url.possibly_invalid_spec().c_str(), |
| 29 kMaxActiveURLSize); |
22 } | 30 } |
23 | 31 |
24 void SetClientId(const std::string& client_id) { | 32 void SetClientId(const std::string& client_id) { |
25 std::string str(client_id); | 33 std::string str(client_id); |
26 ReplaceSubstringsAfterOffset(&str, 0, "-", ""); | 34 ReplaceSubstringsAfterOffset(&str, 0, "-", ""); |
27 | 35 |
28 if (str.empty()) | 36 if (str.empty()) |
29 return; | 37 return; |
30 | 38 |
| 39 base::strlcpy(g_client_id, str.c_str(), kClientIdSize); |
31 std::wstring wstr = ASCIIToWide(str); | 40 std::wstring wstr = ASCIIToWide(str); |
32 GoogleUpdateSettings::SetMetricsId(wstr); | 41 GoogleUpdateSettings::SetMetricsId(wstr); |
33 } | 42 } |
34 | 43 |
| 44 std::string GetClientId() { |
| 45 return std::string(g_client_id); |
| 46 } |
| 47 |
35 void SetActiveExtensions(const std::set<std::string>& extension_ids) { | 48 void SetActiveExtensions(const std::set<std::string>& extension_ids) { |
36 // TODO(port) | 49 // TODO(port) |
37 } | 50 } |
38 | 51 |
39 void SetGpuInfo(const GPUInfo& gpu_info) { | 52 void SetGpuInfo(const GPUInfo& gpu_info) { |
40 // TODO(rlp): Bug 38737. | 53 // TODO(rlp): Bug 38737. |
41 } | 54 } |
42 | 55 |
43 } // namespace child_process_logging | 56 } // namespace child_process_logging |
OLD | NEW |