Some style guide compliance changes and changed the prototype of the method to get custom client info in ClientInfo class.

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@270 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
doshimun 2008-05-07 21:54:12 +00:00
parent c2bdaa613c
commit 8602aa71ec
4 changed files with 25 additions and 21 deletions

View File

@ -169,9 +169,8 @@ bool ClientInfo::PopulateCustomInfo() {
return bytes_count == read_count; return bytes_count == read_count;
} }
int ClientInfo::GetCustomInfo(CustomInfoEntry const** custom_info) const { const CustomClientInfo& ClientInfo::GetCustomInfo() const {
*custom_info = custom_info_entries_.get(); return custom_client_info_;
return custom_client_info_.count;
} }
} // namespace google_breakpad } // namespace google_breakpad

View File

@ -88,10 +88,12 @@ class ClientInfo {
bool Initialize(); bool Initialize();
bool GetClientExceptionInfo(EXCEPTION_POINTERS** ex_info) const; bool GetClientExceptionInfo(EXCEPTION_POINTERS** ex_info) const;
bool GetClientThreadId(DWORD* thread_id) const; bool GetClientThreadId(DWORD* thread_id) const;
// Reads the custom information from the client process address space. // Reads the custom information from the client process address space.
bool PopulateCustomInfo(); bool PopulateCustomInfo();
// Returns the client custom information. // Returns the client custom information.
int GetCustomInfo(CustomInfoEntry const** custom_info) const; const CustomClientInfo& GetCustomInfo() const;
private: private:
// Crash generation server. // Crash generation server.

View File

@ -117,9 +117,9 @@ void ExceptionHandler::Initialize(const wstring& dump_path,
// Attempt to use out-of-process if user has specified pipe name. // Attempt to use out-of-process if user has specified pipe name.
if (pipe_name != NULL) { if (pipe_name != NULL) {
scoped_ptr<CrashGenerationClient> client( scoped_ptr<CrashGenerationClient> client(
new CrashGenerationClient(pipe_name, new CrashGenerationClient(pipe_name,
dump_type_, dump_type_,
custom_info)); custom_info));
// If successful in registering with the monitoring process, // If successful in registering with the monitoring process,
// there is no need to setup in-process crash generation. // there is no need to setup in-process crash generation.

View File

@ -63,12 +63,11 @@ BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
static int k_custom_info_count = 2; static int kCustomInfoCount = 2;
static CustomInfoEntry k_custom_info_entries[] = static CustomInfoEntry kCustomInfoEntries[] = {
{ CustomInfoEntry(L"prod", L"CrashTestApp"),
CustomInfoEntry(L"prod", L"CrashTestApp"), CustomInfoEntry(L"ver", L"1.0"),
CustomInfoEntry(L"ver", L"1.0"), };
};
static ExceptionHandler* handler = NULL; static ExceptionHandler* handler = NULL;
static CrashGenerationServer* crash_server = NULL; static CrashGenerationServer* crash_server = NULL;
@ -175,6 +174,7 @@ bool ShowDumpResults(const wchar_t* dump_path,
MDRawAssertionInfo* assertion, MDRawAssertionInfo* assertion,
bool succeeded) { bool succeeded) {
TCHAR* text = new TCHAR[kMaximumLineLength]; TCHAR* text = new TCHAR[kMaximumLineLength];
text[0] = _T('\0');
int result = swprintf_s(text, int result = swprintf_s(text,
kMaximumLineLength, kMaximumLineLength,
TEXT("Dump generation request %s\r\n"), TEXT("Dump generation request %s\r\n"),
@ -190,6 +190,7 @@ bool ShowDumpResults(const wchar_t* dump_path,
static void _cdecl ShowClientConnected(void* context, static void _cdecl ShowClientConnected(void* context,
const ClientInfo* client_info) { const ClientInfo* client_info) {
TCHAR* line = new TCHAR[kMaximumLineLength]; TCHAR* line = new TCHAR[kMaximumLineLength];
line[0] = _T('\0');
int result = swprintf_s(line, int result = swprintf_s(line,
kMaximumLineLength, kMaximumLineLength,
L"Client connected:\t\t%d\r\n", L"Client connected:\t\t%d\r\n",
@ -207,6 +208,7 @@ static void _cdecl ShowClientCrashed(void* context,
const ClientInfo* client_info, const ClientInfo* client_info,
const wstring* dump_path) { const wstring* dump_path) {
TCHAR* line = new TCHAR[kMaximumLineLength]; TCHAR* line = new TCHAR[kMaximumLineLength];
line[0] = _T('\0');
int result = swprintf_s(line, int result = swprintf_s(line,
kMaximumLineLength, kMaximumLineLength,
TEXT("Client requested dump:\t%d\r\n"), TEXT("Client requested dump:\t%d\r\n"),
@ -219,23 +221,23 @@ static void _cdecl ShowClientCrashed(void* context,
QueueUserWorkItem(AppendTextWorker, line, WT_EXECUTEDEFAULT); QueueUserWorkItem(AppendTextWorker, line, WT_EXECUTEDEFAULT);
const CustomInfoEntry* custom_info = NULL; const CustomClientInfo& custom_info = client_info->GetCustomInfo();
int custom_info_count = client_info->GetCustomInfo(&custom_info); if (custom_info.count <= 0) {
if (custom_info_count <= 0) {
return; return;
} }
wstring str_line; wstring str_line;
for (int i = 0; i < custom_info_count; ++i) { for (int i = 0; i < custom_info.count; ++i) {
if (i > 0) { if (i > 0) {
str_line += L", "; str_line += L", ";
} }
str_line += custom_info[i].name; str_line += custom_info.entries[i].name;
str_line += L": "; str_line += L": ";
str_line += custom_info[i].value; str_line += custom_info.entries[i].value;
} }
line = new TCHAR[kMaximumLineLength]; line = new TCHAR[kMaximumLineLength];
line[0] = _T('\0');
result = swprintf_s(line, result = swprintf_s(line,
kMaximumLineLength, kMaximumLineLength,
L"%s\n", L"%s\n",
@ -250,6 +252,7 @@ static void _cdecl ShowClientCrashed(void* context,
static void _cdecl ShowClientExited(void* context, static void _cdecl ShowClientExited(void* context,
const ClientInfo* client_info) { const ClientInfo* client_info) {
TCHAR* line = new TCHAR[kMaximumLineLength]; TCHAR* line = new TCHAR[kMaximumLineLength];
line[0] = _T('\0');
int result = swprintf_s(line, int result = swprintf_s(line,
kMaximumLineLength, kMaximumLineLength,
TEXT("Client exited:\t\t%d\r\n"), TEXT("Client exited:\t\t%d\r\n"),
@ -310,7 +313,7 @@ void RequestDump() {
if (!handler->WriteMinidump()) { if (!handler->WriteMinidump()) {
MessageBoxW(NULL, L"Dump request failed", L"Dumper", MB_OK); MessageBoxW(NULL, L"Dump request failed", L"Dumper", MB_OK);
} }
k_custom_info_entries[1].set_value(L"1.1"); kCustomInfoEntries[1].set_value(L"1.1");
} }
void CleanUp() { void CleanUp() {
@ -462,7 +465,7 @@ int APIENTRY _tWinMain(HINSTANCE instance,
cs_edit = new CRITICAL_SECTION(); cs_edit = new CRITICAL_SECTION();
InitializeCriticalSection(cs_edit); InitializeCriticalSection(cs_edit);
CustomClientInfo custom_info = {k_custom_info_entries, k_custom_info_count}; CustomClientInfo custom_info = {kCustomInfoEntries, kCustomInfoCount};
// This is needed for CRT to not show dialog for invalid param // This is needed for CRT to not show dialog for invalid param
// failures and instead let the code handle it. // failures and instead let the code handle it.