Index: content/browser/mach_broker_mac.cc |
diff --git a/content/browser/mach_broker_mac.cc b/content/browser/mach_broker_mac.cc |
index 09f3e75c55fed68e5a42ae039668288c01221511..8dea5f559df5add7cf1faa78105528cec4f42ca7 100644 |
--- a/content/browser/mach_broker_mac.cc |
+++ b/content/browser/mach_broker_mac.cc |
@@ -4,6 +4,8 @@ |
#include "content/browser/mach_broker_mac.h" |
+#include "base/bind.h" |
+#include "base/bind_helpers.h" |
#include "base/command_line.h" |
#include "base/logging.h" |
#include "base/mac/foundation_util.h" |
@@ -28,33 +30,6 @@ std::string MachErrorCode(kern_return_t err) { |
} |
} // namespace |
-// Required because notifications happen on the UI thread. |
-class RegisterNotificationTask : public Task { |
- public: |
- RegisterNotificationTask( |
- MachBroker* broker) |
- : broker_(broker) { } |
- |
- virtual void Run() { |
- broker_->registrar_.Add(broker_, |
- content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
- content::NotificationService::AllBrowserContextsAndSources()); |
- broker_->registrar_.Add(broker_, |
- content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
- content::NotificationService::AllBrowserContextsAndSources()); |
- broker_->registrar_.Add(broker_, |
- content::NOTIFICATION_CHILD_PROCESS_CRASHED, |
- content::NotificationService::AllBrowserContextsAndSources()); |
- broker_->registrar_.Add(broker_, |
- content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED, |
- content::NotificationService::AllBrowserContextsAndSources()); |
- } |
- |
- private: |
- MachBroker* broker_; |
- DISALLOW_COPY_AND_ASSIGN(RegisterNotificationTask); |
-}; |
- |
class MachListenerThreadDelegate : public base::PlatformThread::Delegate { |
public: |
MachListenerThreadDelegate(MachBroker* broker) : broker_(broker) { |
@@ -126,11 +101,6 @@ MachBroker* MachBroker::GetInstance() { |
return Singleton<MachBroker, LeakySingletonTraits<MachBroker> >::get(); |
} |
-MachBroker::MachBroker() : listener_thread_started_(false) { |
-} |
- |
-MachBroker::~MachBroker() {} |
- |
void MachBroker::EnsureRunning() { |
lock_.AssertAcquired(); |
@@ -138,7 +108,8 @@ void MachBroker::EnsureRunning() { |
listener_thread_started_ = true; |
BrowserThread::PostTask( |
- BrowserThread::UI, FROM_HERE, new RegisterNotificationTask(this)); |
+ BrowserThread::UI, FROM_HERE, |
+ base::Bind(&MachBroker::RegisterNotifications, base::Unretained(this))); |
// Intentional leak. This thread is never joined or reaped. |
base::PlatformThread::CreateNonJoinable( |
@@ -238,3 +209,19 @@ std::string MachBroker::GetMachPortName() { |
const pid_t pid = is_child ? getppid() : getpid(); |
return base::StringPrintf("%s.rohitfork.%d", base::mac::BaseBundleID(), pid); |
} |
+ |
+MachBroker::MachBroker() : listener_thread_started_(false) { |
+} |
+ |
+MachBroker::~MachBroker() {} |
+ |
+void MachBroker::RegisterNotifications() { |
+ registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
+ content::NotificationService::AllBrowserContextsAndSources()); |
+ registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
+ content::NotificationService::AllBrowserContextsAndSources()); |
+ registrar_.Add(this, content::NOTIFICATION_CHILD_PROCESS_CRASHED, |
+ content::NotificationService::AllBrowserContextsAndSources()); |
+ registrar_.Add(this, content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED, |
+ content::NotificationService::AllBrowserContextsAndSources()); |
+} |