OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 NSString *key = [NSString stringWithUTF8String:kNumberOfViews]; | 169 NSString *key = [NSString stringWithUTF8String:kNumberOfViews]; |
170 NSString *value = [NSString stringWithFormat:@"%d", number_of_views]; | 170 NSString *value = [NSString stringWithFormat:@"%d", number_of_views]; |
171 set_key_func(key, value); | 171 set_key_func(key, value); |
172 } | 172 } |
173 | 173 |
174 void SetNumberOfViews(int number_of_views) { | 174 void SetNumberOfViews(int number_of_views) { |
175 SetNumberOfViewsImpl(number_of_views, SetCrashKeyValue); | 175 SetNumberOfViewsImpl(number_of_views, SetCrashKeyValue); |
176 } | 176 } |
177 | 177 |
178 void SetCommandLine(const CommandLine* command_line) { | 178 void SetCommandLine(const CommandLine* command_line) { |
179 DCHECK(SetCrashKeyValue); | |
180 DCHECK(ClearCrashKey); | |
181 DCHECK(command_line); | 179 DCHECK(command_line); |
182 if (!command_line || !SetCrashKeyValue || !ClearCrashKey) | 180 if (!command_line) |
183 return; | 181 return; |
184 | 182 |
185 // These should match the corresponding strings in breakpad_win.cc. | 183 // These should match the corresponding strings in breakpad_win.cc. |
186 NSString* const kNumSwitchesKey = @"num-switches"; | 184 NSString* const kNumSwitchesKey = @"num-switches"; |
187 NSString* const kSwitchKeyFormat = @"switch-%d"; // 1-based. | 185 NSString* const kSwitchKeyFormat = @"switch-%d"; // 1-based. |
188 | 186 |
189 // Note the total number of switches, not including the exec path. | 187 // Note the total number of switches, not including the exec path. |
190 const CommandLine::StringVector& argv = command_line->argv(); | 188 const CommandLine::StringVector& argv = command_line->argv(); |
191 SetCrashKeyValue(kNumSwitchesKey, | 189 SetCrashKeyValue(kNumSwitchesKey, |
192 [NSString stringWithFormat:@"%d", argv.size() - 1]); | 190 [NSString stringWithFormat:@"%d", argv.size() - 1]); |
193 | 191 |
194 size_t key_i = 0; | 192 size_t key_i = 0; |
195 for (size_t i = 1; i < argv.size() && key_i < kMaxSwitches; ++i) { | 193 for (size_t i = 1; i < argv.size() && key_i < kMaxSwitches; ++i) { |
196 // TODO(shess): Skip boring switches. | 194 // TODO(shess): Skip boring switches. |
197 NSString* key = [NSString stringWithFormat:kSwitchKeyFormat, (key_i + 1)]; | 195 NSString* key = [NSString stringWithFormat:kSwitchKeyFormat, (key_i + 1)]; |
198 NSString* value = base::SysUTF8ToNSString(argv[i]); | 196 NSString* value = base::SysUTF8ToNSString(argv[i]); |
199 SetCrashKeyValue(key, value); | 197 SetCrashKeyValue(key, value); |
200 key_i++; | 198 key_i++; |
201 } | 199 } |
202 | 200 |
203 // Clear out any stale keys. | 201 // Clear out any stale keys. |
204 for (; key_i < kMaxSwitches; ++key_i) { | 202 for (; key_i < kMaxSwitches; ++key_i) { |
205 NSString* key = [NSString stringWithFormat:kSwitchKeyFormat, (key_i + 1)]; | 203 NSString* key = [NSString stringWithFormat:kSwitchKeyFormat, (key_i + 1)]; |
206 ClearCrashKey(key); | 204 ClearCrashKey(key); |
207 } | 205 } |
208 } | 206 } |
209 | 207 |
210 } // namespace child_process_logging | 208 } // namespace child_process_logging |
OLD | NEW |