summaryrefslogtreecommitdiffstats
path: root/content/utility
diff options
context:
space:
mode:
authorssid <ssid@chromium.org>2015-05-12 11:10:07 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-12 18:10:29 +0000
commit90e34895f20edf97693c14ac0ec6faf64dbdcd91 (patch)
tree16a2065fd78b9645d09935bd9523dde1821b6e05 /content/utility
parent57439937b14ad4362ab4dde3f828b7017f4aad8d (diff)
downloadchromium_src-90e34895f20edf97693c14ac0ec6faf64dbdcd91.zip
chromium_src-90e34895f20edf97693c14ac0ec6faf64dbdcd91.tar.gz
chromium_src-90e34895f20edf97693c14ac0ec6faf64dbdcd91.tar.bz2
Adding WebThread and new BlinkPlatformImpl for utility thread.
For ensuring that the blink is always initialized with WebThread, the call sites of blink must implement WebThread to expose the task runner. UtilityThread is the only case where blink is run without exposing the platform thread. This CL adds new WebThread implementation for UtilityThread. After this change blink will always initialized with platform thread and task runner exposed. BUG=486782 Review URL: https://codereview.chromium.org/1133563007 Cr-Commit-Position: refs/heads/master@{#329442}
Diffstat (limited to 'content/utility')
-rw-r--r--content/utility/BUILD.gn4
-rw-r--r--content/utility/DEPS1
-rw-r--r--content/utility/utility_blink_platform_impl.cc24
-rw-r--r--content/utility/utility_blink_platform_impl.h30
-rw-r--r--content/utility/utility_thread_impl.cc3
-rw-r--r--content/utility/utility_thread_impl.h3
-rw-r--r--content/utility/webthread_impl_for_utility_thread.cc37
-rw-r--r--content/utility/webthread_impl_for_utility_thread.h35
8 files changed, 135 insertions, 2 deletions
diff --git a/content/utility/BUILD.gn b/content/utility/BUILD.gn
index b045978..d98d639 100644
--- a/content/utility/BUILD.gn
+++ b/content/utility/BUILD.gn
@@ -10,9 +10,13 @@ source_set("utility") {
sources = [
"in_process_utility_thread.cc",
"in_process_utility_thread.h",
+ "utility_blink_platform_impl.cc",
+ "utility_blink_platform_impl.h",
"utility_main.cc",
"utility_thread_impl.cc",
"utility_thread_impl.h",
+ "webthread_impl_for_utility_thread.cc",
+ "webthread_impl_for_utility_thread.h",
]
configs += [ "//content:content_implementation" ]
diff --git a/content/utility/DEPS b/content/utility/DEPS
index 0818b2c..47166e2 100644
--- a/content/utility/DEPS
+++ b/content/utility/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "+components/scheduler/child",
"+content/child",
"+content/public/utility",
"+sandbox/win/src",
diff --git a/content/utility/utility_blink_platform_impl.cc b/content/utility/utility_blink_platform_impl.cc
new file mode 100644
index 0000000..b3b73bc
--- /dev/null
+++ b/content/utility/utility_blink_platform_impl.cc
@@ -0,0 +1,24 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/utility/utility_blink_platform_impl.h"
+
+#include "content/utility/webthread_impl_for_utility_thread.h"
+
+namespace content {
+
+UtilityBlinkPlatformImpl::UtilityBlinkPlatformImpl()
+ : main_thread_(new WebThreadImplForUtilityThread()) {
+}
+
+UtilityBlinkPlatformImpl::~UtilityBlinkPlatformImpl() {
+}
+
+blink::WebThread* UtilityBlinkPlatformImpl::currentThread() {
+ if (main_thread_->isCurrentThread())
+ return main_thread_.get();
+ return BlinkPlatformImpl::currentThread();
+}
+
+} // namespace content
diff --git a/content/utility/utility_blink_platform_impl.h b/content/utility/utility_blink_platform_impl.h
new file mode 100644
index 0000000..2d2b824
--- /dev/null
+++ b/content/utility/utility_blink_platform_impl.h
@@ -0,0 +1,30 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_UTILITY_UTILITY_BLINK_PLATFORM_IMPL_H_
+#define CONTENT_UTILITY_UTILITY_BLINK_PLATFORM_IMPL_H_
+
+#include "content/child/blink_platform_impl.h"
+
+namespace content {
+
+class WebThreadImplForUtilityThread;
+
+class UtilityBlinkPlatformImpl : public BlinkPlatformImpl {
+ public:
+ UtilityBlinkPlatformImpl();
+ ~UtilityBlinkPlatformImpl() override;
+
+ // BlinkPlatformImpl implementation.
+ blink::WebThread* currentThread() override;
+
+ private:
+ scoped_ptr<WebThreadImplForUtilityThread> main_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(UtilityBlinkPlatformImpl);
+};
+
+} // namespace content
+
+#endif // CONTENT_UTILITY_UTILITY_BLINK_PLATFORM_IMPL_H_
diff --git a/content/utility/utility_thread_impl.cc b/content/utility/utility_thread_impl.cc
index 7ea1a1d..1a020ea 100644
--- a/content/utility/utility_thread_impl.cc
+++ b/content/utility/utility_thread_impl.cc
@@ -14,6 +14,7 @@
#include "content/common/utility_messages.h"
#include "content/public/common/content_switches.h"
#include "content/public/utility/content_utility_client.h"
+#include "content/utility/utility_blink_platform_impl.h"
#include "ipc/ipc_sync_channel.h"
#include "third_party/WebKit/public/web/WebKit.h"
@@ -80,7 +81,7 @@ void UtilityThreadImpl::Init() {
// we run the utility thread on separate thread. This means that if any code
// needs WebKit initialized in the utility process, they need to have
// another path to support single process mode.
- blink_platform_impl_.reset(new BlinkPlatformImpl);
+ blink_platform_impl_.reset(new UtilityBlinkPlatformImpl);
blink::initialize(blink_platform_impl_.get());
}
GetContentClient()->utility()->UtilityThreadStarted();
diff --git a/content/utility/utility_thread_impl.h b/content/utility/utility_thread_impl.h
index 4f0fa3f..3b1d66d 100644
--- a/content/utility/utility_thread_impl.h
+++ b/content/utility/utility_thread_impl.h
@@ -20,6 +20,7 @@ class FilePath;
namespace content {
class BlinkPlatformImpl;
+class UtilityBlinkPlatformImpl;
#if defined(COMPILER_MSVC)
// See explanation for other RenderViewHostImpl which is the same issue.
@@ -56,7 +57,7 @@ class UtilityThreadImpl : public UtilityThread,
// True when we're running in batch mode.
bool batch_mode_;
- scoped_ptr<BlinkPlatformImpl> blink_platform_impl_;
+ scoped_ptr<UtilityBlinkPlatformImpl> blink_platform_impl_;
DISALLOW_COPY_AND_ASSIGN(UtilityThreadImpl);
};
diff --git a/content/utility/webthread_impl_for_utility_thread.cc b/content/utility/webthread_impl_for_utility_thread.cc
new file mode 100644
index 0000000..12c4caa
--- /dev/null
+++ b/content/utility/webthread_impl_for_utility_thread.cc
@@ -0,0 +1,37 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/utility/webthread_impl_for_utility_thread.h"
+
+namespace content {
+
+WebThreadImplForUtilityThread::WebThreadImplForUtilityThread()
+ : task_runner_(base::MessageLoopProxy::current()),
+ thread_id_(base::PlatformThread::CurrentId()) {
+}
+
+WebThreadImplForUtilityThread::~WebThreadImplForUtilityThread() {
+}
+
+blink::WebScheduler* WebThreadImplForUtilityThread::scheduler() const {
+ NOTIMPLEMENTED();
+ return nullptr;
+}
+
+blink::PlatformThreadId WebThreadImplForUtilityThread::threadId() const {
+ return thread_id_;
+}
+
+base::SingleThreadTaskRunner* WebThreadImplForUtilityThread::TaskRunner()
+ const {
+ return task_runner_.get();
+}
+
+scheduler::SingleThreadIdleTaskRunner*
+WebThreadImplForUtilityThread::IdleTaskRunner() const {
+ NOTIMPLEMENTED();
+ return nullptr;
+}
+
+} // namespace content
diff --git a/content/utility/webthread_impl_for_utility_thread.h b/content/utility/webthread_impl_for_utility_thread.h
new file mode 100644
index 0000000..15d7e57
--- /dev/null
+++ b/content/utility/webthread_impl_for_utility_thread.h
@@ -0,0 +1,35 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_UTILITY_WEBTHREAD_IMPL_FOR_UTILITY_THREAD_H_
+#define CONTENT_UTILITY_WEBTHREAD_IMPL_FOR_UTILITY_THREAD_H_
+
+#include "base/memory/ref_counted.h"
+#include "components/scheduler/child/webthread_base.h"
+
+namespace content {
+
+class WebThreadImplForUtilityThread : public scheduler::WebThreadBase {
+ public:
+ WebThreadImplForUtilityThread();
+ ~WebThreadImplForUtilityThread() override;
+
+ // blink::WebThread implementation.
+ blink::WebScheduler* scheduler() const override;
+ blink::PlatformThreadId threadId() const override;
+
+ // WebThreadBase implementation.
+ base::SingleThreadTaskRunner* TaskRunner() const override;
+ scheduler::SingleThreadIdleTaskRunner* IdleTaskRunner() const override;
+
+ private:
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ blink::PlatformThreadId thread_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebThreadImplForUtilityThread);
+};
+
+} // namespace content
+
+#endif // CONTENT_UTILITY_WEBTHREAD_IMPL_FOR_UTILITY_THREAD_H_