summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/child_process_logging.h20
-rw-r--r--chrome/common/child_process_logging_mac.mm36
-rw-r--r--chrome/common/child_process_logging_mac_unittest.mm8
-rw-r--r--chrome/common/mac/DEPS5
-rw-r--r--chrome/common/mac/objc_zombie.mm6
5 files changed, 29 insertions, 46 deletions
diff --git a/chrome/common/child_process_logging.h b/chrome/common/child_process_logging.h
index 7b80c82..0daabb8 100644
--- a/chrome/common/child_process_logging.h
+++ b/chrome/common/child_process_logging.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,6 +10,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/mac/crash_logging.h"
#include "googleurl/src/gurl.h"
struct GPUInfo;
@@ -78,25 +79,20 @@ class ScopedActiveURLSetter {
} // namespace child_process_logging
-#if defined(OS_MACOSX) && __OBJC__
-
-@class NSString;
-
-typedef void (*SetCrashKeyValueFuncPtr)(NSString*, NSString*);
-typedef void (*ClearCrashKeyValueFuncPtr)(NSString*);
+#if defined(OS_MACOSX)
namespace child_process_logging {
-void SetCrashKeyFunctions(SetCrashKeyValueFuncPtr set_key_func,
- ClearCrashKeyValueFuncPtr clear_key_func);
+
void SetActiveURLImpl(const GURL& url,
- SetCrashKeyValueFuncPtr set_key_func,
- ClearCrashKeyValueFuncPtr clear_key_func);
+ base::mac::SetCrashKeyValueFuncPtr set_key_func,
+ base::mac::ClearCrashKeyValueFuncPtr clear_key_func);
extern const int kMaxNumCrashURLChunks;
extern const int kMaxNumURLChunkValueLength;
extern const char *kUrlChunkFormatStr;
+
} // namespace child_process_logging
-#endif // defined(OS_MACOSX) && __OBJC__
+#endif // defined(OS_MACOSX)
#endif // CHROME_COMMON_CHILD_PROCESS_LOGGING_H_
diff --git a/chrome/common/child_process_logging_mac.mm b/chrome/common/child_process_logging_mac.mm
index ab3d021..70ee2a7 100644
--- a/chrome/common/child_process_logging_mac.mm
+++ b/chrome/common/child_process_logging_mac.mm
@@ -16,6 +16,11 @@
namespace child_process_logging {
+using base::mac::SetCrashKeyValueFuncPtr;
+using base::mac::ClearCrashKeyValueFuncPtr;
+using base::mac::SetCrashKeyValue;
+using base::mac::ClearCrashKey;
+
const int kMaxNumCrashURLChunks = 8;
const int kMaxNumURLChunkValueLength = 255;
const char *kUrlChunkFormatStr = "url-chunk-%d";
@@ -30,19 +35,10 @@ const char *kNumberOfViews = "num-views";
NSString* const kNumExtensionsName = @"num-extensions";
NSString* const kExtensionNameFormat = @"extension-%d";
-static SetCrashKeyValueFuncPtr g_set_key_func;
-static ClearCrashKeyValueFuncPtr g_clear_key_func;
-
// Account for the terminating null character.
static const size_t kClientIdSize = 32 + 1;
static char g_client_id[kClientIdSize];
-void SetCrashKeyFunctions(SetCrashKeyValueFuncPtr set_key_func,
- ClearCrashKeyValueFuncPtr clear_key_func) {
- g_set_key_func = set_key_func;
- g_clear_key_func = clear_key_func;
-}
-
void SetActiveURLImpl(const GURL& url,
SetCrashKeyValueFuncPtr set_key_func,
ClearCrashKeyValueFuncPtr clear_key_func) {
@@ -94,8 +90,7 @@ void SetClientIdImpl(const std::string& client_id,
}
void SetActiveURL(const GURL& url) {
- if (g_set_key_func && g_clear_key_func)
- SetActiveURLImpl(url, g_set_key_func, g_clear_key_func);
+ SetActiveURLImpl(url, SetCrashKeyValue, ClearCrashKey);
}
void SetClientId(const std::string& client_id) {
@@ -103,8 +98,7 @@ void SetClientId(const std::string& client_id) {
ReplaceSubstringsAfterOffset(&str, 0, "-", "");
base::strlcpy(g_client_id, str.c_str(), kClientIdSize);
- if (g_set_key_func)
- SetClientIdImpl(str, g_set_key_func);
+ SetClientIdImpl(str, SetCrashKeyValue);
std::wstring wstr = ASCIIToWide(str);
GoogleUpdateSettings::SetMetricsId(wstr);
@@ -115,12 +109,10 @@ std::string GetClientId() {
}
void SetActiveExtensions(const std::set<std::string>& extension_ids) {
- if (!g_set_key_func)
- return;
-
// Log the count separately to track heavy users.
const int count = static_cast<int>(extension_ids.size());
- g_set_key_func(kNumExtensionsName, [NSString stringWithFormat:@"%i", count]);
+ SetCrashKeyValue(kNumExtensionsName,
+ [NSString stringWithFormat:@"%i", count]);
// Record up to |kMaxReportedActiveExtensions| extensions, clearing
// keys if there aren't that many.
@@ -128,10 +120,10 @@ void SetActiveExtensions(const std::set<std::string>& extension_ids) {
for (int i = 0; i < kMaxReportedActiveExtensions; ++i) {
NSString* key = [NSString stringWithFormat:kExtensionNameFormat, i];
if (iter != extension_ids.end()) {
- g_set_key_func(key, [NSString stringWithUTF8String:iter->c_str()]);
+ SetCrashKeyValue(key, [NSString stringWithUTF8String:iter->c_str()]);
++iter;
} else {
- g_clear_key_func(key);
+ ClearCrashKey(key);
}
}
}
@@ -166,8 +158,7 @@ void SetGpuInfoImpl(const GPUInfo& gpu_info,
}
void SetGpuInfo(const GPUInfo& gpu_info) {
- if (g_set_key_func)
- SetGpuInfoImpl(gpu_info, g_set_key_func);
+ SetGpuInfoImpl(gpu_info, SetCrashKeyValue);
}
@@ -179,8 +170,7 @@ void SetNumberOfViewsImpl(int number_of_views,
}
void SetNumberOfViews(int number_of_views) {
- if (g_set_key_func)
- SetNumberOfViewsImpl(number_of_views, g_set_key_func);
+ SetNumberOfViewsImpl(number_of_views, SetCrashKeyValue);
}
} // namespace child_process_logging
diff --git a/chrome/common/child_process_logging_mac_unittest.mm b/chrome/common/child_process_logging_mac_unittest.mm
index a751287..feedcbe 100644
--- a/chrome/common/child_process_logging_mac_unittest.mm
+++ b/chrome/common/child_process_logging_mac_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,6 +7,7 @@
#import <Foundation/Foundation.h>
#include "base/logging.h"
+#include "base/mac/crash_logging.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -88,8 +89,9 @@ NSMutableDictionary* MockBreakpadKeyValueStore::dict;
void SetActiveURLWithMock(const GURL& url) {
using child_process_logging::SetActiveURLImpl;
- SetCrashKeyValueFuncPtr setFunc = MockBreakpadKeyValueStore::SetKeyValue;
- ClearCrashKeyValueFuncPtr clearFunc =
+ base::mac::SetCrashKeyValueFuncPtr setFunc =
+ MockBreakpadKeyValueStore::SetKeyValue;
+ base::mac::ClearCrashKeyValueFuncPtr clearFunc =
MockBreakpadKeyValueStore::ClearKeyValue;
SetActiveURLImpl(url, setFunc, clearFunc);
diff --git a/chrome/common/mac/DEPS b/chrome/common/mac/DEPS
index b0c96ed..77a551b 100644
--- a/chrome/common/mac/DEPS
+++ b/chrome/common/mac/DEPS
@@ -1,8 +1,3 @@
include_rules = [
- # TODO(shess): http://crbug.com/95272
- # This dependency needed by objc_zombie.mm. Unfortunately, putting
- # objc_zombie.mm in chrome/app calls into existence unspeakable horrors.
- "+chrome/app",
-
"+third_party/mach_override",
]
diff --git a/chrome/common/mac/objc_zombie.mm b/chrome/common/mac/objc_zombie.mm
index c60981b..3e9ce8a 100644
--- a/chrome/common/mac/objc_zombie.mm
+++ b/chrome/common/mac/objc_zombie.mm
@@ -16,10 +16,10 @@
#include "base/debug/stack_trace.h"
#include "base/logging.h"
+#include "base/mac/crash_logging.h"
#include "base/mac/mac_util.h"
#include "base/metrics/histogram.h"
#include "base/synchronization/lock.h"
-#import "chrome/app/breakpad_mac.h"
#import "chrome/common/mac/objc_method_swizzle.h"
// Deallocated objects are re-classed as |CrZombie|. No superclass
@@ -284,7 +284,7 @@ void ZombieObjectCrash(id object, SEL aSelector, SEL viaSelector) {
}
// Set a value for breakpad to report.
- SetCrashKeyValue(@"zombie", aString);
+ base::mac::SetCrashKeyValue(@"zombie", aString);
// Hex-encode the backtrace and tuck it into a breakpad key.
NSString* deallocTrace = @"<unknown>";
@@ -300,7 +300,7 @@ void ZombieObjectCrash(id object, SEL aSelector, SEL viaSelector) {
// Warn someone if this exceeds the breakpad limits.
DCHECK_LE(strlen([deallocTrace UTF8String]), 255U);
}
- SetCrashKeyValue(@"zombie_dealloc_bt", deallocTrace);
+ base::mac::SetCrashKeyValue(@"zombie_dealloc_bt", deallocTrace);
// Log -dealloc backtrace in debug builds then crash with a useful
// stack trace.