summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/common/child_process.cc25
-rw-r--r--content/common/child_process.h5
2 files changed, 13 insertions, 17 deletions
diff --git a/content/common/child_process.cc b/content/common/child_process.cc
index 3a31a96..5e5d5fa 100644
--- a/content/common/child_process.cc
+++ b/content/common/child_process.cc
@@ -8,12 +8,10 @@
#include <signal.h> // For SigUSR1Handler below.
#endif
-#include "base/lazy_instance.h"
#include "base/message_loop.h"
#include "base/process_util.h"
#include "base/string_number_conversions.h"
#include "base/threading/thread.h"
-#include "base/threading/thread_local.h"
#include "base/utf_string_conversions.h"
#include "content/common/child_thread.h"
@@ -21,23 +19,20 @@
static void SigUSR1Handler(int signal) { }
#endif
-namespace {
-static base::LazyInstance<base::ThreadLocalPointer<ChildProcess> > lazy_tls(
- base::LINKER_INITIALIZED);
-}
+ChildProcess* ChildProcess::child_process_;
ChildProcess::ChildProcess()
: ref_count_(0),
shutdown_event_(true, false),
io_thread_("Chrome_ChildIOThread") {
- DCHECK(!lazy_tls.Pointer()->Get());
- lazy_tls.Pointer()->Set(this);
+ DCHECK(!child_process_);
+ child_process_ = this;
io_thread_.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0));
}
ChildProcess::~ChildProcess() {
- DCHECK(lazy_tls.Pointer()->Get() == this);
+ DCHECK(child_process_ == this);
// Signal this event before destroying the child process. That way all
// background threads can cleanup.
@@ -45,15 +40,11 @@ ChildProcess::~ChildProcess() {
// notice shutdown before the render process begins waiting for them to exit.
shutdown_event_.Signal();
- // Kill the main thread object before nulling lazy_tls, since
+ // Kill the main thread object before nulling child_process_, since
// destruction code might depend on it.
main_thread_.reset();
- lazy_tls.Pointer()->Set(NULL);
-}
-
-ChildProcess* ChildProcess::current() {
- return lazy_tls.Pointer()->Get();
+ child_process_ = NULL;
}
ChildThread* ChildProcess::main_thread() {
@@ -74,6 +65,7 @@ void ChildProcess::ReleaseProcess() {
DCHECK(!main_thread_.get() || // null in unittests.
MessageLoop::current() == main_thread_->message_loop());
DCHECK(ref_count_);
+ DCHECK(child_process_);
if (--ref_count_)
return;
@@ -82,7 +74,8 @@ void ChildProcess::ReleaseProcess() {
}
base::WaitableEvent* ChildProcess::GetShutDownEvent() {
- return &lazy_tls.Pointer()->Get()->shutdown_event_;
+ DCHECK(child_process_);
+ return &child_process_->shutdown_event_;
}
void ChildProcess::WaitForDebugger(const std::string& label) {
diff --git a/content/common/child_process.h b/content/common/child_process.h
index f37d528..e3786ae 100644
--- a/content/common/child_process.h
+++ b/content/common/child_process.h
@@ -53,7 +53,7 @@ class ChildProcess {
void ReleaseProcess();
// Getter for the one ChildProcess object for this process.
- static ChildProcess* current();
+ static ChildProcess* current() { return child_process_; }
static void WaitForDebugger(const std::string& label);
private:
@@ -70,6 +70,9 @@ class ChildProcess {
// io_thread_.
scoped_ptr<ChildThread> main_thread_;
+ // The singleton instance for this process.
+ static ChildProcess* child_process_;
+
DISALLOW_COPY_AND_ASSIGN(ChildProcess);
};