Commit 06f34ffd authored by Robert Liao's avatar Robert Liao Committed by Commit Bot

Disable COM Initialization on SchedulerWorkers When COM_INIT_CHECK_HOOK_ENABLED()

This change will allow for the detection of tasks running in
TaskScheduler that fail to post their task in a COM STA Task Runner
instead.

BUG=706512

Change-Id: If8ea9df63cface0dc48aa11b5254ab3e6d87dc4f
Reviewed-on: https://chromium-review.googlesource.com/549223
Commit-Queue: Robert Liao <robliao@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487269}
parent 6b8278e1
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h" #include "base/mac/scoped_nsautorelease_pool.h"
#elif defined(OS_WIN) #elif defined(OS_WIN)
#include "base/win/com_init_check_hook.h"
#include "base/win/scoped_com_initializer.h" #include "base/win/scoped_com_initializer.h"
#endif #endif
...@@ -43,7 +44,10 @@ class SchedulerWorker::Thread : public PlatformThread::Delegate { ...@@ -43,7 +44,10 @@ class SchedulerWorker::Thread : public PlatformThread::Delegate {
// A SchedulerWorker starts out waiting for work. // A SchedulerWorker starts out waiting for work.
outer_->delegate_->WaitForWork(&wake_up_event_); outer_->delegate_->WaitForWork(&wake_up_event_);
#if defined(OS_WIN) // When defined(COM_INIT_CHECK_HOOK_ENABLED), ignore
// SchedulerBackwardCompatibility::INIT_COM_STA to find incorrect uses of
// COM that should be running in a COM STA Task Runner.
#if defined(OS_WIN) && !defined(COM_INIT_CHECK_HOOK_ENABLED)
std::unique_ptr<win::ScopedCOMInitializer> com_initializer; std::unique_ptr<win::ScopedCOMInitializer> com_initializer;
if (outer_->backward_compatibility_ == if (outer_->backward_compatibility_ ==
SchedulerBackwardCompatibility::INIT_COM_STA) { SchedulerBackwardCompatibility::INIT_COM_STA) {
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include <objbase.h> #include <objbase.h>
#include "base/win/com_init_check_hook.h"
#endif #endif
using testing::_; using testing::_;
...@@ -931,7 +933,13 @@ TEST(TaskSchedulerWorkerTest, BackwardCompatibilityEnabled) { ...@@ -931,7 +933,13 @@ TEST(TaskSchedulerWorkerTest, BackwardCompatibilityEnabled) {
// The call to CoInitializeEx() should have returned S_FALSE to indicate that // The call to CoInitializeEx() should have returned S_FALSE to indicate that
// the COM library was already initialized on the thread. // the COM library was already initialized on the thread.
// See SchedulerWorker::Thread::ThreadMain for why we expect two different
// results here.
#if defined(COM_INIT_CHECK_HOOK_ENABLED)
EXPECT_EQ(S_OK, delegate_raw->coinitialize_hresult());
#else
EXPECT_EQ(S_FALSE, delegate_raw->coinitialize_hresult()); EXPECT_EQ(S_FALSE, delegate_raw->coinitialize_hresult());
#endif
worker->JoinForTesting(); worker->JoinForTesting();
} }
......
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