diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-16 03:10:32 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-16 03:10:32 +0000 |
commit | 6d24aff09d504fabafd368b8d298a2be217ad962 (patch) | |
tree | 150d9203c5b2d791e862fd4d7b497ddd253afe93 /chrome | |
parent | 12abdcdda33d5030f892de6f8a0b4b69513c6b61 (diff) | |
download | chromium_src-6d24aff09d504fabafd368b8d298a2be217ad962.zip chromium_src-6d24aff09d504fabafd368b8d298a2be217ad962.tar.gz chromium_src-6d24aff09d504fabafd368b8d298a2be217ad962.tar.bz2 |
[Mac] Breakpad key to help track web-drag crash.
BUG=78782
TEST=Monitor crashes.
Review URL: http://codereview.chromium.org/6861004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/scoped_crash_key_mac.h | 32 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_application_mac.mm | 19 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/tab_contents/web_drag_source.mm | 15 | ||||
-rw-r--r-- | chrome/chrome_dll.gypi | 1 |
4 files changed, 48 insertions, 19 deletions
diff --git a/chrome/app/scoped_crash_key_mac.h b/chrome/app/scoped_crash_key_mac.h new file mode 100644 index 0000000..3eedc0b --- /dev/null +++ b/chrome/app/scoped_crash_key_mac.h @@ -0,0 +1,32 @@ +// 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. + +#ifndef CHROME_APP_SCOPED_CRASH_KEY_MAC_H_ +#define CHROME_APP_SCOPED_CRASH_KEY_MAC_H_ +#pragma once + +#import <Foundation/Foundation.h> + +#import "base/memory/scoped_nsobject.h" +#import "chrome/app/breakpad_mac.h" + +// This helper can be used to add additional breakpad keys when some +// code is known to crash. It should only be used when more +// traditional debugging has not been able to reproduce the problem. + +class ScopedCrashKey { + public: + ScopedCrashKey(NSString* key, NSString* value) + : crash_key_([key retain]) { + SetCrashKeyValue(crash_key_.get(), value); + } + ~ScopedCrashKey() { + ClearCrashKeyValue(crash_key_.get()); + } + + private: + scoped_nsobject<NSString> crash_key_; +}; + +#endif // CHROME_APP_SCOPED_CRASH_KEY_MAC_H_ diff --git a/chrome/browser/chrome_browser_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm index 8e605ee..0c2ac3c 100644 --- a/chrome/browser/chrome_browser_application_mac.mm +++ b/chrome/browser/chrome_browser_application_mac.mm @@ -8,7 +8,7 @@ #import "base/metrics/histogram.h" #import "base/memory/scoped_nsobject.h" #import "base/sys_string_conversions.h" -#import "chrome/app/breakpad_mac.h" +#import "chrome/app/scoped_crash_key_mac.h" #import "chrome/browser/app_controller_mac.h" #import "chrome/browser/ui/cocoa/objc_method_swizzle.h" #import "chrome/browser/ui/cocoa/objc_zombie.h" @@ -178,23 +178,6 @@ void CancelTerminate() { namespace { -// Helper to make it easy to get crash keys right. -// TODO(shess): Find a better home for this. app/breakpad_mac.h -// doesn't work. -class ScopedCrashKey { - public: - ScopedCrashKey(NSString* key, NSString* value) - : crash_key_([key retain]) { - SetCrashKeyValue(crash_key_.get(), value); - } - ~ScopedCrashKey() { - ClearCrashKeyValue(crash_key_.get()); - } - - private: - scoped_nsobject<NSString> crash_key_; -}; - // Do-nothing wrapper so that we can arrange to only swizzle // -[NSException raise] when DCHECK() is turned on (as opposed to // replicating the preprocess logic which turns DCHECK() on). diff --git a/chrome/browser/ui/cocoa/tab_contents/web_drag_source.mm b/chrome/browser/ui/cocoa/tab_contents/web_drag_source.mm index a655473..0a883df 100644 --- a/chrome/browser/ui/cocoa/tab_contents/web_drag_source.mm +++ b/chrome/browser/ui/cocoa/tab_contents/web_drag_source.mm @@ -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,7 +10,9 @@ #include "base/sys_string_conversions.h" #include "base/task.h" #include "base/threading/thread.h" +#include "base/threading/thread_restrictions.h" #include "base/utf_string_conversions.h" +#import "chrome/app/scoped_crash_key_mac.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/download_util.h" @@ -40,6 +42,12 @@ NSString* const kNSURLTitlePboardType = @"public.url-name"; // TODO(viettrungluu): Refactor to make it common across platforms, // and move it somewhere sensible. FilePath GetFileNameFromDragData(const WebDropData& drop_data) { + // Set a breakpad key for the scope of this function to help debug + // http://crbug.com/78782 + static NSString* const kUrlKey = @"drop_data_url"; + NSString* value = SysUTF8ToNSString(drop_data.url.spec()); + ScopedCrashKey key(kUrlKey, value); + // Images without ALT text will only have a file extension so we need to // synthesize one from the provided extension and URL. FilePath file_name([SysUTF16ToNSString(drop_data.file_description_filename) @@ -307,6 +315,11 @@ void PromiseWriterTask::Run() { GetFileNameFromDragData(*dropData_) : downloadFileName_; FilePath filePath(SysNSStringToUTF8(path)); filePath = filePath.Append(fileName); + + // CreateFileStreamForDrop() will call file_util::PathExists(), + // which is blocking. Since this operation is already blocking the + // UI thread on OSX, it should be reasonable to let it happen. + base::ThreadRestrictions::ScopedAllowIO allow_io; FileStream* fileStream = drag_download_util::CreateFileStreamForDrop(&filePath); if (!fileStream) diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi index e8a7fa1..1057a1f 100644 --- a/chrome/chrome_dll.gypi +++ b/chrome/chrome_dll.gypi @@ -179,6 +179,7 @@ 'app/chrome_main_app_mode_mac.mm', 'app/chrome_main_mac.mm', 'app/chrome_main_posix.cc', + 'app/scoped_crash_key_mac.h', ], 'include_dirs': [ '<(grit_out_dir)', |