Title: [112302] trunk/Source/WebCore
Revision
112302
Author
[email protected]
Date
2012-03-27 12:32:36 -0700 (Tue, 27 Mar 2012)

Log Message

        [Mac] Stop using NSMapTable in FormDataStreamMac.mm
        https://bugs.webkit.org/show_bug.cgi?id=82358

        Reviewed by Darin Adler.

        * platform/network/mac/FormDataStreamMac.mm: Use WTF::HashMap, as we always do. All accesses
        are protected with a mutex anyway.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (112301 => 112302)


--- trunk/Source/WebCore/ChangeLog	2012-03-27 19:19:59 UTC (rev 112301)
+++ trunk/Source/WebCore/ChangeLog	2012-03-27 19:32:36 UTC (rev 112302)
@@ -1,3 +1,13 @@
+2012-03-27  Alexey Proskuryakov  <[email protected]>
+
+        [Mac] Stop using NSMapTable in FormDataStreamMac.mm
+        https://bugs.webkit.org/show_bug.cgi?id=82358
+
+        Reviewed by Darin Adler.
+
+        * platform/network/mac/FormDataStreamMac.mm: Use WTF::HashMap, as we always do. All accesses
+        are protected with a mutex anyway.
+
 2012-03-27  Joe Thomas  <[email protected]>
 
         Implement vw/vh/vmin (viewport sizes) from CSS3 Values and Units

Modified: trunk/Source/WebCore/platform/network/mac/FormDataStreamMac.mm (112301 => 112302)


--- trunk/Source/WebCore/platform/network/mac/FormDataStreamMac.mm	2012-03-27 19:19:59 UTC (rev 112301)
+++ trunk/Source/WebCore/platform/network/mac/FormDataStreamMac.mm	2012-03-27 19:32:36 UTC (rev 112302)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2008, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2008, 2011, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -57,12 +57,6 @@
     return staticMutex;
 }
 
-static NSMapTable *streamFieldsMap()
-{
-    static NSMapTable *streamFieldsMap = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 1);
-    return streamFieldsMap;
-}
-
 static void formEventCallback(CFReadStreamRef stream, CFStreamEventType type, void* context);
 
 struct FormContext {
@@ -84,6 +78,13 @@
     unsigned long long bytesSent;
 };
 
+typedef HashMap<CFReadStreamRef, FormStreamFields*> StreamFieldsMap;
+static StreamFieldsMap& streamFieldsMap()
+{
+    DEFINE_STATIC_LOCAL(StreamFieldsMap, streamFieldsMap, ());
+    return streamFieldsMap;
+}
+
 static void closeCurrentStream(FormStreamFields *form)
 {
     if (form->currentStream) {
@@ -189,8 +190,8 @@
         newInfo->remainingElements.append(newInfo->formData->elements()[size - i - 1]);
 
     MutexLocker locker(streamFieldsMapMutex());
-    ASSERT(!NSMapGet(streamFieldsMap(), stream));
-    NSMapInsertKnownAbsent(streamFieldsMap(), stream, newInfo);
+    ASSERT(!streamFieldsMap().contains(stream));
+    streamFieldsMap().add(stream, newInfo);
 
     return newInfo;
 }
@@ -209,13 +210,13 @@
     MutexLocker locker(streamFieldsMapMutex());
 
     ASSERT(form->formStream == stream);
-    ASSERT(NSMapGet(streamFieldsMap(), stream) == context);
+    ASSERT(streamFieldsMap().get(stream) == context);
 
     // Do this right away because the CFReadStreamRef is being deallocated.
     // We can't wait to remove this from the map until we finish finalizing
     // on the main thread because in theory the freed memory could be reused
     // for a new CFReadStream before that runs.
-    NSMapRemove(streamFieldsMap(), stream);
+    streamFieldsMap().remove(stream);
 
     callOnMainThread(formFinishFinalizationOnMainThread, form);
 }
@@ -435,7 +436,7 @@
 FormData* httpBodyFromStream(NSInputStream* stream)
 {
     MutexLocker locker(streamFieldsMapMutex());
-    FormStreamFields* formStream = static_cast<FormStreamFields*>(NSMapGet(streamFieldsMap(), stream));
+    FormStreamFields* formStream = streamFieldsMap().get(reinterpret_cast<CFReadStreamRef>(stream));
     if (!formStream)
         return 0;
     return formStream->formData.get();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to