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

Side by Side Diff: chrome/browser/sync/sync_sessions_metrics_android.cc

Issue 2343463003: [Sync] Fix namespaces for the sync_sessions component. (Closed)
Patch Set: Fix gn. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/sync_sessions_metrics_android.h"
6
7 #include <string>
8
9 #include "base/metrics/field_trial.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/sync/profile_sync_service_factory.h"
13 #include "components/browser_sync/browser/profile_sync_service.h"
14 #include "components/sync_sessions/sessions_sync_manager.h"
15 #include "components/sync_sessions/sync_sessions_metrics.h"
16 #include "jni/SyncSessionsMetrics_jni.h"
17
18 // static
19 bool SyncSessionsMetricsAndroid::Register(JNIEnv* env) {
20 return RegisterNativesImpl(env);
21 }
22
23 // static
24 void RecordYoungestForeignTabAgeOnNTP(
25 JNIEnv* env,
26 const base::android::JavaParamRef<jclass>& jcaller) {
27 // Unlike other platforms, Android typically disables session invalidations to
28 // conserve battery. This means that the foreign tab data may be quite stale.
29 // This would drastically distort the metric we want to emit here, however the
30 // revisit experiement disables said optimization, allowing us to collect
31 // valid data but at the cost of a much smaller sample size.
32 const std::string group_name =
33 base::FieldTrialList::FindFullName("PageRevisitInstrumentation");
34 bool shouldInstrument = group_name == "Enabled";
35 if (shouldInstrument) {
36 Profile* profile = ProfileManager::GetActiveUserProfile();
37 if (profile) {
38 ProfileSyncService* sync =
39 ProfileSyncServiceFactory::GetForProfile(profile);
40 if (sync) {
41 browser_sync::SessionsSyncManager* sessions =
42 static_cast<browser_sync::SessionsSyncManager*>(
43 sync->GetSessionsSyncableService());
44 if (sessions) {
45 sync_sessions::SyncSessionsMetrics::RecordYoungestForeignTabAgeOnNTP(
46 sessions);
47 }
48 }
49 }
50 }
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698