Skip to content

Commit

Permalink
AW: move variations code into separate folder
Browse files Browse the repository at this point in the history
No change to logic. This moves WebView's variations code into separate
folders with distinct OWNERS files, updates BUILD rules, and applies
automatic code formatting from git-cl format.

Test: autoninja -C out/Default system_webview_apk
Test: run_webview_instrumentation_test_apk -f *Variations*
Test: gn check out/Default android_webview/browser/variations:variations
Test: gn check out/Default android_webview/browser:browser
Change-Id: If405f2f840d37861d38f8d5b221ed5f2bc36de69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2469356
Reviewed-by: Richard Coles <[email protected]>
Reviewed-by: Changwan Ryu <[email protected]>
Commit-Queue: Nate Fischer <[email protected]>
Cr-Commit-Position: refs/heads/master@{#817130}
  • Loading branch information
ntfschr-chromium authored and Commit Bot committed Oct 14, 2020
1 parent d76ce9b commit 8e5da69
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 27 deletions.
4 changes: 2 additions & 2 deletions android_webview/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ generate_jni("browser_jni_headers") {
"java/src/org/chromium/android_webview/AwWebResourceResponse.java",
"java/src/org/chromium/android_webview/JsReplyProxy.java",
"java/src/org/chromium/android_webview/PopupTouchHandleDrawable.java",
"java/src/org/chromium/android_webview/VariationsSeedLoader.java",
"java/src/org/chromium/android_webview/WebMessageListenerHolder.java",
"java/src/org/chromium/android_webview/WebMessageListenerInfo.java",
"java/src/org/chromium/android_webview/gfx/AwDrawFnImpl.java",
Expand All @@ -411,6 +410,7 @@ generate_jni("browser_jni_headers") {
"java/src/org/chromium/android_webview/metrics/AwMetricsServiceClient.java",
"java/src/org/chromium/android_webview/permission/AwPermissionRequest.java",
"java/src/org/chromium/android_webview/safe_browsing/AwSafeBrowsingConfigHelper.java",
"java/src/org/chromium/android_webview/variations/VariationsSeedLoader.java",
]

deps = [ ":cancellation_signal_android_jar_jni_headers" ]
Expand Down Expand Up @@ -488,7 +488,6 @@ android_library("browser_java") {
"java/src/org/chromium/android_webview/ScriptReference.java",
"java/src/org/chromium/android_webview/ScrollAccessibilityHelper.java",
"java/src/org/chromium/android_webview/SslUtil.java",
"java/src/org/chromium/android_webview/VariationsSeedLoader.java",
"java/src/org/chromium/android_webview/ViewPositionObserver.java",
"java/src/org/chromium/android_webview/WebMessageListener.java",
"java/src/org/chromium/android_webview/WebMessageListenerHolder.java",
Expand All @@ -510,6 +509,7 @@ android_library("browser_java") {
"java/src/org/chromium/android_webview/safe_browsing/AwSafeBrowsingConfigHelper.java",
"java/src/org/chromium/android_webview/safe_browsing/AwSafeBrowsingConversionHelper.java",
"java/src/org/chromium/android_webview/safe_browsing/AwSafeBrowsingResponse.java",
"java/src/org/chromium/android_webview/variations/VariationsSeedLoader.java",
]
deps = [
":common_aidl_java",
Expand Down
6 changes: 1 addition & 5 deletions android_webview/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ source_set("browser") {
"aw_speech_recognition_manager_delegate.h",
"aw_ssl_host_state_delegate.cc",
"aw_ssl_host_state_delegate.h",
"aw_variations_service_client.cc",
"aw_variations_service_client.h",
"aw_web_contents_delegate.cc",
"aw_web_contents_delegate.h",
"aw_web_contents_view_delegate.cc",
Expand Down Expand Up @@ -174,8 +172,6 @@ source_set("browser") {
"tracing/aw_tracing_controller.h",
"tracing/aw_tracing_delegate.cc",
"tracing/aw_tracing_delegate.h",
"variations_seed_loader.cc",
"variations_seed_loader.h",
]

deps = [
Expand All @@ -184,6 +180,7 @@ source_set("browser") {
"//android_webview/browser/gfx",
"//android_webview/browser/lifecycle",
"//android_webview/browser/metrics",
"//android_webview/browser/variations",
"//android_webview/common",
"//android_webview/proto:aw_variations_seed_proto",
"//base",
Expand Down Expand Up @@ -239,7 +236,6 @@ source_set("browser") {
"//components/url_formatter",
"//components/user_prefs",
"//components/variations",
"//components/variations/net",
"//components/variations/service",
"//components/version_info",
"//components/version_info/android:channel_getter",
Expand Down
6 changes: 6 additions & 0 deletions android_webview/browser/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ per-file aw_content_browser_receiver_bindings.cc=file://ipc/SECURITY_OWNERS

per-file aw_browser_policy_connector.h=file://chrome/browser/policy/OWNERS
per-file aw_browser_policy_connector.cc=file://chrome/browser/policy/OWNERS

# For metrics-related changes
per-file aw_feature_list_creator.*=file://android_webview/browser/metrics/OWNERS

# For variations-related changes
per-file aw_feature_list_creator.*=file://android_webview/browser/variations/OWNERS
2 changes: 1 addition & 1 deletion android_webview/browser/aw_feature_list_creator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "android_webview/browser/aw_browser_process.h"
#include "android_webview/browser/aw_metrics_service_client_delegate.h"
#include "android_webview/browser/metrics/aw_metrics_service_client.h"
#include "android_webview/browser/variations_seed_loader.h"
#include "android_webview/browser/variations/variations_seed_loader.h"
#include "android_webview/proto/aw_variations_seed.pb.h"
#include "base/base_switches.h"
#include "base/bind.h"
Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/aw_feature_list_creator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "android_webview/browser/aw_browser_policy_connector.h"
#include "android_webview/browser/aw_field_trials.h"
#include "android_webview/browser/aw_variations_service_client.h"
#include "android_webview/browser/variations/aw_variations_service_client.h"
#include "base/metrics/field_trial.h"
#include "components/policy/core/browser/browser_policy_connector_base.h"
#include "components/prefs/pref_service.h"
Expand Down
20 changes: 20 additions & 0 deletions android_webview/browser/variations/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2020 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.

source_set("variations") {
sources = [
"aw_variations_service_client.cc",
"aw_variations_service_client.h",
"variations_seed_loader.cc",
"variations_seed_loader.h",
]
deps = [
"//android_webview:browser_jni_headers",
"//android_webview/proto:aw_variations_seed_proto",
"//components/variations",
"//components/variations/net",
"//components/variations/service",
"//components/version_info/android:channel_getter",
]
}
1 change: 1 addition & 0 deletions android_webview/browser/variations/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "android_webview/browser/aw_variations_service_client.h"
#include "android_webview/browser/variations/aw_variations_service_client.h"

#include "base/bind.h"
#include "base/threading/scoped_blocking_call.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ANDROID_WEBVIEW_BROWSER_AW_VARIATIONS_SERVICE_CLIENT_H_
#define ANDROID_WEBVIEW_BROWSER_AW_VARIATIONS_SERVICE_CLIENT_H_
#ifndef ANDROID_WEBVIEW_BROWSER_VARIATIONS_AW_VARIATIONS_SERVICE_CLIENT_H_
#define ANDROID_WEBVIEW_BROWSER_VARIATIONS_AW_VARIATIONS_SERVICE_CLIENT_H_

#include <string>

Expand Down Expand Up @@ -37,4 +37,4 @@ class AwVariationsServiceClient : public variations::VariationsServiceClient {

} // namespace android_webview

#endif // ANDROID_WEBVIEW_BROWSER_AW_VARIATIONS_SERVICE_CLIENT_H_
#endif // ANDROID_WEBVIEW_BROWSER_VARIATIONS_AW_VARIATIONS_SERVICE_CLIENT_H_
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <jni.h>
#include <string>

#include "android_webview/browser/variations_seed_loader.h"
#include "android_webview/browser/variations/variations_seed_loader.h"

#include "android_webview/browser_jni_headers/VariationsSeedLoader_jni.h"
#include "android_webview/proto/aw_variations_seed.pb.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ANDROID_WEBVIEW_BROWSER_VARIATIONS_SEED_LOADER_H_
#define ANDROID_WEBVIEW_BROWSER_VARIATIONS_SEED_LOADER_H_
#ifndef ANDROID_WEBVIEW_BROWSER_VARIATIONS_VARIATIONS_SEED_LOADER_H_
#define ANDROID_WEBVIEW_BROWSER_VARIATIONS_VARIATIONS_SEED_LOADER_H_

#include <memory>

Expand All @@ -15,4 +15,4 @@ std::unique_ptr<AwVariationsSeed> TakeSeed();

} // namespace android_webview

#endif // ANDROID_WEBVIEW_BROWSER_VARIATIONS_SEED_LOADER_H_
#endif // ANDROID_WEBVIEW_BROWSER_VARIATIONS_VARIATIONS_SEED_LOADER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
import org.chromium.android_webview.HttpAuthDatabase;
import org.chromium.android_webview.ProductConfig;
import org.chromium.android_webview.R;
import org.chromium.android_webview.VariationsSeedLoader;
import org.chromium.android_webview.WebViewChromiumRunQueue;
import org.chromium.android_webview.common.AwResource;
import org.chromium.android_webview.common.AwSwitches;
import org.chromium.android_webview.gfx.AwDrawFnImpl;
import org.chromium.android_webview.variations.VariationsSeedLoader;
import org.chromium.base.BuildConfig;
import org.chromium.base.BuildInfo;
import org.chromium.base.BundleUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file://android_webview/browser/variations/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file://android_webview/browser/variations/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.android_webview;
package org.chromium.android_webview.variations;

import android.content.ComponentName;
import android.content.Context;
Expand All @@ -18,6 +18,7 @@
import androidx.annotation.IntDef;
import androidx.annotation.VisibleForTesting;

import org.chromium.android_webview.AwBrowserProcess;
import org.chromium.android_webview.common.AwSwitches;
import org.chromium.android_webview.common.services.IVariationsSeedServer;
import org.chromium.android_webview.common.services.IVariationsSeedServerCallback;
Expand Down Expand Up @@ -292,16 +293,17 @@ public SeedServerConnection(ParcelFileDescriptor newSeedFd, long oldSeedDate) {

public void start() {
try {
if (!ContextUtils.getApplicationContext()
.bindService(getServerIntent(), this, Context.BIND_AUTO_CREATE)) {
if (!ContextUtils.getApplicationContext().bindService(
getServerIntent(), this, Context.BIND_AUTO_CREATE)) {
Log.e(TAG, "Failed to bind to WebView service");
}
// Connect to nonembedded metrics Service at the same time we connect to variation
// service.
AwBrowserProcess.collectNonembeddedMetrics();
} catch (NameNotFoundException e) {
Log.e(TAG, "WebView provider \"" + AwBrowserProcess.getWebViewPackageName() +
"\" not found!");
Log.e(TAG,
"WebView provider \"" + AwBrowserProcess.getWebViewPackageName()
+ "\" not found!");
}
}

Expand Down Expand Up @@ -389,8 +391,8 @@ protected void requestSeedFromService(long oldSeedDate) {
}
ParcelFileDescriptor newSeedFd = null;
try {
newSeedFd = ParcelFileDescriptor.open(
newSeedFile, ParcelFileDescriptor.MODE_WRITE_ONLY);
newSeedFd =
ParcelFileDescriptor.open(newSeedFile, ParcelFileDescriptor.MODE_WRITE_ONLY);
} catch (FileNotFoundException e) {
Log.e(TAG, "Failed to open seed file " + newSeedFile);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ per-file [email protected]
per-file [email protected]
per-file [email protected]
per-file [email protected]

# Variations
per-file AwVariationsSeedFetcherTest*=file://android_webview/browser/variations/OWNERS
per-file Variations*=file://android_webview/browser/variations/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import org.chromium.android_webview.VariationsSeedLoader;
import org.chromium.android_webview.common.AwSwitches;
import org.chromium.android_webview.common.variations.VariationsServiceMetricsHelper;
import org.chromium.android_webview.common.variations.VariationsUtils;
import org.chromium.android_webview.test.services.MockVariationsSeedServer;
import org.chromium.android_webview.test.util.VariationsTestUtils;
import org.chromium.android_webview.variations.VariationsSeedLoader;
import org.chromium.base.ContextUtils;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.util.CallbackHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import org.junit.runner.RunWith;

import org.chromium.android_webview.AwFeatureList;
import org.chromium.android_webview.VariationsSeedLoader;
import org.chromium.android_webview.common.AwFeatures;
import org.chromium.android_webview.common.variations.VariationsUtils;
import org.chromium.android_webview.test.util.VariationsTestUtils;
import org.chromium.android_webview.variations.VariationsSeedLoader;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.components.variations.StudyOuterClass.Study;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
file://android_webview/nonembedded/OWNERS

# Variations
per-file MockVariationsSeedServer*=file://android_webview/browser/variations/OWNERS
per-file VariationsSeedServerTest*=file://android_webview/browser/variations/OWNERS

0 comments on commit 8e5da69

Please sign in to comment.