Skip to content

Commit

Permalink
Bug 913653: Remove lock from IOInterposer and add IOInterposer thread…
Browse files Browse the repository at this point in the history
… registration; r=froydnj
  • Loading branch information
dblohm7 committed Apr 9, 2014
1 parent 6e32959 commit 025fed5
Show file tree
Hide file tree
Showing 7 changed files with 394 additions and 225 deletions.
3 changes: 3 additions & 0 deletions dom/src/storage/DOMStorageDBThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "mozIStorageFunction.h"
#include "nsIObserverService.h"
#include "nsIVariant.h"
#include "mozilla/IOInterposer.h"
#include "mozilla/Services.h"

// How long we collect write oprerations
Expand Down Expand Up @@ -279,9 +280,11 @@ void
DOMStorageDBThread::ThreadFunc(void* aArg)
{
PR_SetCurrentThreadName("localStorage DB");
mozilla::IOInterposer::RegisterCurrentThread();

DOMStorageDBThread* thread = static_cast<DOMStorageDBThread*>(aArg);
thread->ThreadFunc();
mozilla::IOInterposer::UnregisterCurrentThread();
}

void
Expand Down
3 changes: 3 additions & 0 deletions ipc/chromium/src/base/thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/thread_local.h"
#include "base/waitable_event.h"
#include "GeckoProfiler.h"
#include "mozilla/IOInterposer.h"

namespace base {

Expand Down Expand Up @@ -139,6 +140,7 @@ void Thread::StopSoon() {
void Thread::ThreadMain() {
char aLocal;
profiler_register_thread(name_.c_str(), &aLocal);
mozilla::IOInterposer::RegisterCurrentThread();

// The message loop for this thread.
MessageLoop message_loop(startup_data_->options.message_loop_type);
Expand Down Expand Up @@ -167,6 +169,7 @@ void Thread::ThreadMain() {
// Assert that MessageLoop::Quit was called by ThreadQuitTask.
DCHECK(GetThreadWasQuitProperly());

mozilla::IOInterposer::UnregisterCurrentThread();
profiler_unregister_thread();

// We can't receive messages anymore.
Expand Down
3 changes: 3 additions & 0 deletions netwerk/cache2/CacheIOThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "nsISupportsImpl.h"
#include "nsPrintfCString.h"
#include "nsThreadUtils.h"
#include "mozilla/IOInterposer.h"
#include "mozilla/VisualEventTracer.h"

namespace mozilla {
Expand Down Expand Up @@ -152,8 +153,10 @@ already_AddRefed<nsIEventTarget> CacheIOThread::Target()
void CacheIOThread::ThreadFunc(void* aClosure)
{
PR_SetCurrentThreadName("Cache2 I/O");
mozilla::IOInterposer::RegisterCurrentThread();
CacheIOThread* thread = static_cast<CacheIOThread*>(aClosure);
thread->ThreadFunc();
mozilla::IOInterposer::UnregisterCurrentThread();
}

void CacheIOThread::ThreadFunc()
Expand Down
3 changes: 3 additions & 0 deletions startupcache/StartupCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "prio.h"
#include "pldhash.h"
#include "nsXPCOMStrings.h"
#include "mozilla/IOInterposer.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/scache/StartupCache.h"

Expand Down Expand Up @@ -536,6 +537,7 @@ void
StartupCache::ThreadedWrite(void *aClosure)
{
PR_SetCurrentThreadName("StartupCache");
mozilla::IOInterposer::RegisterCurrentThread();
/*
* It is safe to use the pointer passed in aClosure to reference the
* StartupCache object because the thread's lifetime is tightly coupled to
Expand All @@ -545,6 +547,7 @@ StartupCache::ThreadedWrite(void *aClosure)
*/
StartupCache* startupCacheObj = static_cast<StartupCache*>(aClosure);
startupCacheObj->WriteToDisk();
mozilla::IOInterposer::UnregisterCurrentThread();
}

/*
Expand Down
Loading

0 comments on commit 025fed5

Please sign in to comment.