Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/renderer/renderer_logging_mac.mm

Issue 155238: Add the page url to plugin crashes to aid debugging. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2009 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/renderer/renderer_logging.h"
6
7 #import <Foundation/Foundation.h>
8
9 #include "base/string_util.h"
10 #include "googleurl/src/gurl.h"
11 #import "chrome/app/breakpad_mac.h"
12
13 namespace renderer_logging {
14
15 const int kMaxNumCrashURLChunks = 8;
16 const int kMaxNumURLChunkValueLength = 255;
17 const char *kUrlChunkFormatStr = "url-chunk-%d";
18
19 void SetActiveRendererURLImpl(const GURL& url,
20 SetCrashKeyValueFuncPtr set_key_func,
21 ClearCrashKeyValueFuncPtr clear_key_func) {
22
23 NSString *kUrlChunkFormatStr_utf8 = [NSString
24 stringWithUTF8String:kUrlChunkFormatStr];
25
26 // First remove any old url chunks we might have lying around.
27 for (int i = 0; i < kMaxNumCrashURLChunks; i++) {
28 // On Windows the url-chunk items are 1-based, so match that.
29 NSString *key = [NSString stringWithFormat:kUrlChunkFormatStr_utf8, i+1];
30 clear_key_func(key);
31 }
32
33 const std::string& raw_url_utf8 = url.possibly_invalid_spec();
34 NSString *raw_url = [NSString stringWithUTF8String:raw_url_utf8.c_str()];
35 size_t raw_url_length = [raw_url length];
36
37 // Bail on zero-length URLs.
38 if (raw_url_length == 0) {
39 return;
40 }
41
42 // Parcel the URL up into up to 8, 255 byte segments.
43 size_t start_ofs = 0;
44 for (int i = 0;
45 i < kMaxNumCrashURLChunks && start_ofs < raw_url_length;
46 ++i) {
47
48 // On Windows the url-chunk items are 1-based, so match that.
49 NSString *key = [NSString stringWithFormat:kUrlChunkFormatStr_utf8, i+1];
50 NSRange range;
51 range.location = start_ofs;
52 range.length = std::min((size_t)kMaxNumURLChunkValueLength,
53 raw_url_length - start_ofs);
54 NSString *value = [raw_url substringWithRange:range];
55 set_key_func(key, value);
56
57 // Next chunk.
58 start_ofs += kMaxNumURLChunkValueLength;
59 }
60 }
61
62 void SetActiveRendererURL(const GURL& url) {
63 // If Breakpad isn't initialized then bail.
64 if (IsCrashReporterDisabled()) {
65 return;
66 }
67
68 SetActiveRendererURLImpl(url, SetCrashKeyValue, ClearCrashKeyValue);
69 }
70
71 } // namespace renderer_logging
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_logging_linux.cc ('k') | chrome/renderer/renderer_logging_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698