Chromium Code Reviews| Index: chrome/browser/mac/keystone_glue.mm |
| diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm |
| index 6960e70cb060a786d1be7162973e6069516fbe5b..c8cacdd89974243ec5ceaf976145933ae9d4ae30 100644 |
| --- a/chrome/browser/mac/keystone_glue.mm |
| +++ b/chrome/browser/mac/keystone_glue.mm |
| @@ -24,6 +24,7 @@ |
| #include "base/threading/worker_pool.h" |
| #include "build/build_config.h" |
| #import "chrome/browser/mac/keystone_registration.h" |
| +#import "chrome/browser/mac/keystone_reporting_attribute.h" |
| #include "chrome/browser/mac/obsolete_system.h" |
| #include "chrome/common/chrome_constants.h" |
| #include "chrome/common/chrome_version_info.h" |
| @@ -119,6 +120,9 @@ class PerformBridge : public base::RefCountedThreadSafe<PerformBridge> { |
| // Called when Keystone registration completes. |
| - (void)registrationComplete:(NSNotification*)notification; |
| +// Set the registration active passing profile count parameters. |
| +- (void)setRegistrationActive:(KSRegistration*)ksr; |
| + |
| // Called periodically to announce activity by pinging the Keystone server. |
| - (void)markActive:(NSTimer*)timer; |
| @@ -491,6 +495,51 @@ NSString* const kVersionKey = @"KSVersion"; |
| nil]; |
| } |
| +- (void)setRegistrationActive:(KSRegistration*)ksr { |
| + if (numSignedInProfiles_ > 0) { |
|
bcwhite
2014/09/23 20:32:58
Should this be "numProfiles_"? You could have exi
Mike Lerman
2014/09/26 19:52:29
Done.
|
| + NSError* reportingAttributeError = nil; |
| + KSUnsignedReportingAttribute* numProfilesAttribute = |
| + [KSUnsignedReportingAttribute |
| + reportingAttributeWithValue:numProfiles_ |
| + name:@"_numAccounts" |
| + aggregationType:kKSReportingAggregationSum |
| + error:&reportingAttributeError]; |
| + if (reportingAttributeError != nil) { |
| + LOG(ERROR) << [reportingAttributeError localizedDescription]; |
| + [ksr setActive]; |
| + return; |
| + } |
| + |
| + KSUnsignedReportingAttribute* numSignedInProfilesAttribute = |
| + [KSUnsignedReportingAttribute |
| + reportingAttributeWithValue:numSignedInProfiles_ |
| + name:@"_numSignedInAccounts" |
| + aggregationType:kKSReportingAggregationSum |
| + error:&reportingAttributeError]; |
| + if (reportingAttributeError != nil) { |
| + LOG(ERROR) << [reportingAttributeError localizedDescription]; |
| + [ksr setActive]; |
| + return; |
| + } |
| + |
| + NSArray* profileCountsInformation = |
| + [NSArray arrayWithObjects:numProfilesAttribute, |
| + numSignedInProfilesAttribute, |
| + nil]; |
| + |
| + NSError* setActiveError = nil; |
| + [ksr setActiveWithReportingAttributes:profileCountsInformation |
| + error:&setActiveError]; |
| + if (setActiveError != nil) { |
| + LOG(ERROR) << [setActiveError localizedDescription]; |
| + [ksr setActive]; |
|
bcwhite
2014/09/23 20:32:58
How about moving this out of the condition and eli
Mike Lerman
2014/09/26 19:52:30
I flipped the upper condition around.
bcwhite
2014/09/26 20:41:20
I like the idea where you optionally add things to
Mike Lerman
2014/10/06 16:49:08
We don't always call setActive, we call it only if
|
| + return; |
|
bcwhite
2014/09/23 20:32:58
Unneeded.
Mike Lerman
2014/09/26 19:52:29
Done.
|
| + } |
| + } else { |
| + [ksr setActive]; |
| + } |
| +} |
| + |
| - (void)registerWithKeystone { |
| [self updateStatus:kAutoupdateRegistering version:nil]; |
| @@ -512,7 +561,7 @@ 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:registration_]; |
| // Set up hourly activity pings. |
| timer_ = [NSTimer scheduledTimerWithTimeInterval:60 * 60 // One hour |
| @@ -541,8 +590,7 @@ NSString* const kVersionKey = @"KSVersion"; |
| } |
| - (void)markActive:(NSTimer*)timer { |
| - KSRegistration* ksr = [timer userInfo]; |
| - [ksr setActive]; |
| + [self setRegistrationActive:[timer userInfo]]; |
| } |
| - (void)checkForUpdate { |
| @@ -1045,6 +1093,13 @@ NSString* const kVersionKey = @"KSVersion"; |
| return tagSuffix; |
| } |
| + |
| +- (void)updateProfileCountsWithNumProfiles:(size_t)numProfiles |
| + numSignedInProfiles:(size_t)numSignedInProfiles { |
| + numProfiles_ = numProfiles; |
| + numSignedInProfiles_ = numSignedInProfiles; |
| +} |
| + |
| @end // @implementation KeystoneGlue |
| namespace { |