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

Issue 2466863003: Finalize backend for fetching more NTPSnippets. (Closed)

Created:
4 years, 1 month ago by fhorschig
Modified:
4 years, 1 month ago
Reviewers:
tschumann, dgn
CC:
chromium-reviews, ntp-dev+reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Finalize backend for fetching more NTPSnippets. Taken over from https://codereview.chromium.org/2446163005/#ps60001 Addressed comments in that CL. BUG=634892

Patch Set 1 : Changed misplaces merges and typos. #

Patch Set 2 : Rename Callback #

Patch Set 3 : Known suggestion are now a parameter for Fetch. #

Total comments: 10
Unified diffs Side-by-side diffs Delta from patch set Stats (+111 lines, -72 lines) Patch
M components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h View 1 2 1 chunk +3 lines, -2 lines 3 comments Download
M components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc View 1 2 1 chunk +5 lines, -3 lines 0 comments Download
M components/ntp_snippets/content_suggestions_provider.h View 1 2 3 chunks +9 lines, -6 lines 0 comments Download
M components/ntp_snippets/content_suggestions_service.h View 1 2 2 chunks +4 lines, -2 lines 0 comments Download
M components/ntp_snippets/content_suggestions_service.cc View 1 2 1 chunk +5 lines, -3 lines 0 comments Download
M components/ntp_snippets/content_suggestions_service_unittest.cc View 1 2 2 chunks +7 lines, -5 lines 0 comments Download
M components/ntp_snippets/offline_pages/recent_tab_suggestions_provider.h View 1 2 1 chunk +3 lines, -2 lines 0 comments Download
M components/ntp_snippets/offline_pages/recent_tab_suggestions_provider.cc View 1 2 1 chunk +5 lines, -3 lines 0 comments Download
M components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.h View 1 2 1 chunk +3 lines, -2 lines 0 comments Download
M components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.cc View 1 2 1 chunk +4 lines, -3 lines 0 comments Download
M components/ntp_snippets/remote/ntp_snippets_service.h View 1 2 4 chunks +13 lines, -9 lines 0 comments Download
M components/ntp_snippets/remote/ntp_snippets_service.cc View 1 2 7 chunks +25 lines, -19 lines 5 comments Download
M components/ntp_snippets/remote/ntp_snippets_service_unittest.cc View 1 2 3 chunks +18 lines, -8 lines 2 comments Download
M components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.h View 1 2 1 chunk +3 lines, -2 lines 0 comments Download
M components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.cc View 1 2 1 chunk +4 lines, -3 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 15 (9 generated)
fhorschig
Hi Tim, could you please take a look at this CL and especially if the ...
4 years, 1 month ago (2016-11-02 05:11:24 UTC) #7
dgn
Can you please merge all the changes in a single review? if you try submitting ...
4 years, 1 month ago (2016-11-02 11:10:11 UTC) #9
dgn
I just realised that you made this one a fork of https://codereview.chromium.org/2421463002/. Can you just ...
4 years, 1 month ago (2016-11-02 11:18:07 UTC) #10
tschumann
@dgn: As Friedrich is not available, can you please have a closer look (also at ...
4 years, 1 month ago (2016-11-02 11:23:22 UTC) #11
dgn
https://codereview.chromium.org/2466863003/diff/120001/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h File components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h (right): https://codereview.chromium.org/2466863003/diff/120001/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h#newcode46 components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h:46: std::set<std::string> known_suggestion_ids, On 2016/11/02 11:23:22, tschumann wrote: > @dgn ...
4 years, 1 month ago (2016-11-02 12:04:33 UTC) #12
fhorschig
4 years, 1 month ago (2016-11-03 01:53:14 UTC) #15
Addressed all comments in the first CL:
https://codereview.chromium.org/2421463002/#ps200001

(This CL is no longer updated to avoid further confusion)

https://codereview.chromium.org/2466863003/diff/120001/components/ntp_snippet...
File components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h (right):

https://codereview.chromium.org/2466863003/diff/120001/components/ntp_snippet...
components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h:46:
std::set<std::string> known_suggestion_ids,
On 2016/11/02 12:04:33, dgn wrote:
> On 2016/11/02 11:23:22, tschumann wrote:
> > @dgn (to get quicker feedback as Friedrich is not available).
> > 
> > we should pass the ids per const reference. Any reason why we use per value
> and
> > rely on std::move().
> > The problem with per-value and std::move() is that if you forget std::move()
> > you'll make a copy without noticing *and* you have zombie-state data on the
> > caller side (moved-out variables). Their state is usually well defined with
> STL
> > data types, but accessing them rings a few alarm bells.
> 
> Yes, I also would prefer having const references rather than duplicating or
> moving things around manually. I see no specific reason why it is that way
> currently.

Done.

BTW: I used the ownership of the set to std::move all elements in
NTPSnippetService::CollectIdsToExclude() into another set. Now, the inserted
strings have to be copied. What I could have used is an rvalue-reference as
parameter but copying strings is rather cheap compared to accidentally copying
the whole set, so I will go with your solution.

https://codereview.chromium.org/2466863003/diff/120001/components/ntp_snippet...
File components/ntp_snippets/remote/ntp_snippets_service.cc (right):

https://codereview.chromium.org/2466863003/diff/120001/components/ntp_snippet...
components/ntp_snippets/remote/ntp_snippets_service.cc:330:
std::move(callback).Run(std::vector<ContentSuggestion>());
On 2016/11/02 12:04:33, dgn wrote:
> On 2016/11/02 11:10:11, dgn wrote:
> > why is std::move necessary here?
> 
> Okay, this is explained in
> https://chromium.googlesource.com/chromium/src/+/master/docs/callback.md
> 
> It still looks super dodgy to my untrained c++ eyes. Maybe add a comment to
> explain why this is WAI to not move it anywhere or wrap it in a method that
will
> have that explanation?

Thank you very much!
You discovered (maybe unwillingly) a potential bug: this callback used to be a
OnceCallback, but it isn't one any longer. So the outer move used to be
necessary but is ABSOLUTELY WRONG currently. I move it into an explaining
function as this construct will return in the near future.

https://codereview.chromium.org/2466863003/diff/120001/components/ntp_snippet...
components/ntp_snippets/remote/ntp_snippets_service.cc:640: FetchingCallback
fetched_more_callback,
On 2016/11/02 11:10:11, dgn wrote:
> Can this argument be a base::Optional<FetchingCallback> ? we don't care about
it
> if |fetched_more| is false, right? that would also avoid giving a dummy
callback
> as argument.

Done.

Yes. This whole set of parameters is planned to change when supporting
concurrent fetches (Bug 659931).

https://codereview.chromium.org/2466863003/diff/120001/components/ntp_snippet...
File components/ntp_snippets/remote/ntp_snippets_service_unittest.cc (right):

https://codereview.chromium.org/2466863003/diff/120001/components/ntp_snippet...
components/ntp_snippets/remote/ntp_snippets_service_unittest.cc:508:
std::set<std::string> known,
On 2016/11/02 11:10:11, dgn wrote:
> |known_ids| maybe? name is too unspecific as it is now.

Done.

Powered by Google App Engine
This is Rietveld 408576698