Title: [158448] trunk/Source/WebKit2
Revision
158448
Author
ander...@apple.com
Date
2013-11-01 12:35:39 -0700 (Fri, 01 Nov 2013)

Log Message

Don't use the C API in WKRemoteObjectCoder
https://bugs.webkit.org/show_bug.cgi?id=123627

Reviewed by Dan Bernstein.

* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(-[WKRemoteObjectEncoder init]):
(-[WKRemoteObjectEncoder encodeBytes:length:forKey:]):
(-[WKRemoteObjectEncoder _encodeObjectForKey:usingBlock:]):
* Shared/ImmutableDictionary.h:
* Shared/MutableDictionary.cpp:
(WebKit::MutableDictionary::add):
(WebKit::MutableDictionary::set):
* Shared/MutableDictionary.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (158447 => 158448)


--- trunk/Source/WebKit2/ChangeLog	2013-11-01 19:18:27 UTC (rev 158447)
+++ trunk/Source/WebKit2/ChangeLog	2013-11-01 19:35:39 UTC (rev 158448)
@@ -1,3 +1,20 @@
+2013-11-01  Anders Carlsson  <ander...@apple.com>
+
+        Don't use the C API in WKRemoteObjectCoder
+        https://bugs.webkit.org/show_bug.cgi?id=123627
+
+        Reviewed by Dan Bernstein.
+
+        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+        (-[WKRemoteObjectEncoder init]):
+        (-[WKRemoteObjectEncoder encodeBytes:length:forKey:]):
+        (-[WKRemoteObjectEncoder _encodeObjectForKey:usingBlock:]):
+        * Shared/ImmutableDictionary.h:
+        * Shared/MutableDictionary.cpp:
+        (WebKit::MutableDictionary::add):
+        (WebKit::MutableDictionary::set):
+        * Shared/MutableDictionary.h:
+
 2013-11-01  Emilio Pozuelo Monfort  <poch...@gmail.com>
 
         Fix build on non-linux platforms

Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm (158447 => 158448)


--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm	2013-11-01 19:18:27 UTC (rev 158447)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm	2013-11-01 19:35:39 UTC (rev 158448)
@@ -26,21 +26,21 @@
 #import "config.h"
 #import "WKRemoteObjectCoder.h"
 
-#import "WKData.h"
-#import "WKMutableDictionary.h"
-#import "WKNumber.h"
-#import "WKRetainPtr.h"
-#import "WKStringCF.h"
+#import "MutableDictionary.h"
+#import "WebData.h"
+#import <wtf/TemporaryChange.h>
 
 #if WK_API_ENABLED
 
+using namespace WebKit;
+
 @interface NSMethodSignature (Details)
 - (NSString *)_typeString;
 @end
 
 @implementation WKRemoteObjectEncoder {
-    WKRetainPtr<WKMutableDictionaryRef> _rootDictionary;
-    WKMutableDictionaryRef _currentDictionary;
+    RefPtr<MutableDictionary> _rootDictionary;
+    MutableDictionary* _currentDictionary;
 }
 
 - (id)init
@@ -48,7 +48,7 @@
     if (!(self = [super init]))
         return nil;
 
-    _rootDictionary = adoptWK(WKMutableDictionaryCreate());
+    _rootDictionary = MutableDictionary::create();
     _currentDictionary = _rootDictionary.get();
 
     return self;
@@ -97,22 +97,16 @@
 
 - (void)encodeBytes:(const uint8_t *)bytes length:(NSUInteger)length forKey:(NSString *)key
 {
-    auto data = "" length));
-    auto keyString = adoptWK(WKStringCreateWithCFString((CFStringRef)key));
-
-    WKDictionarySetItem(_currentDictionary, keyString.get(), data.get());
+    _currentDictionary->set(key, WebData::create(bytes, length));
 }
 
 - (void)_encodeObjectForKey:(NSString *)key usingBlock:(void (^)())block
 {
-    auto dictionary = adoptWK(WKMutableDictionaryCreate());
-    auto keyString = adoptWK(WKStringCreateWithCFString((CFStringRef)key));
+    RefPtr<MutableDictionary> dictionary = MutableDictionary::create();
+    TemporaryChange<MutableDictionary*> dictionaryChange(_currentDictionary, dictionary.get());
 
-    WKDictionarySetItem(_currentDictionary, keyString.get(), dictionary.get());
-
-    WKMutableDictionaryRef previousDictionary = _currentDictionary;
+    dictionary->set(key, dictionary.release());
     block();
-    _currentDictionary = previousDictionary;
 }
 
 @end

Modified: trunk/Source/WebKit2/Shared/ImmutableDictionary.h (158447 => 158448)


--- trunk/Source/WebKit2/Shared/ImmutableDictionary.h	2013-11-01 19:18:27 UTC (rev 158447)
+++ trunk/Source/WebKit2/Shared/ImmutableDictionary.h	2013-11-01 19:35:39 UTC (rev 158448)
@@ -81,7 +81,7 @@
 
 protected:
     ImmutableDictionary();
-    ImmutableDictionary(MapType& map);
+    explicit ImmutableDictionary(MapType&);
 
     MapType m_map;
 };

Modified: trunk/Source/WebKit2/Shared/MutableDictionary.cpp (158447 => 158448)


--- trunk/Source/WebKit2/Shared/MutableDictionary.cpp	2013-11-01 19:18:27 UTC (rev 158447)
+++ trunk/Source/WebKit2/Shared/MutableDictionary.cpp	2013-11-01 19:35:39 UTC (rev 158448)
@@ -36,13 +36,13 @@
 {
 }
 
-bool MutableDictionary::add(const String& key, APIObject* item)
+bool MutableDictionary::add(const String& key, PassRefPtr<APIObject> item)
 {
     MapType::AddResult result = m_map.add(key, item);
     return result.isNewEntry;
 }
 
-bool MutableDictionary::set(const String& key, APIObject* item)
+bool MutableDictionary::set(const String& key, PassRefPtr<APIObject> item)
 {
     MapType::AddResult result = m_map.set(key, item);
     return result.isNewEntry;

Modified: trunk/Source/WebKit2/Shared/MutableDictionary.h (158447 => 158448)


--- trunk/Source/WebKit2/Shared/MutableDictionary.h	2013-11-01 19:18:27 UTC (rev 158447)
+++ trunk/Source/WebKit2/Shared/MutableDictionary.h	2013-11-01 19:35:39 UTC (rev 158448)
@@ -41,8 +41,8 @@
 
     ~MutableDictionary();
 
-    bool add(const String& key, APIObject*);
-    bool set(const String& key, APIObject*);
+    bool add(const String& key, PassRefPtr<APIObject>);
+    bool set(const String& key, PassRefPtr<APIObject>);
     void remove(const String& key);
 
     virtual bool isMutable() { return true; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to