Index: chrome/browser/mac/keystone_glue.mm |
diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm |
index bd0e12e827bc302fd7b6a1a44a19f03f081f1392..a99ff29b22a14bbad47489eb1b9b32386e04d7e3 100644 |
--- a/chrome/browser/mac/keystone_glue.mm |
+++ b/chrome/browser/mac/keystone_glue.mm |
@@ -119,6 +119,9 @@ class PerformBridge : public base::RefCountedThreadSafe<PerformBridge> { |
// Called when Keystone registration completes. |
- (void)registrationComplete:(NSNotification*)notification; |
+// Set the registration active and pass profile count parameters. |
+- (void)setRegistrationActive; |
+ |
// Called periodically to announce activity by pinging the Keystone server. |
- (void)markActive:(NSTimer*)timer; |
@@ -215,6 +218,9 @@ NSString* const kChannelKey = @"KSChannelID"; |
NSString* const kBrandKey = @"KSBrandID"; |
NSString* const kVersionKey = @"KSVersion"; |
+// Keep the Keystone Registration bundle once it's been loaded. |
+NSBundle* ksrBundle; |
Mark Mentovai
2015/02/20 21:54:18
Don’t store this in a global. Use an instance vari
Mike Lerman
2015/02/23 16:12:11
Done.
|
+ |
} // namespace |
@implementation KeystoneGlue |
@@ -435,7 +441,7 @@ NSString* const kVersionKey = @"KSVersion"; |
NSString* ksrPath = |
[[base::mac::FrameworkBundle() privateFrameworksPath] |
stringByAppendingPathComponent:@"KeystoneRegistration.framework"]; |
- NSBundle* ksrBundle = [NSBundle bundleWithPath:ksrPath]; |
+ ksrBundle = [NSBundle bundleWithPath:ksrPath]; |
[ksrBundle load]; |
// Harness the KSRegistration class. |
@@ -491,6 +497,49 @@ NSString* const kVersionKey = @"KSVersion"; |
nil]; |
} |
+- (void)setRegistrationActive { |
+ if (!registration_) |
+ return; |
+ |
+ // Should never have zero profiles. Do not report this value. |
+ if (!numProfiles_) { |
+ [registration_ setActive]; |
+ return; |
+ } |
+ |
+ NSError* reportingError = nil; |
+ |
+ Class ksUnsignedReportingAttributeClass = |
+ [ksrBundle classNamed:@"KSUnsignedReportingAttribute"]; |
+ |
+ KSReportingAttribute* numAccountsAttr = |
+ [ksUnsignedReportingAttributeClass |
+ reportingAttributeWithValue:numProfiles_ |
+ name:@"_NumAccounts" |
+ aggregationType:kKSReportingAggregationSum |
+ error:&reportingError]; |
+ if (reportingError != nil) |
+ VLOG(1) << [reportingError localizedDescription]; |
+ reportingError = nil; |
+ |
+ KSReportingAttribute* numSignedInAccountsAttr = |
+ [ksUnsignedReportingAttributeClass |
+ reportingAttributeWithValue:numSignedInProfiles_ |
+ name:@"_NumSignedIn" |
+ aggregationType:kKSReportingAggregationSum |
+ error:&reportingError]; |
+ if (reportingError != nil) |
+ VLOG(1) << [reportingError localizedDescription]; |
+ reportingError = nil; |
+ |
+ NSArray* profileCountsInformation = |
+ [NSArray arrayWithObjects:numAccountsAttr, numSignedInAccountsAttr, nil]; |
+ |
+ if (![registration_ setActiveWithReportingAttributes:profileCountsInformation |
+ error:&reportingError]) |
+ VLOG(1) << [reportingError localizedDescription]; |
Mark Mentovai
2015/02/20 21:54:18
{brace} this because its controlling condition tak
Mike Lerman
2015/02/23 16:12:11
Indeed - thanks. Done.
|
+} |
+ |
- (void)registerWithKeystone { |
[self updateStatus:kAutoupdateRegistering version:nil]; |
@@ -512,13 +561,13 @@ NSString* const kVersionKey = @"KSVersion"; |
// posted, and -registrationComplete: will be called. |
// Mark an active RIGHT NOW; don't wait an hour for the first one. |
- [registration_ setActive]; |
+ [self setRegistrationActive]; |
// Set up hourly activity pings. |
timer_ = [NSTimer scheduledTimerWithTimeInterval:60 * 60 // One hour |
target:self |
selector:@selector(markActive:) |
- userInfo:registration_ |
+ userInfo:nil |
repeats:YES]; |
} |
@@ -541,8 +590,7 @@ NSString* const kVersionKey = @"KSVersion"; |
} |
- (void)markActive:(NSTimer*)timer { |
- KSRegistration* ksr = [timer userInfo]; |
- [ksr setActive]; |
+ [self setRegistrationActive]; |
} |
- (void)checkForUpdate { |
@@ -1049,6 +1097,13 @@ NSString* const kVersionKey = @"KSVersion"; |
return tagSuffix; |
} |
+ |
+- (void)updateProfileCountsWithNumProfiles:(uint32_t)numProfiles |
+ numSignedInProfiles:(uint32_t)numSignedInProfiles { |
+ numProfiles_ = numProfiles; |
+ numSignedInProfiles_ = numSignedInProfiles; |
+} |
+ |
@end // @implementation KeystoneGlue |
namespace { |