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

Issue 2619993002: ntp_tiles: Migrate to multi-observer model

Created:
3 years, 11 months ago by mastiz
Modified:
3 years, 11 months ago
Reviewers:
sfiera
CC:
chromium-reviews, skanuj+watch_chromium.org, melevin+watch_chromium.org, ntp-dev+reviews_chromium.org, pkl (ping after 24h if needed), donnd+watch_chromium.org, jfweitz+watch_chromium.org, David Black, samarth+watch_chromium.org, kmadhusu+watch_chromium.org, noyau+watch_chromium.org, Jered, sdefresne+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

ntp_tiles: Migrate to multi-observer model No behavioral changes except a subtle change affecting Finch metrics, described later below. The goal is to bring the component one step closer to becoming a service, where multiple observers will need to coexist. MostVisitedSites' API now replaces SetMostVisitedURLsObserver() with AddObserver()/RemoveObserver(). There are two important changes: 1. The maximum number of tiles is no longer specified, since each observer could have a different interest. Instead, clients are expected to truncate the tileset manually. 2. AddObserver() doesn't trigger a refresh. Instead, clients are expected to call Refresh() explicitly. Finch actives for Popular Sites studies will increase due to ShouldShowPopularSites() being called more often. This is because the component will internally always try to build a tileset of size 12 (and pull Popular Sites if enabled). This change might also have a performance impact (due to PopularSites::StartFetch). BUG=619584 WIP: to adopt multiobserver.

Patch Set 1 #

Patch Set 2 : Fixed build. #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+125 lines, -96 lines) Patch
M chrome/browser/android/ntp/most_visited_sites_bridge.cc View 6 chunks +19 lines, -6 lines 1 comment Download
M chrome/browser/search/instant_service.cc View 2 chunks +3 lines, -1 line 1 comment Download
M components/ntp_tiles/most_visited_sites.h View 6 chunks +12 lines, -12 lines 1 comment Download
M components/ntp_tiles/most_visited_sites.cc View 14 chunks +40 lines, -40 lines 0 comments Download
M components/ntp_tiles/most_visited_sites_unittest.cc View 6 chunks +24 lines, -22 lines 0 comments Download
M components/ntp_tiles/webui/ntp_tiles_internals_message_handler.h View 1 chunk +0 lines, -1 line 0 comments Download
M components/ntp_tiles/webui/ntp_tiles_internals_message_handler.cc View 3 chunks +5 lines, -3 lines 0 comments Download
M ios/chrome/browser/ui/ntp/google_landing_controller.mm View 1 5 chunks +22 lines, -11 lines 1 comment Download

Messages

Total messages: 12 (10 generated)
mastiz
I think this brings the component one step closer to becoming a service. Not a ...
3 years, 11 months ago (2017-01-10 15:18:49 UTC) #10
sfiera
3 years, 11 months ago (2017-01-18 09:58:33 UTC) #12
https://codereview.chromium.org/2619993002/diff/20001/chrome/browser/android/...
File chrome/browser/android/ntp/most_visited_sites_bridge.cc (right):

https://codereview.chromium.org/2619993002/diff/20001/chrome/browser/android/...
chrome/browser/android/ntp/most_visited_sites_bridge.cc:121:
java_observer_.reset(new JavaObserver(env, j_observer, num_sites));
Can we change JavaObserver to call {Add,Remove}Observer() in its
constructor/destructor? This would match the behavior of the ios implementation
(and if we choose one behavior, that one seems better than this one).

I think I would keep the Refresh() external, though (as it is in both places).

https://codereview.chromium.org/2619993002/diff/20001/chrome/browser/search/i...
File chrome/browser/search/instant_service.cc (right):

https://codereview.chromium.org/2619993002/diff/20001/chrome/browser/search/i...
chrome/browser/search/instant_service.cc:106:
most_visited_sites_->AddObserver(this);
Here, you're not doing any filtering to produce 8 tiles. I assume that means we
can provide >8 tiles to JS now. Have you tested this with the bing or yandex
NTPs?

https://codereview.chromium.org/2619993002/diff/20001/components/ntp_tiles/mo...
File components/ntp_tiles/most_visited_sites.h (right):

https://codereview.chromium.org/2619993002/diff/20001/components/ntp_tiles/mo...
components/ntp_tiles/most_visited_sites.h:112: // once the request completes.
This is now also necessary after every AddObserver() call, right? (there is no
way to get the current state, only updates)

https://codereview.chromium.org/2619993002/diff/20001/ios/chrome/browser/ui/n...
File ios/chrome/browser/ui/ntp/google_landing_controller.mm (right):

https://codereview.chromium.org/2619993002/diff/20001/ios/chrome/browser/ui/n...
ios/chrome/browser/ui/ntp/google_landing_controller.mm:1110: if
(_mostVisitedData.size() > kMaxNumMostVisitedFavicons)
We're resizing to save memory, but it's not related to the number of tiles we're
actually going to show, is it? I think it would be good to have a comment in
this function explaining that we might show fewer than _mostVisitedData.size()
tiles, and a TODO to correct the impressions metrics accordingly (ios will make
you create a bug for a TODO; P3/sfiera is OK).

Powered by Google App Engine
This is Rietveld 408576698