summaryrefslogtreecommitdiffstats
path: root/content/utility
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-14 23:29:48 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-14 23:29:48 +0000
commitac381f190519f153566503e5cba87e310c1a3f96 (patch)
tree4fa928efb7f8964738e06d2de5b71f33ffcebca4 /content/utility
parent4e3ce3ba829b7b0251948538ff08010c312a8ec0 (diff)
downloadchromium_src-ac381f190519f153566503e5cba87e310c1a3f96.zip
chromium_src-ac381f190519f153566503e5cba87e310c1a3f96.tar.gz
chromium_src-ac381f190519f153566503e5cba87e310c1a3f96.tar.bz2
Create content::UtilityThread interface and make chrome code use that. This interface is implemented
by the UtilityThreadImpl class in content\utility\utility_thread_impl.cc/.h which are renamed incarnations of the content\utility\utility_thread.cc/.h files. Changes as part of creating a content API. BUG=98716 TEST=No change in functionality. Review URL: http://codereview.chromium.org/8276026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/utility')
-rw-r--r--content/utility/utility_main.cc4
-rw-r--r--content/utility/utility_thread_impl.cc (renamed from content/utility/utility_thread.cc)35
-rw-r--r--content/utility/utility_thread_impl.h (renamed from content/utility/utility_thread.h)24
3 files changed, 33 insertions, 30 deletions
diff --git a/content/utility/utility_main.cc b/content/utility/utility_main.cc
index b66cfa9..f97d1d3 100644
--- a/content/utility/utility_main.cc
+++ b/content/utility/utility_main.cc
@@ -10,7 +10,7 @@
#include "content/common/hi_res_timer_manager.h"
#include "content/common/main_function_params.h"
#include "content/public/common/content_switches.h"
-#include "content/utility/utility_thread.h"
+#include "content/utility/utility_thread_impl.h"
#if defined(OS_WIN)
#include "sandbox/src/sandbox.h"
@@ -26,7 +26,7 @@ int UtilityMain(const MainFunctionParams& parameters) {
HighResolutionTimerManager hi_res_timer_manager;
ChildProcess utility_process;
- utility_process.set_main_thread(new UtilityThread());
+ utility_process.set_main_thread(new UtilityThreadImpl());
#if defined(OS_WIN)
bool no_sandbox = parameters.command_line_.HasSwitch(switches::kNoSandbox);
diff --git a/content/utility/utility_thread.cc b/content/utility/utility_thread_impl.cc
index 607ec53..ca1a7e3 100644
--- a/content/utility/utility_thread.cc
+++ b/content/utility/utility_thread_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/utility/utility_thread.h"
+#include "content/utility/utility_thread_impl.h"
#include <stddef.h>
@@ -29,7 +29,7 @@ void ConvertVector(const SRC& src, DEST* dest) {
} // namespace
-UtilityThread::UtilityThread()
+UtilityThreadImpl::UtilityThreadImpl()
: batch_mode_(false) {
ChildProcess::current()->AddRefProcess();
webkit_platform_support_.reset(new webkit_glue::WebKitPlatformSupportImpl);
@@ -37,16 +37,25 @@ UtilityThread::UtilityThread()
content::GetContentClient()->utility()->UtilityThreadStarted();
}
-UtilityThread::~UtilityThread() {
+UtilityThreadImpl::~UtilityThreadImpl() {
WebKit::shutdown();
}
-bool UtilityThread::OnControlMessageReceived(const IPC::Message& msg) {
+bool UtilityThreadImpl::Send(IPC::Message* msg) {
+ return ChildThread::Send(msg);
+}
+
+void UtilityThreadImpl::ReleaseProcessIfNeeded() {
+ if (!batch_mode_)
+ ChildProcess::current()->ReleaseProcess();
+}
+
+bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) {
if (content::GetContentClient()->utility()->OnMessageReceived(msg))
return true;
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(UtilityThread, msg)
+ IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg)
IPC_MESSAGE_HANDLER(UtilityMsg_IDBKeysFromValuesAndKeyPath,
OnIDBKeysFromValuesAndKeyPath)
IPC_MESSAGE_HANDLER(UtilityMsg_InjectIDBKey, OnInjectIDBKey)
@@ -60,7 +69,7 @@ bool UtilityThread::OnControlMessageReceived(const IPC::Message& msg) {
return handled;
}
-void UtilityThread::OnIDBKeysFromValuesAndKeyPath(
+void UtilityThreadImpl::OnIDBKeysFromValuesAndKeyPath(
int id,
const std::vector<SerializedScriptValue>& serialized_script_values,
const string16& idb_key_path) {
@@ -79,7 +88,7 @@ void UtilityThread::OnIDBKeysFromValuesAndKeyPath(
ReleaseProcessIfNeeded();
}
-void UtilityThread::OnInjectIDBKey(const IndexedDBKey& key,
+void UtilityThreadImpl::OnInjectIDBKey(const IndexedDBKey& key,
const SerializedScriptValue& value,
const string16& key_path) {
SerializedScriptValue new_value(webkit_glue::InjectIDBKey(key, value,
@@ -88,16 +97,16 @@ void UtilityThread::OnInjectIDBKey(const IndexedDBKey& key,
ReleaseProcessIfNeeded();
}
-void UtilityThread::OnBatchModeStarted() {
+void UtilityThreadImpl::OnBatchModeStarted() {
batch_mode_ = true;
}
-void UtilityThread::OnBatchModeFinished() {
+void UtilityThreadImpl::OnBatchModeFinished() {
ChildProcess::current()->ReleaseProcess();
}
#if defined(OS_POSIX)
-void UtilityThread::OnLoadPlugins(
+void UtilityThreadImpl::OnLoadPlugins(
const std::vector<FilePath>& extra_plugin_paths,
const std::vector<FilePath>& extra_plugin_dirs,
const std::vector<webkit::WebPluginInfo>& internal_plugins) {
@@ -126,11 +135,7 @@ void UtilityThread::OnLoadPlugins(
plugin_list->GetPlugins(&plugins);
Send(new UtilityHostMsg_LoadedPlugins(plugins));
- UtilityThread::current()->ReleaseProcessIfNeeded();
+ ReleaseProcessIfNeeded();
}
#endif
-void UtilityThread::ReleaseProcessIfNeeded() {
- if (!batch_mode_)
- ChildProcess::current()->ReleaseProcess();
-}
diff --git a/content/utility/utility_thread.h b/content/utility/utility_thread_impl.h
index 8489a65..3af6c32 100644
--- a/content/utility/utility_thread.h
+++ b/content/utility/utility_thread_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_UTILITY_UTILITY_THREAD_H_
-#define CONTENT_UTILITY_UTILITY_THREAD_H_
+#ifndef CONTENT_UTILITY_UTILITY_THREAD_IMPL_H_
+#define CONTENT_UTILITY_UTILITY_THREAD_IMPL_H_
#pragma once
#include <string>
@@ -14,6 +14,7 @@
#include "base/string16.h"
#include "content/common/child_thread.h"
#include "content/common/content_export.h"
+#include "content/public/utility/utility_thread.h"
class FilePath;
class IndexedDBKey;
@@ -28,18 +29,15 @@ class WebKitPlatformSupportImpl;
}
// This class represents the background thread where the utility task runs.
-class UtilityThread : public ChildThread {
+class UtilityThreadImpl : public content::UtilityThread,
+ public ChildThread {
public:
- UtilityThread();
- virtual ~UtilityThread();
+ UtilityThreadImpl();
+ virtual ~UtilityThreadImpl();
- // Releases the process if we are not (or no longer) in batch mode.
- CONTENT_EXPORT void ReleaseProcessIfNeeded();
+ virtual bool Send(IPC::Message* msg) OVERRIDE;
- // Returns the one utility thread.
- static UtilityThread* current() {
- return static_cast<UtilityThread*>(ChildThread::current());
- }
+ virtual void ReleaseProcessIfNeeded() OVERRIDE;
private:
// ChildThread implementation.
@@ -68,7 +66,7 @@ class UtilityThread : public ChildThread {
scoped_ptr<webkit_glue::WebKitPlatformSupportImpl> webkit_platform_support_;
- DISALLOW_COPY_AND_ASSIGN(UtilityThread);
+ DISALLOW_COPY_AND_ASSIGN(UtilityThreadImpl);
};
-#endif // CONTENT_UTILITY_UTILITY_THREAD_H_
+#endif // CONTENT_UTILITY_UTILITY_THREAD_IMPL_H_