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

Unified Diff: remoting/host/me2me_preference_pane.mm

Issue 10386128: Use distributed notifications instead of polling to determine success/failure of the preference pan… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove observer in dtor. Created 8 years, 7 months 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
Index: remoting/host/me2me_preference_pane.mm
diff --git a/remoting/host/me2me_preference_pane.mm b/remoting/host/me2me_preference_pane.mm
index d092983ba081d82ff257c5f6970fa9519e77be2f..90e34a5d3831337baabc04ec6a5189ecbd0c0f49 100644
--- a/remoting/host/me2me_preference_pane.mm
+++ b/remoting/host/me2me_preference_pane.mm
@@ -28,6 +28,8 @@
namespace {
// The name of the Remoting Host service that is registered with launchd.
#define kServiceName "org.chromium.chromoting"
+
+#define kUpdateCompleteNotificationName kServiceName ".update_complete"
#define kConfigDir "/Library/PrivilegedHelperTools/"
// This helper script is executed as root. It is passed a command-line option
@@ -103,6 +105,9 @@ bool IsPinValid(const std::string& pin, const std::string& host_id,
[service_status_timer_ invalidate];
[service_status_timer_ release];
service_status_timer_ = nil;
+ if (have_new_config_) {
+ [self notifyPlugin: @"CANCEL"];
+ }
}
- (void)onApply:(id)sender {
@@ -291,6 +296,10 @@ bool IsPinValid(const std::string& pin, const std::string& host_id,
} else {
[self sendJobControlMessage:LAUNCH_KEY_STARTJOB];
}
+
+ // Broadcast a distributed notification to inform the plugin that the
+ // configuration has been applied.
+ [self notifyPlugin: @"OK"];
}
- (BOOL)runHelperAsRootWithCommand:(const char*)command
@@ -400,4 +409,17 @@ bool IsPinValid(const std::string& pin, const std::string& host_id,
return YES;
}
+- (void)notifyPlugin:(NSString*)result {
+ NSDistributedNotificationCenter* center =
+ [NSDistributedNotificationCenter defaultCenter];
+ NSString* name =
+ [[NSString alloc] initWithUTF8String:kUpdateCompleteNotificationName];
Lambros 2012/05/15 18:55:35 nit: stringWithUTF8String might be easier (and doe
Jamie 2012/05/15 20:53:50 Thanks, I wasn't aware of that.
+ NSDictionary* result_dictionary =
+ [NSDictionary dictionaryWithObject:result
+ forKey:@"result"];
+ [center postNotificationName:name
+ object:nil
+ userInfo:result_dictionary];
+}
+
@end
« no previous file with comments | « no previous file | remoting/host/plugin/daemon_controller_mac.cc » ('j') | remoting/host/plugin/daemon_controller_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698