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

Unified Diff: chrome/browser/mac/keystone_glue.mm

Issue 593243002: Profile_Metrics integration with Keystone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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
« no previous file with comments | « chrome/browser/mac/keystone_glue.h ('k') | chrome/browser/mac/keystone_glue_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..42b6b49e2c4b3db0135f78da0cad7ef3b8731d46 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;
@@ -445,6 +448,8 @@ NSString* const kVersionKey = @"KSVersion";
return NO;
registration_ = [ksr retain];
+ ksUnsignedReportingAttributeClass_ =
+ [ksrBundle classNamed:@"KSUnsignedReportingAttribute"];
return YES;
}
@@ -491,6 +496,47 @@ 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;
+
+ 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];
+ }
+}
+
- (void)registerWithKeystone {
[self updateStatus:kAutoupdateRegistering version:nil];
@@ -512,13 +558,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 +587,7 @@ NSString* const kVersionKey = @"KSVersion";
}
- (void)markActive:(NSTimer*)timer {
- KSRegistration* ksr = [timer userInfo];
- [ksr setActive];
+ [self setRegistrationActive];
}
- (void)checkForUpdate {
@@ -1049,6 +1094,13 @@ NSString* const kVersionKey = @"KSVersion";
return tagSuffix;
}
+
+- (void)updateProfileCountsWithNumProfiles:(uint32_t)profiles
+ numSignedInProfiles:(uint32_t)signedInProfiles {
+ numProfiles_ = profiles;
+ numSignedInProfiles_ = signedInProfiles;
+}
+
@end // @implementation KeystoneGlue
namespace {
« no previous file with comments | « chrome/browser/mac/keystone_glue.h ('k') | chrome/browser/mac/keystone_glue_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698