Skip to content

Commit

Permalink
[Merge to M101] [Topics] Implement BrowsingTopicsCalculator
Browse files Browse the repository at this point in the history
- Implement BrowsingTopicsCalculator. It’s responsible for doing a
one-off browsing topics calculation. The calculation will occur every 7
days. See the class comment for details.
- Rename “top_host” to “main_frame_host” to be more clear. This is fine
with database schema as well, as currently there’s no way to initialize
the database tables (even with feature flags).
- Let PageContentAnnotationsService::BatchAnnotatePageTopics accept the
hosts instead of GURL.
- Move GetModelInfoForType() to the PageContentAnnotator interface, so
that the model version can be mocked in tests as well.

Explainer: https://github.com/jkarlin/topics

Design doc:
https://docs.google.com/document/d/12UEo6PgeySUgEpkaAoawPjhjR0GSz-XhSOXSmrMxV6U

PoC CL:
https://chromium-review.googlesource.com/c/chromium/src/+/3416117

(cherry picked from commit c95d315)

Bug: 1294456
Change-Id: I13aba4d32a0e3377295f926a5ddb2168417d8c4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3511510
Reviewed-by: Josh Karlin <jkarlin@chromium.org>
Reviewed-by: Robert Ogden <robertogden@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Mark Pearson <mpearson@chromium.org>
Reviewed-by: Sophie Chang <sophiechang@chromium.org>
Reviewed-by: Christian Dullweber <dullweber@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Yao Xiao <yaoxia@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#982586}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3553239
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Yao Xiao <yaoxia@chromium.org>
Reviewed-by: Balazs Engedy <engedy@chromium.org>
Commit-Queue: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/branch-heads/4951@{#171}
Cr-Branched-From: 27de622-refs/heads/main@{#982481}
  • Loading branch information
yaoxiachromium authored and Chromium LUCI CQ committed Mar 28, 2022
1 parent b92fca8 commit 13b49f7
Show file tree
Hide file tree
Showing 40 changed files with 1,839 additions and 122 deletions.
Expand Up @@ -243,10 +243,10 @@ IN_PROC_BROWSER_TEST_F(PageContentAnnotationsServicePageTopicsBrowserTest,
run_loop->Quit();
},
&run_loop, &results),
std::vector<GURL>{
GURL("https://www.youtube.com/"),
GURL("https://www.chrome.com/"),
GURL("https://music.youtube.com/"),
std::vector<std::string>{
"youtube.com",
"chrome.com",
"music.youtube.com",
});
run_loop.Run();

Expand Down Expand Up @@ -497,7 +497,7 @@ IN_PROC_BROWSER_TEST_F(PageContentAnnotationsServiceBrowserTest,
run_loop->Quit();
},
&run_loop),
std::vector<GURL>{GURL("https://www.chromium.org")});
std::vector<std::string>{"www.chromium.org"});

run_loop.Run();
}
Expand Down
31 changes: 31 additions & 0 deletions components/browsing_topics/BUILD.gn
Expand Up @@ -4,6 +4,8 @@

source_set("browsing_topics") {
sources = [
"browsing_topics_calculator.cc",
"browsing_topics_calculator.h",
"browsing_topics_service.h",
"browsing_topics_service_impl.cc",
"browsing_topics_service_impl.h",
Expand All @@ -20,16 +22,33 @@ source_set("browsing_topics") {
deps = [
"//base",
"//components/browsing_topics/common:common",
"//components/history/content/browser",
"//components/history/core/browser",
"//components/keyed_service/core",
"//components/optimization_guide/content/browser",
"//components/privacy_sandbox",
"//content/public/browser",
"//crypto",
"//third_party/blink/public/common",
]
}

source_set("test_support") {
testonly = true
sources = [
"test_util.cc",
"test_util.h",
]

public_deps = [ "//base" ]

deps = [ ":browsing_topics" ]
}

source_set("unit_tests") {
testonly = true
sources = [
"browsing_topics_calculator_unittest.cc",
"browsing_topics_state_unittest.cc",
"epoch_topics_unittest.cc",
"topic_and_domains_unittest.cc",
Expand All @@ -38,9 +57,21 @@ source_set("unit_tests") {

deps = [
":browsing_topics",
":test_support",
"//base",
"//base/test:test_support",
"//components/content_settings/core/test:test_support",
"//components/history/core/browser:browser",
"//components/history/core/test",
"//components/optimization_guide/content/browser:browser",
"//components/optimization_guide/content/browser:test_support",
"//components/optimization_guide/core:test_support",
"//components/prefs:test_support",
"//components/privacy_sandbox:privacy_sandbox",
"//components/privacy_sandbox:privacy_sandbox_prefs",
"//components/privacy_sandbox:test_support",
"//components/sync_preferences:test_support",
"//content/test:test_support",
"//testing/gtest",
"//third_party/blink/public/common",
]
Expand Down
15 changes: 13 additions & 2 deletions components/browsing_topics/DEPS
@@ -1,6 +1,17 @@
include_rules = [
"+crypto",
"+third_party/blink/public/common",
"+components/history",
"+components/optimization_guide",
"+components/keyed_service",
"+components/privacy_sandbox",
"+content/public/browser",
"+content/public/test",
"+crypto",
"+third_party/blink/public/common",
]

specific_include_rules = {
".*_unittest.cc": [
"+components/content_settings/core",
"+components/sync_preferences",
],
}

0 comments on commit 13b49f7

Please sign in to comment.