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

Unified Diff: chrome/browser/android/metrics/variations_session.cc

Issue 1024993003: Upstream VariationsSession (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/android/metrics/variations_session.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/metrics/variations_session.cc
diff --git a/chrome/browser/android/metrics/variations_session.cc b/chrome/browser/android/metrics/variations_session.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b9cac1e50efa9a5cf14959af9231b2da3fef3a1e
--- /dev/null
+++ b/chrome/browser/android/metrics/variations_session.cc
@@ -0,0 +1,46 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/metrics/variations_session.h"
+
+#include "base/android/jni_string.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/metrics/variations/variations_service.h"
+#include "jni/VariationsSession_jni.h"
+
+namespace {
+
+// Tracks whether VariationsService::OnAppEnterForeground() has been called
+// previously, in order to set the restrict mode param before the first call.
+bool g_on_app_enter_foreground_called = false;
+
+} // namespace
+
+static void StartVariationsSession(JNIEnv* env,
+ jobject obj,
+ jstring jrestrict_mode) {
+ DCHECK(g_browser_process);
+
+ chrome_variations::VariationsService* variations_service =
+ g_browser_process->variations_service();
+ // Triggers an OnAppEnterForeground on the VariationsService. This may fetch
+ // a new seed.
+ if (variations_service) {
+ std::string restrict_mode =
+ base::android::ConvertJavaStringToUTF8(env, jrestrict_mode);
+ if (!restrict_mode.empty() && !g_on_app_enter_foreground_called)
+ variations_service->SetRestrictMode(restrict_mode);
+ variations_service->OnAppEnterForeground();
+ g_on_app_enter_foreground_called = true;
+ }
+}
+
+namespace chrome {
+namespace android {
+
+// Register native methods
+bool RegisterVariationsSession(JNIEnv* env) { return RegisterNativesImpl(env); }
+
+} // namespace android
+} // namespace chrome
« no previous file with comments | « chrome/browser/android/metrics/variations_session.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698