Commit fb57a0eb authored by beidson's avatar beidson

WebCore:

        Reviewed by Beth

        Move the Thread Safety Check functions into their own header for export to WebKit

        * WebCore.exp: Export the function
        * WebCore.xcodeproj/project.pbxproj: 
        * bindings/scripts/CodeGeneratorObjC.pm: Include the new header
        * platform/Logging.h: Move stuff to ThreadCheck.h
        * platform/ThreadCheck.h: Added.
        * platform/mac/LoggingMac.mm: Move stuff to ThreadCheck.mm
        * platform/mac/ThreadCheck.mm: Added.
        (WebCore::_WebCoreThreadViolationCheck):
        (WebCoreReportThreadViolation):

WebKit:

        Reviewed by Beth

        Start using the Thread Safety Check implemented in WebCore for the DOM bindings in the rest of
        the WebKit API instead of the ASSERT_MAIN_THREAD() hack

        * History/WebBackForwardList.mm:
        (-[WebBackForwardList initWithWebCoreBackForwardList:]):
        (-[WebBackForwardList init]):
        (-[WebBackForwardList dealloc]):
        (-[WebBackForwardList finalize]):
        * History/WebHistoryItem.mm:
        (-[WebHistoryItem initWithURLString:title:lastVisitedTimeInterval:]):
        (-[WebHistoryItem dealloc]):
        (-[WebHistoryItem finalize]):
        (-[WebHistoryItem copyWithZone:]):
        (-[WebHistoryItem initWithWebCoreHistoryItem:]):
        * Misc/WebIconDatabase.mm:
        (-[WebIconDatabase init]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@19921 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a1cb81e1
2007-02-28 Brady Eidson <beidson@apple.com>
Reviewed by Beth
Move the Thread Safety Check functions into their own header for export to WebKit
* WebCore.exp: Export the function
* WebCore.xcodeproj/project.pbxproj:
* bindings/scripts/CodeGeneratorObjC.pm: Include the new header
* platform/Logging.h: Move stuff to ThreadCheck.h
* platform/ThreadCheck.h: Added.
* platform/mac/LoggingMac.mm: Move stuff to ThreadCheck.mm
* platform/mac/ThreadCheck.mm: Added.
(WebCore::_WebCoreThreadViolationCheck):
(WebCoreReportThreadViolation):
2007-02-28 Beth Dakin <bdakin@apple.com>
Reviewed by Brady.
......
.objc_class_name_DOMAbstractView
.objc_class_name_DOMAttr
.objc_class_name_DOMCDATASection
......@@ -311,6 +312,7 @@ __ZN7WebCore21findEventWithKeyStateEPNS_5EventE
__ZN7WebCore21isBackForwardLoadTypeENS_13FrameLoadTypeE
__ZN7WebCore24notifyHistoryItemChangedE
__ZN7WebCore26NetscapePlugInStreamLoader6createEPNS_5FrameEP11objc_object
__ZN7WebCore28_WebCoreThreadViolationCheckEPKc
__ZN7WebCore36InitializeLoggingChannelsIfNecessaryEv
__ZN7WebCore3macERKNS_23AuthenticationChallengeE
__ZN7WebCore4FontC1ERKNS_16FontPlatformDataEb
......
......@@ -328,6 +328,8 @@
51D3EA160A3D24D300BADA35 /* SQLDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D3EA130A3D24D300BADA35 /* SQLDatabase.cpp */; };
51D3EA170A3D24D300BADA35 /* SQLDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D3EA140A3D24D300BADA35 /* SQLDatabase.h */; settings = {ATTRIBUTES = (Private, ); }; };
51D3EA180A3D24D300BADA35 /* SQLStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D3EA150A3D24D300BADA35 /* SQLStatement.cpp */; };
51DF6D7E0B92A16D00C2DC85 /* ThreadCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 51DF6D7D0B92A16D00C2DC85 /* ThreadCheck.h */; settings = {ATTRIBUTES = (Private, ); }; };
51DF6D800B92A18E00C2DC85 /* ThreadCheck.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */; };
51F11E150A48C2920034A24E /* SQLTransaction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F11E140A48C2920034A24E /* SQLTransaction.cpp */; };
550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -3426,6 +3428,8 @@
51D3EA130A3D24D300BADA35 /* SQLDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SQLDatabase.cpp; sourceTree = "<group>"; };
51D3EA140A3D24D300BADA35 /* SQLDatabase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SQLDatabase.h; sourceTree = "<group>"; };
51D3EA150A3D24D300BADA35 /* SQLStatement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SQLStatement.cpp; sourceTree = "<group>"; };
51DF6D7D0B92A16D00C2DC85 /* ThreadCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadCheck.h; sourceTree = "<group>"; };
51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ThreadCheck.mm; sourceTree = "<group>"; };
51F11E140A48C2920034A24E /* SQLTransaction.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SQLTransaction.cpp; sourceTree = "<group>"; };
51F6A3D50663BF04004D2919 /* HTMLCanvasElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLCanvasElement.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
51F6A3D60663BF04004D2919 /* HTMLCanvasElement.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HTMLCanvasElement.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
......@@ -6857,6 +6861,7 @@
1402645D0AFDC19B005919E2 /* LoggingMac.mm */,
65F5382409B2B57500F3DC4A /* mac-encodings.txt */,
A70023FF0B02BECC00170215 /* MimeTypeRegistryMac.mm */,
A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */,
4B2709810AF2E5E00065127F /* PasteboardMac.mm */,
935C476F09AC4D7300A6AAB4 /* PlatformMouseEventMac.mm */,
BC3FCAA80AC3DB5800BA54AD /* PlatformScrollBar.h */,
......@@ -6875,6 +6880,7 @@
93B0FD890A759BED0080AD44 /* StringMac.mm */,
6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */,
9352071B09BD3BBB00F2038D /* TextBoundaries.mm */,
51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */,
F5517DC2031AB56301A80180 /* WebCoreHistory.h */,
F5517DC3031AB56301A80180 /* WebCoreHistory.m */,
84B2B1F7056BEF3A00D2B771 /* WebCoreKeyGenerator.h */,
......@@ -6893,7 +6899,6 @@
BC6DADF90A19602B00E5CD14 /* WebFontCache.mm */,
935C477209AC4D7700A6AAB4 /* WheelEventMac.mm */,
9380F47709A11ACC001FDB34 /* WidgetMac.mm */,
A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */,
);
path = mac;
sourceTree = "<group>";
......@@ -9083,6 +9088,7 @@
F587853C02DE375901EA4122 /* DeprecatedValueListImpl.cpp */,
F587853B02DE375901EA4122 /* DeprecatedValueListImpl.h */,
A7B6E69D0B291A9600D0529F /* DragData.h */,
A79546420B5C4CB4007B438F /* DragData.cpp */,
A7CFB3D00B7ED10A0070C32D /* DragImage.h */,
A7CFB3CF0B7ED10A0070C32D /* DragImage.cpp */,
934FE9E40B5CA539003E4A73 /* FileChooser.cpp */,
......@@ -9166,12 +9172,12 @@
F587853902DE375901EA4122 /* TextStream.cpp */,
F58786BF02DE3B8601EA4122 /* TextStream.h */,
93AC8DE00A955FAC00239794 /* TextStyle.h */,
51DF6D7D0B92A16D00C2DC85 /* ThreadCheck.h */,
93309EA1099EB78C0056E581 /* Timer.cpp */,
9305B24C098F1B6B00C28855 /* Timer.h */,
9380F47109A11AB4001FDB34 /* Widget.cpp */,
9380F47209A11AB4001FDB34 /* Widget.h */,
93B780C909B3B7FE00690162 /* WidgetClient.h */,
A79546420B5C4CB4007B438F /* DragData.cpp */,
);
path = platform;
sourceTree = "<group>";
......@@ -11153,6 +11159,7 @@
AB4CB4EB0B8BDA3D009F40B0 /* JSHTMLSelectElementCustom.h in Headers */,
06A6A73D0B8BA44800DF1703 /* StringTruncator.h in Headers */,
934D9BA70B8C1175007B42A9 /* WebCoreNSStringExtras.h in Headers */,
51DF6D7E0B92A16D00C2DC85 /* ThreadCheck.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -12517,6 +12524,7 @@
DD05FE0E0B8BA3C6009ACDFE /* WebCoreObjCExtras.c in Sources */,
06A6A73C0B8BA44800DF1703 /* StringTruncator.cpp in Sources */,
934D9BA50B8C116B007B42A9 /* WebCoreNSStringExtras.mm in Sources */,
51DF6D800B92A18E00C2DC85 /* ThreadCheck.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -977,6 +977,7 @@ sub GenerateImplementation
# - INCLUDES -
push(@implContentHeader, "\n#import \"config.h\"\n");
push(@implContentHeader, "\n#import \"logging.h\"\n");
push(@implContentHeader, "\n#import \"ThreadCheck.h\"\n");
my $conditionalString;
if ($conditional) {
$conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")";
......
......@@ -51,14 +51,6 @@ namespace WebCore {
extern WTFLogChannel LogNetwork;
void InitializeLoggingChannelsIfNecessary();
void _WebCoreThreadViolationCheck(const char* function);
} // namespace WebCore
extern "C" void WebCoreReportThreadViolation(const char* funciton, bool threadViolationIsException);
#define WebCoreThreadViolationCheck() do \
WebCore::_WebCoreThreadViolationCheck(WTF_PRETTY_FUNCTION); \
while (0)
}
#endif // Logging_h
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ThreadCheck_h
#define ThreadCheck_h
namespace WebCore {
void _WebCoreThreadViolationCheck(const char* function);
}
extern "C" void WebCoreReportThreadViolation(const char* function, bool threadViolationIsException);
#define WebCoreThreadViolationCheck() do \
WebCore::_WebCoreThreadViolationCheck(WTF_PRETTY_FUNCTION); \
while (0)
#endif
......@@ -64,42 +64,4 @@ void InitializeLoggingChannelsIfNecessary()
initializeWithUserDefault(LogNetwork);
}
void _WebCoreThreadViolationCheck(const char* function)
{
static bool fetchDefault = true;
static bool performThreadCheck = true;
static bool threadViolationIsException = false;
if (fetchDefault) {
NSString *threadCheckLevel = [[NSUserDefaults standardUserDefaults] objectForKey:@"WebCoreThreadCheck"];
if ([threadCheckLevel isEqualToString:@"None"])
performThreadCheck = false;
else if ([threadCheckLevel isEqualToString:@"Exception"]) {
performThreadCheck = true;
threadViolationIsException = true;
} else if ([threadCheckLevel isEqualToString:@"Log"]) {
performThreadCheck = true;
threadViolationIsException = false;
}
fetchDefault = false;
}
if (!performThreadCheck)
return;
if (pthread_main_np())
return;
WebCoreReportThreadViolation(function, threadViolationIsException);
}
} // namespace WebCore
// Split out the actual reporting of the thread violation to make it easier to set a breakpoint
void WebCoreReportThreadViolation(const char* function, bool threadViolationIsException)
{
if (threadViolationIsException)
[NSException raise:@"WebKitThreadingException" format:@"%s was called from a secondary thread", function];
else
NSLog(@"WebKit Threading Violation - %s called from secondary thread", function);
}
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "config.h"
#import "ThreadCheck.h"
namespace WebCore {
void _WebCoreThreadViolationCheck(const char* function)
{
static bool fetchDefault = true;
static bool performThreadCheck = true;
static bool threadViolationIsException = false;
if (fetchDefault) {
NSString *threadCheckLevel = [[NSUserDefaults standardUserDefaults] objectForKey:@"WebCoreThreadCheck"];
if ([threadCheckLevel isEqualToString:@"None"])
performThreadCheck = false;
else if ([threadCheckLevel isEqualToString:@"Exception"]) {
performThreadCheck = true;
threadViolationIsException = true;
} else if ([threadCheckLevel isEqualToString:@"Log"]) {
performThreadCheck = true;
threadViolationIsException = false;
}
fetchDefault = false;
}
if (!performThreadCheck)
return;
if (pthread_main_np())
return;
WebCoreReportThreadViolation(function, threadViolationIsException);
}
} // namespace WebCore
// Split out the actual reporting of the thread violation to make it easier to set a breakpoint
void WebCoreReportThreadViolation(const char* function, bool threadViolationIsException)
{
if (threadViolationIsException)
[NSException raise:@"WebKitThreadingException" format:@"%s was called from a secondary thread", function];
else
NSLog(@"WebKit Threading Violation - %s called from secondary thread", function);
}
2007-02-28 Brady Eidson <beidson@apple.com>
Reviewed by Beth
Start using the Thread Safety Check implemented in WebCore for the DOM bindings in the rest of
the WebKit API instead of the ASSERT_MAIN_THREAD() hack
* History/WebBackForwardList.mm:
(-[WebBackForwardList initWithWebCoreBackForwardList:]):
(-[WebBackForwardList init]):
(-[WebBackForwardList dealloc]):
(-[WebBackForwardList finalize]):
* History/WebHistoryItem.mm:
(-[WebHistoryItem initWithURLString:title:lastVisitedTimeInterval:]):
(-[WebHistoryItem dealloc]):
(-[WebHistoryItem finalize]):
(-[WebHistoryItem copyWithZone:]):
(-[WebHistoryItem initWithWebCoreHistoryItem:]):
* Misc/WebIconDatabase.mm:
(-[WebIconDatabase init]):
2007-02-28 Adele Peterson <adele@apple.com>
Reviewed by Beth.
......
......@@ -40,6 +40,7 @@
#import <WebCore/BackForwardList.h>
#import <WebCore/HistoryItem.h>
#import <WebCore/RetainPtr.h>
#import <WebCore/ThreadCheck.h>
#import <WebCore/WebCoreObjCExtras.h>
#define COMPUTE_DEFAULT_PAGE_CACHE_SIZE UINT_MAX
......@@ -99,6 +100,7 @@ WebBackForwardList *kit(BackForwardList* list)
- (id)initWithWebCoreBackForwardList:(PassRefPtr<BackForwardList>)list
{
WebCoreThreadViolationCheck();
self = [super init];
if (!self)
return nil;
......@@ -121,6 +123,7 @@ WebBackForwardList *kit(BackForwardList* list)
- (id)init
{
WebCoreThreadViolationCheck();
self = [super init];
if (!self) {
return nil;
......@@ -137,6 +140,7 @@ WebBackForwardList *kit(BackForwardList* list)
- (void)dealloc
{
WebCoreThreadViolationCheck();
BackForwardList* coreList = core(_private);
ASSERT(coreList->closed());
backForwardListWrappers().remove(coreList);
......@@ -147,7 +151,7 @@ WebBackForwardList *kit(BackForwardList* list)
- (void)finalize
{
ASSERT_MAIN_THREAD();
WebCoreThreadViolationCheck();
BackForwardList* coreList = core(_private);
ASSERT(coreList->closed());
backForwardListWrappers().remove(coreList);
......
......@@ -48,6 +48,7 @@
#import <WebCore/KURL.h>
#import <WebCore/PageState.h>
#import <WebCore/PlatformString.h>
#import <WebCore/ThreadCheck.h>
#import <WebCore/WebCoreObjCExtras.h>
#import <WebKitSystemInterface.h>
......@@ -96,12 +97,13 @@ void WKNotifyHistoryItemChanged()
- (id)initWithURLString:(NSString *)URLString title:(NSString *)title lastVisitedTimeInterval:(NSTimeInterval)time
{
WebCoreThreadViolationCheck();
return [self initWithWebCoreHistoryItem:(new HistoryItem(URLString, title, time))];
}
- (void)dealloc
{
ASSERT_MAIN_THREAD();
WebCoreThreadViolationCheck();
if (_private) {
HistoryItem* coreItem = core(_private);
coreItem->deref();
......@@ -112,7 +114,7 @@ void WKNotifyHistoryItemChanged()
- (void)finalize
{
ASSERT_MAIN_THREAD();
WebCoreThreadViolationCheck();
// FIXME: The WebCore::HistoryItem d'tor is what releases the history item's icon from the icon database
// It's probably not good to release icons from the database only when the object is garbage-collected.
// Need to change design so this happens at a predictable time.
......@@ -126,7 +128,7 @@ void WKNotifyHistoryItemChanged()
- (id)copyWithZone:(NSZone *)zone
{
ASSERT_MAIN_THREAD();
WebCoreThreadViolationCheck();
WebHistoryItem *copy = (WebHistoryItem *)NSCopyObject(self, 0, zone);
RefPtr<HistoryItem> item = core(_private)->copy();
copy->_private = kitPrivate(item.get());
......@@ -280,7 +282,7 @@ static WebWindowWatcher *_windowWatcher = nil;
- (id)initWithWebCoreHistoryItem:(PassRefPtr<HistoryItem>)item
{
ASSERT_MAIN_THREAD();
WebCoreThreadViolationCheck();
// Need to tell WebCore what function to call for the
// "History Item has Changed" notification - no harm in doing this
// everytime a WebHistoryItem is created
......
......@@ -37,6 +37,8 @@
#import <WebCore/IconDatabase.h>
#import <WebCore/Image.h>
#import <WebCore/IntSize.h>
#import <WebCore/ThreadCheck.h>
using namespace WebCore;
......@@ -85,7 +87,8 @@ NSSize WebIconLargeSize = {128, 128};
- init
{
[super init];
WebCoreThreadViolationCheck();
_private = [[WebIconDatabasePrivate alloc] init];
// Check the user defaults and see if the icon database should even be enabled.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment