Stop using dispatch_set_target_queue()
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 19:06:35 +0000 (19:06 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 19:06:35 +0000 (19:06 +0000)
<https://webkit.org/b/183908>
<rdar://problem/33553533>

Reviewed by Daniel Bates.

Source/ThirdParty/libwebrtc:

* Source/webrtc/rtc_base/task_queue_gcd.cc: Remove use of
dispatch_set_target_queue() by changing dispatch_queue_create()
to dispatch_queue_create_with_target().
* WebKit/0009-Remove-dispatch_set_target_queue.patch: Add patch.
Filed this to track upstreaming the change:
<https://bugs.chromium.org/p/webrtc/issues/detail?id=9055>
* WebKit/patch-libwebrtc: Delete empty patch file.

Source/WebCore:

No new tests since no change in behavior.

* platform/mediastream/mac/AVMediaCaptureSource.mm:
(WebCore::globaVideoCaptureSerialQueue): Remove use of
dispatch_set_target_queue() by changing dispatch_queue_create()
to dispatch_queue_create_with_target().

Source/WebKit:

* NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:
(WebKit::NetworkCache::IOChannel::IOChannel): Remove the call to
dispatch_set_target_queue() since this is handled in the
dispatch_io_create() call above.

Source/WTF:

* wtf/cocoa/WorkQueueCocoa.cpp:
(WTF::WorkQueue::platformInitialize): Remove !HAVE(QOS_CLASSES)
code path since it's never used now that HAVE(QOS_CLASSES) is
equivalent to PLATFORM(COCOA) in <wtf/Platform.h>.

Tools:

* Scripts/webkitpy/style/checkers/cpp.py:
(check_language): Add check for use of
dispatch_set_target_queue().
(CppChecker): Add 'runtime/dispatch_set_target_queue' category.
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(CppStyleTest): Add test.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229913 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/Source/webrtc/rtc_base/task_queue_gcd.cc
Source/ThirdParty/libwebrtc/WebKit/0009-Remove-dispatch_set_target_queue.patch [new file with mode: 0644]
Source/ThirdParty/libwebrtc/WebKit/patch-libwebrtc [deleted file]
Source/WTF/ChangeLog
Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp
Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm
Tools/ChangeLog
Tools/Scripts/webkitpy/style/checkers/cpp.py
Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

index 7d88b16d0346a0ecbd11d11d0d36e358952b1d49..836c9e797f6c64c73bdff7dfaa4310e9517d501d 100644 (file)
@@ -1,3 +1,19 @@
+2018-03-23  David Kilzer  <ddkilzer@apple.com>
+
+        Stop using dispatch_set_target_queue()
+        <https://webkit.org/b/183908>
+        <rdar://problem/33553533>
+
+        Reviewed by Daniel Bates.
+
+        * Source/webrtc/rtc_base/task_queue_gcd.cc: Remove use of
+        dispatch_set_target_queue() by changing dispatch_queue_create()
+        to dispatch_queue_create_with_target().
+        * WebKit/0009-Remove-dispatch_set_target_queue.patch: Add patch.
+        Filed this to track upstreaming the change:
+        <https://bugs.chromium.org/p/webrtc/issues/detail?id=9055>
+        * WebKit/patch-libwebrtc: Delete empty patch file.
+
 2018-03-23  Youenn Fablet  <youenn@apple.com>
 
         Use libwebrtc ObjectiveC H264 encoder and decoder
index a13e088ede60bd91d6649121bfa134634c4af48d..675b8005722f3d6072703178316498dd9cd218ce 100644 (file)
@@ -139,7 +139,7 @@ class TaskQueue::Impl : public RefCountInterface {
 TaskQueue::Impl::Impl(const char* queue_name,
                       TaskQueue* task_queue,
                       Priority priority)
-    : queue_(dispatch_queue_create(queue_name, DISPATCH_QUEUE_SERIAL)),
+    : queue_(dispatch_queue_create_with_target(queue_name, DISPATCH_QUEUE_SERIAL, dispatch_get_global_queue(TaskQueuePriorityToGCD(priority), 0))),
       context_(new QueueContext(task_queue)) {
   RTC_DCHECK(queue_name);
   RTC_CHECK(queue_);
@@ -148,9 +148,6 @@ TaskQueue::Impl::Impl(const char* queue_name,
   // to the queue is released.  This may run after the TaskQueue object has
   // been deleted.
   dispatch_set_finalizer_f(queue_, &QueueContext::DeleteContext);
-
-  dispatch_set_target_queue(
-      queue_, dispatch_get_global_queue(TaskQueuePriorityToGCD(priority), 0));
 }
 
 TaskQueue::Impl::~Impl() {
diff --git a/Source/ThirdParty/libwebrtc/WebKit/0009-Remove-dispatch_set_target_queue.patch b/Source/ThirdParty/libwebrtc/WebKit/0009-Remove-dispatch_set_target_queue.patch
new file mode 100644 (file)
index 0000000..c614069
--- /dev/null
@@ -0,0 +1,23 @@
+diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/rtc_base/task_queue_gcd.cc b/Source/ThirdParty/libwebrtc/Source/webrtc/rtc_base/task_queue_gcd.cc
+index a13e088ede6..675b8005722 100644
+--- a/Source/ThirdParty/libwebrtc/Source/webrtc/rtc_base/task_queue_gcd.cc
++++ b/Source/ThirdParty/libwebrtc/Source/webrtc/rtc_base/task_queue_gcd.cc
+@@ -139,7 +139,7 @@ class TaskQueue::Impl : public RefCountInterface {
+ TaskQueue::Impl::Impl(const char* queue_name,
+                       TaskQueue* task_queue,
+                       Priority priority)
+-    : queue_(dispatch_queue_create(queue_name, DISPATCH_QUEUE_SERIAL)),
++    : queue_(dispatch_queue_create_with_target(queue_name, DISPATCH_QUEUE_SERIAL, dispatch_get_global_queue(TaskQueuePriorityToGCD(priority), 0))),
+       context_(new QueueContext(task_queue)) {
+   RTC_DCHECK(queue_name);
+   RTC_CHECK(queue_);
+@@ -148,9 +148,6 @@ TaskQueue::Impl::Impl(const char* queue_name,
+   // to the queue is released.  This may run after the TaskQueue object has
+   // been deleted.
+   dispatch_set_finalizer_f(queue_, &QueueContext::DeleteContext);
+-
+-  dispatch_set_target_queue(
+-      queue_, dispatch_get_global_queue(TaskQueuePriorityToGCD(priority), 0));
+ }
+ TaskQueue::Impl::~Impl() {
diff --git a/Source/ThirdParty/libwebrtc/WebKit/patch-libwebrtc b/Source/ThirdParty/libwebrtc/WebKit/patch-libwebrtc
deleted file mode 100644 (file)
index e69de29..0000000
index 87a97a2551c70760556a91a11dfc98786fabc7f8..148978b99352aef5d6bad796e9d97591200fbd62 100644 (file)
@@ -1,3 +1,16 @@
+2018-03-23  David Kilzer  <ddkilzer@apple.com>
+
+        Stop using dispatch_set_target_queue()
+        <https://webkit.org/b/183908>
+        <rdar://problem/33553533>
+
+        Reviewed by Daniel Bates.
+
+        * wtf/cocoa/WorkQueueCocoa.cpp:
+        (WTF::WorkQueue::platformInitialize): Remove !HAVE(QOS_CLASSES)
+        code path since it's never used now that HAVE(QOS_CLASSES) is
+        equivalent to PLATFORM(COCOA) in <wtf/Platform.h>.
+
 2018-03-23  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         WebProcess memory monitor thresholds should be better tuned for embedded systems.
index f1589f6ef1d7a52dce8530c493006459c9705927..521a1d816fb6b748ecad94bc202c1cd50cef6429 100644 (file)
@@ -82,16 +82,8 @@ static dispatch_queue_t targetQueueForQOSClass(WorkQueue::QOS qos)
 void WorkQueue::platformInitialize(const char* name, Type type, QOS qos)
 {
     dispatch_queue_attr_t attr = type == Type::Concurrent ? DISPATCH_QUEUE_CONCURRENT : DISPATCH_QUEUE_SERIAL;
-#if HAVE(QOS_CLASSES)
     attr = dispatch_queue_attr_make_with_qos_class(attr, dispatchQOSClass(qos), 0);
-#else
-    UNUSED_PARAM(qos);
-#endif
     m_dispatchQueue = dispatch_queue_create(name, attr);
-#if !HAVE(QOS_CLASSES)
-    if (qos != WorkQueue::QOS::Default)
-        dispatch_set_target_queue(m_dispatchQueue, targetQueueForQOSClass(qos));
-#endif
     dispatch_set_context(m_dispatchQueue, this);
 }
 
index 36973481708fe58b341766689b37ffbf9126d593..00fb17a49ceafe04282504b20d1436770e1dadf9 100644 (file)
@@ -1,3 +1,18 @@
+2018-03-23  David Kilzer  <ddkilzer@apple.com>
+
+        Stop using dispatch_set_target_queue()
+        <https://webkit.org/b/183908>
+        <rdar://problem/33553533>
+
+        Reviewed by Daniel Bates.
+
+        No new tests since no change in behavior.
+
+        * platform/mediastream/mac/AVMediaCaptureSource.mm:
+        (WebCore::globaVideoCaptureSerialQueue): Remove use of
+        dispatch_set_target_queue() by changing dispatch_queue_create()
+        to dispatch_queue_create_with_target().
+
 2018-03-23  Youenn Fablet  <youenn@apple.com>
 
         Use libwebrtc ObjectiveC H264 encoder and decoder
index e61953f4c315706cbaee22f7703f6d4dcc0a8067..afec3968a9f49e53f2fb25936585dc44161f1a12 100644 (file)
@@ -130,8 +130,7 @@ static dispatch_queue_t globaVideoCaptureSerialQueue()
     static dispatch_queue_t globalQueue;
     static dispatch_once_t onceToken;
     dispatch_once(&onceToken, ^{
-        globalQueue = dispatch_queue_create("WebCoreAVMediaCaptureSource video capture queue", DISPATCH_QUEUE_SERIAL);
-        dispatch_set_target_queue(globalQueue, dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0));
+        globalQueue = dispatch_queue_create_with_target("WebCoreAVMediaCaptureSource video capture queue", DISPATCH_QUEUE_SERIAL, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));
     });
     return globalQueue;
 }
index c6552caa2880355c07b644ba3e224c9a0348ba26..c3cb7daa62478d024f9ef372460473fafab608eb 100644 (file)
@@ -1,3 +1,16 @@
+2018-03-23  David Kilzer  <ddkilzer@apple.com>
+
+        Stop using dispatch_set_target_queue()
+        <https://webkit.org/b/183908>
+        <rdar://problem/33553533>
+
+        Reviewed by Daniel Bates.
+
+        * NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:
+        (WebKit::NetworkCache::IOChannel::IOChannel): Remove the call to
+        dispatch_set_target_queue() since this is handled in the
+        dispatch_io_create() call above.
+
 2018-03-23  Youenn Fablet  <youenn@apple.com>
 
         CacheStorage::Engine should not ref itself when hopping to a background thread
index 9dcd69b2eed31fc114f711ad4ec3f14b15522c42..b062667ea2903187b260ee256f6294063786aed0 100644 (file)
@@ -74,11 +74,6 @@ IOChannel::IOChannel(const String& filePath, Type type)
 
     // This makes the channel read/write all data before invoking the handlers.
     dispatch_io_set_low_water(m_dispatchIO.get(), std::numeric_limits<size_t>::max());
-
-    if (useLowIOPriority) {
-        // The target queue of a dispatch I/O channel specifies the priority of the global queue where its I/O operations are executed.
-        dispatch_set_target_queue(m_dispatchIO.get(), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0));
-    }
 }
 
 IOChannel::~IOChannel()
index f0c9db4b0fcb4138f6d417858bae453b124f81e4..992132009a9beb3007c336a254d9aac2bc1c2a35 100644 (file)
@@ -1,3 +1,18 @@
+2018-03-23  David Kilzer  <ddkilzer@apple.com>
+
+        Stop using dispatch_set_target_queue()
+        <https://webkit.org/b/183908>
+        <rdar://problem/33553533>
+
+        Reviewed by Daniel Bates.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_language): Add check for use of
+        dispatch_set_target_queue().
+        (CppChecker): Add 'runtime/dispatch_set_target_queue' category.
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (CppStyleTest): Add test.
+
 2018-03-23  Youenn Fablet  <youenn@apple.com>
 
         Allow fully whitelisted plug-ins to match non HTTP URLs
index eb83c05e8ff2a0691aacae7d4d4f07454f675f64..39b08cad462cc503f9c9b84c3221c9b90e567dbf 100644 (file)
@@ -3224,6 +3224,10 @@ def check_language(filename, clean_lines, line_number, file_extension, include_s
         error(line_number, 'security/temp_file', 5,
               'Never use mktemp.  Use mkstemp or mkostemp instead.')
 
+    if search(r'\bdispatch_set_target_queue\b', line):
+        error(line_number, 'runtime/dispatch_set_target_queue', 5,
+              'Never use dispatch_set_target_queue.  Use dispatch_queue_create_with_target instead.')
+
     # Check for suspicious usage of "if" like
     # } if (a == b) {
     if search(r'\}\s*if\s*\(', line):
@@ -3941,6 +3945,7 @@ class CppChecker(object):
         'runtime/bitfields',
         'runtime/casting',
         'runtime/ctype_function',
+        'runtime/dispatch_set_target_queue',
         'runtime/enum_bitfields',
         'runtime/explicit',
         'runtime/init',
index cd4ad8e6f797e35b0da2de33a56b064ffd27c793..782dd7e3fb32a0c1ee54c982f47c4b5a289354ca 100644 (file)
@@ -1588,6 +1588,15 @@ class CppStyleTest(CppStyleTestBase):
         self.assert_lint('mkstemp(template);', '')
         self.assert_lint('mkostemp(template);', '')
 
+    def test_dispatch_set_target_queue(self):
+        self.assert_lint(
+            '''\
+            globalQueue = dispatch_queue_create("My Serial Queue", DISPATCH_QUEUE_SERIAL);
+            dispatch_set_target_queue(globalQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));''',
+            'Never use dispatch_set_target_queue.  Use dispatch_queue_create_with_target instead.'
+            '  [runtime/dispatch_set_target_queue] [5]')
+        self.assert_lint('globalQueue = dispatch_queue_create_with_target("My Serial Queue", DISPATCH_QUEUE_SERIAL, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));', '')
+
     # Variable-length arrays are not permitted.
     def test_variable_length_array_detection(self):
         errmsg = ('Do not use variable-length arrays.  Use an appropriately named '