summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_thread.cc
diff options
context:
space:
mode:
authornsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 18:17:55 +0000
committernsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 18:17:55 +0000
commit42f1d782153f79b0b43bcb17db7dc4979bc08814 (patch)
treea5f08a5eda55157626abccd96b0b1ff177882370 /chrome/renderer/render_thread.cc
parentafc9075980bba8f1427b788692f45921ecf14b67 (diff)
downloadchromium_src-42f1d782153f79b0b43bcb17db7dc4979bc08814.zip
chromium_src-42f1d782153f79b0b43bcb17db7dc4979bc08814.tar.gz
chromium_src-42f1d782153f79b0b43bcb17db7dc4979bc08814.tar.bz2
Unrevert 21355 because the revert might be causing the
worker tests failures. Review URL: http://codereview.chromium.org/159276 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_thread.cc')
-rw-r--r--chrome/renderer/render_thread.cc99
1 files changed, 36 insertions, 63 deletions
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index e35377a..80811b2 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -17,7 +17,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/renderer_preferences.h"
-#include "chrome/common/notification_service.h"
#include "chrome/common/url_constants.h"
#include "chrome/plugin/npobject_util.h"
// TODO(port)
@@ -55,54 +54,10 @@
using WebKit::WebCache;
using WebKit::WebString;
+namespace {
static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */;
-
static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls(
base::LINKER_INITIALIZED);
-
-//-----------------------------------------------------------------------------
-// Methods below are only called on the owner's thread:
-
-// When we run plugins in process, we actually run them on the render thread,
-// which means that we need to make the render thread pump UI events.
-RenderThread::RenderThread()
- : ChildThread(
- base::Thread::Options(RenderProcess::InProcessPlugins() ?
- MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kV8StackSize)),
- plugin_refresh_allowed_(true) {
-}
-
-RenderThread::RenderThread(const std::string& channel_name)
- : ChildThread(
- base::Thread::Options(RenderProcess::InProcessPlugins() ?
- MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kV8StackSize)),
- plugin_refresh_allowed_(true) {
- SetChannelName(channel_name);
-}
-
-RenderThread::~RenderThread() {
-}
-
-RenderThread* RenderThread::current() {
- return lazy_tls.Pointer()->Get();
-}
-
-void RenderThread::AddFilter(IPC::ChannelProxy::MessageFilter* filter) {
- channel()->AddFilter(filter);
-}
-
-void RenderThread::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) {
- channel()->RemoveFilter(filter);
-}
-
-void RenderThread::Resolve(const char* name, size_t length) {
- return dns_master_->Resolve(name, length);
-}
-
-void RenderThread::SendHistograms(int sequence_number) {
- return histogram_snapshots_->SendHistograms(sequence_number);
-}
-
static WebAppCacheContext* CreateAppCacheContextForRenderer() {
return new AppCacheContextImpl(RenderThread::current());
}
@@ -128,6 +83,18 @@ class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter {
}
};
#endif
+} // namespace
+
+// When we run plugins in process, we actually run them on the render thread,
+// which means that we need to make the render thread pump UI events.
+RenderThread::RenderThread() {
+ Init();
+}
+
+RenderThread::RenderThread(const std::string& channel_name)
+ : ChildThread(channel_name) {
+ Init();
+}
void RenderThread::Init() {
lazy_tls.Pointer()->Set(this);
@@ -138,8 +105,7 @@ void RenderThread::Init() {
CoInitialize(0);
#endif
- ChildThread::Init();
- notification_service_.reset(new NotificationService);
+ plugin_refresh_allowed_ = true;
cache_stats_factory_.reset(
new ScopedRunnableMethodFactory<RenderThread>(this));
@@ -158,24 +124,13 @@ void RenderThread::Init() {
#endif
}
-void RenderThread::CleanUp() {
+RenderThread::~RenderThread() {
// Shutdown in reverse of the initialization order.
RemoveFilter(devtools_agent_filter_.get());
- devtools_agent_filter_ = NULL;
WebAppCacheContext::SetFactory(NULL);
- app_cache_dispatcher_.reset();
- histogram_snapshots_.reset();
- dns_master_.reset();
- user_script_slave_.reset();
- visited_link_slave_.reset();
-
- if (webkit_client_.get()) {
+ if (webkit_client_.get())
WebKit::shutdown();
- webkit_client_.reset();
- }
- notification_service_.reset();
- ChildThread::CleanUp();
lazy_tls.Pointer()->Set(NULL);
// TODO(port)
@@ -188,6 +143,26 @@ void RenderThread::CleanUp() {
#endif
}
+RenderThread* RenderThread::current() {
+ return lazy_tls.Pointer()->Get();
+}
+
+void RenderThread::AddFilter(IPC::ChannelProxy::MessageFilter* filter) {
+ channel()->AddFilter(filter);
+}
+
+void RenderThread::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) {
+ channel()->RemoveFilter(filter);
+}
+
+void RenderThread::Resolve(const char* name, size_t length) {
+ return dns_master_->Resolve(name, length);
+}
+
+void RenderThread::SendHistograms(int sequence_number) {
+ return histogram_snapshots_->SendHistograms(sequence_number);
+}
+
void RenderThread::OnUpdateVisitedLinks(base::SharedMemoryHandle table) {
DCHECK(base::SharedMemory::IsHandleValid(table)) << "Bad table handle";
visited_link_slave_->Init(table);
@@ -274,8 +249,6 @@ void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd,
true, false);
#endif
- // TODO(darin): once we have a RenderThread per RenderView, this will need to
- // change to assert that we are not creating more than one view.
RenderView::Create(
this, parent_hwnd, waitable_event, MSG_ROUTING_NONE, renderer_prefs,
webkit_prefs, new SharedRenderViewCounter(0), view_id);