Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1292)

Unified Diff: content/browser/mach_broker_mac.cc

Issue 8734017: base::Bind: More random cleanups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mac build fix 2. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/mach_broker_mac.h ('k') | net/base/keygen_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
+}
« no previous file with comments | « content/browser/mach_broker_mac.h ('k') | net/base/keygen_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698