|
|
Created:
3 years, 5 months ago by gcomanici Modified:
3 years, 4 months ago CC:
chromium-reviews, jdonnelly+watch_chromium.org, sdefresne+watchlist_chromium.org, droger+watchlist_chromium.org, asvitkine+watch_chromium.org, blundell+watchlist_chromium.org, zkoch1 Target Ref:
refs/heads/master Project:
chromium Visibility:
Public. |
DescriptionCreate a new class `ContextualSuggestionsService`
This class provides a service to fetch experimental contextual suggestions for the omnibox.
Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own class, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider.
Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort.
From a technical perspective, the new class is similar to SuggestionsService in componenents/suggestions. More functionality will soon be necessary on client side and all the corresponding logic will be handled by the ContextualSuggestionsService.
Design doc: https://docs.google.com/document/d/1FUowJo9AnSziiQfBumyicaTWDKjOcM574aOBwKIVpbU/edit#heading=h.xgjl2srtytjt
BUG=692471, 609084
Patch Set 1 : Initial component creation #
Total comments: 63
Patch Set 2 #
Total comments: 10
Patch Set 3 #
Total comments: 14
Patch Set 4 : Fix includes and the composition of the fetcher. #Patch Set 5 : Remove code duplication. #Patch Set 6 : Move contextual suggestions service to c/o/b #
Total comments: 53
Messages
Total messages: 45 (16 generated)
Patchset #1 (id:1) has been deleted
Patchset #1 (id:20001) has been deleted
Patchset #1 (id:40001) has been deleted
Description was changed from ========== Create a new component `contextual_suggestions`, which provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. The new component `contextual_suggestions` is a simplified version of `suggestions`. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the logic will be living in the new component. BUG=692471,609084 ========== to ========== Create a new component `contextual_suggestions`, which provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. The new component `contextual_suggestions` is a simplified version of `suggestions`. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the logic will be living in the new component. BUG=692471,609084 ==========
gcomanici@chromium.org changed reviewers: + treib@chromium.org
Hi Marc, Could you please take a look at the files in `components/contextual_suggestions` to make sure that I am understanding well the functionality that I am mimicking from `components/suggestions`? This CL is a bit larger, as it moves stuff from `c/o/b` to the new component, but I will get someone more familiar with that code to take a look at it later. Thanks! Gheorghe
This generally looks good; I've added a bunch of comments below. I mostly looked at the new component. I'm not super happy with the name "contextual_suggestions", since there are also plans to have (probably different) contextual suggestions in Chrome Home. But I don't really have a better suggestion (haha)... Description nit: Try to keep the first line <= 72 chars, since it'll become the git commit header. https://codereview.chromium.org/2965173002/diff/60001/chrome/browser/autocomp... File chrome/browser/autocomplete/contextual_suggestions_service_factory.h (right): https://codereview.chromium.org/2965173002/diff/60001/chrome/browser/autocomp... chrome/browser/autocomplete/contextual_suggestions_service_factory.h:1: // Copyright (c) 2017 The Chromium Authors. All rights reserved. nitty nit: no "(c)", see https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md... https://codereview.chromium.org/2965173002/diff/60001/chrome/browser/autocomp... chrome/browser/autocomplete/contextual_suggestions_service_factory.h:14: namespace contextual_suggestions { nit: I think this shouldn't be in the namespace - generally, only the code under components/ goes in the namespace. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/BUILD.gn (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/BUILD.gn:1: # Copyright 2014 The Chromium Authors. All rights reserved. 2017 https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/BUILD.gn:21: "//google_apis", Are all these actually needed (yet)? https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/DEPS (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/DEPS:10: "+url", Same here: Are these all needed? https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/OWNERS (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/OWNERS:1: gcomanici@chromium.org Only committers can be owners. Are you are committer already? https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/README (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/README:1: The Contextual Suggestions compoment provides utilities for fetching contextual s/compoment/component/ https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/contextual_suggestions_service.cc (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:53: return false; nit: add braces if the condition doesn't fit on one line https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:62: return false; Here too https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:81: // Skip this request is still waiting for oauth2 token. s/is/if/ ? https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:133: cookies_allowed: true Does this actually require cookies? If you're doing OAuth2 authentication, then presumably cookies aren't necessary? https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:148: if (!suggest_url.is_valid()) If this were the case, we shouldn't get here, right? If so, maybe just DCHECK that the URL is valid? https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:181: } nit: Other places in this file don't use braces for single-line bodies https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:185: std::move(callback).Run(std::move(fetcher)); Is it okay to just not call the callback if something went wrong? If that's the contract this service provides, then IMO that should be called out in a comment in the header. (It looks like the omnibox code expects to be called back with nullptr though?) https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/contextual_suggestions_service.h (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:6: #define COMPONENTS_CONTEXTUAL_SUGGESTIONS_SERVICE_H_ There should be an extra CONTEXTUAL_SUGGESTIONS_ here (one for the folder, one for the file name) https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:7: nit: include <string>, <memory> https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:9: #include "base/strings/stringprintf.h" Not needed I think? https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:24: extern const base::Feature kZeroSuggestRedirectToChrome; It's common practice to put features into a separate features.h file. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:41: // URL nit: weird line break https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:50: // |visited_url|, with |fetch_delegate| as the URLFetherDelegate that will s/fetch_delegate/fetcher_delegate/ s/URLFetherDelegate/URLFetcherDelegate/ https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:54: // executed with the result as a parameter. Sync or async? https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:59: // The function returns |false| if the service is suggest URL used to redirect Remove "service is"? (I don't understand this sentence) https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:69: static GURL ExperimentalZeroSuggestURL(const std::string visited_url); & https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:76: net::URLFetcherDelegate* fetcher_delegate); const? https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... File components/omnibox/browser/zero_suggest_provider.cc (right): https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... components/omnibox/browser/zero_suggest_provider.cc:163: // fether delagate. s/fether delagate/fetcher delegate/ https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... components/omnibox/browser/zero_suggest_provider.cc:168: base::Unretained(this))); Is Unretained() safe to use here? If so, please add a comment explaining why. If not, use a WeakPtr instead. https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... components/omnibox/browser/zero_suggest_provider.cc:193: // fetcher->Start(); ?
jdonnelly@chromium.org changed reviewers: + jdonnelly@chromium.org
Is there a design doc for this new component? Per go/newchromefeature*, any work crossing components (which a new component does by definition) should have a design doc sent out for review. Even if it's a simple one-pager, which is probably sufficient for your purposes. * In the Design docs section: https://docs.google.com/document/d/1eqxrys_EnlCvLDXWhMZOPBDmPEuSs9xgw7VZ_CW5l...
Thanks Marc! PTAL. https://codereview.chromium.org/2965173002/diff/60001/chrome/browser/autocomp... File chrome/browser/autocomplete/contextual_suggestions_service_factory.h (right): https://codereview.chromium.org/2965173002/diff/60001/chrome/browser/autocomp... chrome/browser/autocomplete/contextual_suggestions_service_factory.h:1: // Copyright (c) 2017 The Chromium Authors. All rights reserved. On 2017/07/06 08:32:19, Marc Treib wrote: > nitty nit: no "(c)", see > https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md... Done. https://codereview.chromium.org/2965173002/diff/60001/chrome/browser/autocomp... chrome/browser/autocomplete/contextual_suggestions_service_factory.h:14: namespace contextual_suggestions { On 2017/07/06 08:32:19, Marc Treib wrote: > nit: I think this shouldn't be in the namespace - generally, only the code under > components/ goes in the namespace. I removed it. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/BUILD.gn (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/BUILD.gn:1: # Copyright 2014 The Chromium Authors. All rights reserved. On 2017/07/06 08:32:20, Marc Treib wrote: > 2017 Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/BUILD.gn:21: "//google_apis", On 2017/07/06 08:32:20, Marc Treib wrote: > Are all these actually needed (yet)? I am not very familiar with BUILD.gn files, so I added these dependencies based on the imports that I made in the sources. Is there a better approach at making sure that this list is as small as possible? If there's a link you are aware of, please share. Thanks! https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/DEPS (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/DEPS:10: "+url", On 2017/07/06 08:32:20, Marc Treib wrote: > Same here: Are these all needed? See my comment in BUILD.gn. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/OWNERS (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/OWNERS:1: gcomanici@chromium.org On 2017/07/06 08:32:20, Marc Treib wrote: > Only committers can be owners. Are you are committer already? No, I am not. :) Removed. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/README (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/README:1: The Contextual Suggestions compoment provides utilities for fetching contextual On 2017/07/06 08:32:20, Marc Treib wrote: > s/compoment/component/ Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/contextual_suggestions_service.cc (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:53: return false; On 2017/07/06 08:32:20, Marc Treib wrote: > nit: add braces if the condition doesn't fit on one line Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:62: return false; On 2017/07/06 08:32:20, Marc Treib wrote: > Here too Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:81: // Skip this request is still waiting for oauth2 token. On 2017/07/06 08:32:20, Marc Treib wrote: > s/is/if/ ? Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:133: cookies_allowed: true On 2017/07/06 08:32:20, Marc Treib wrote: > Does this actually require cookies? If you're doing OAuth2 authentication, then > presumably cookies aren't necessary? Good point. I was using the same annotation tag as before, but indeed cookies are no longer needed. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:148: if (!suggest_url.is_valid()) On 2017/07/06 08:32:20, Marc Treib wrote: > If this were the case, we shouldn't get here, right? If so, maybe just DCHECK > that the URL is valid? Added a DCHECK. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:181: } On 2017/07/06 08:32:20, Marc Treib wrote: > nit: Other places in this file don't use braces for single-line bodies I chanced the other places for consistency. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:185: std::move(callback).Run(std::move(fetcher)); On 2017/07/06 08:32:20, Marc Treib wrote: > Is it okay to just not call the callback if something went wrong? If that's the > contract this service provides, then IMO that should be called out in a comment > in the header. > (It looks like the omnibox code expects to be called back with nullptr though?) I changed the description and signature for CreateContextualSuggestionsRequest. Indeed the callback is called synchronously either when an error is encountered (with nullptr) or after the fetcher is properly built. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/contextual_suggestions_service.h (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:6: #define COMPONENTS_CONTEXTUAL_SUGGESTIONS_SERVICE_H_ On 2017/07/06 08:32:20, Marc Treib wrote: > There should be an extra CONTEXTUAL_SUGGESTIONS_ here (one for the folder, one > for the file name) Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:7: On 2017/07/06 08:32:21, Marc Treib wrote: > nit: include <string>, <memory> Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:9: #include "base/strings/stringprintf.h" On 2017/07/06 08:32:20, Marc Treib wrote: > Not needed I think? Removed. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:24: extern const base::Feature kZeroSuggestRedirectToChrome; On 2017/07/06 08:32:21, Marc Treib wrote: > It's common practice to put features into a separate features.h file. Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:41: // URL On 2017/07/06 08:32:21, Marc Treib wrote: > nit: weird line break Fixed. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:50: // |visited_url|, with |fetch_delegate| as the URLFetherDelegate that will On 2017/07/06 08:32:20, Marc Treib wrote: > s/fetch_delegate/fetcher_delegate/ > s/URLFetherDelegate/URLFetcherDelegate/ Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:54: // executed with the result as a parameter. On 2017/07/06 08:32:21, Marc Treib wrote: > Sync or async? sync. I changed the comments to make this clear. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:59: // The function returns |false| if the service is suggest URL used to redirect On 2017/07/06 08:32:20, Marc Treib wrote: > Remove "service is"? (I don't understand this sentence) I changed the statement to make it more clear. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:69: static GURL ExperimentalZeroSuggestURL(const std::string visited_url); On 2017/07/06 08:32:21, Marc Treib wrote: > & Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:76: net::URLFetcherDelegate* fetcher_delegate); On 2017/07/06 08:32:21, Marc Treib wrote: > const? Added const. https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... File components/omnibox/browser/zero_suggest_provider.cc (right): https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... components/omnibox/browser/zero_suggest_provider.cc:163: // fether delagate. On 2017/07/06 08:32:21, Marc Treib wrote: > s/fether delagate/fetcher delegate/ Done. https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... components/omnibox/browser/zero_suggest_provider.cc:168: base::Unretained(this))); On 2017/07/06 08:32:21, Marc Treib wrote: > Is Unretained() safe to use here? If so, please add a comment explaining why. If > not, use a WeakPtr instead. I am not sure how to answer your question, so I will go with WeakPtr instead to be safe. https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... components/omnibox/browser/zero_suggest_provider.cc:193: // fetcher->Start(); On 2017/07/06 08:32:21, Marc Treib wrote: > ? Removed.
On 2017/07/06 14:16:24, Justin Donnelly wrote: > Is there a design doc for this new component? Per go/newchromefeature*, any work > crossing components (which a new component does by definition) should have a > design doc sent out for review. Even if it's a simple one-pager, which is > probably sufficient for your purposes. > > * In the Design docs section: > https://docs.google.com/document/d/1eqxrys_EnlCvLDXWhMZOPBDmPEuSs9xgw7VZ_CW5l... Hi Justin, That's a very good point. Since the feature is not new (see https://docs.google.com/a/google.com/document/d/1ATAbcfUwqmEvGJRylUYqOFUDVpvP...) we already have a design doc. Still, it does not include the creation of this new component. I will add a new section with more details on the new component and I will add it to the CL description.
Description was changed from ========== Create a new component `contextual_suggestions`, which provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. The new component `contextual_suggestions` is a simplified version of `suggestions`. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the logic will be living in the new component. BUG=692471,609084 ========== to ========== Create a new component `contextual_suggestions`, which provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. The new component `contextual_suggestions` is a simplified version of `suggestions`. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the logic will be living in the new component. Design doc: https://docs.google.com/a/google.com/document/d/1ATAbcfUwqmEvGJRylUYqOFUDVpvP... BUG=692471,609084 ==========
gcomanici@chromium.org changed reviewers: + mpearson@chromium.org
First description line is still too long. Mostly looks good to me now, a few more comments below. You'll have to get a /components/ owner to approve this though. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/BUILD.gn (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/BUILD.gn:21: "//google_apis", On 2017/07/06 15:34:17, gcomanici wrote: > On 2017/07/06 08:32:20, Marc Treib wrote: > > Are all these actually needed (yet)? > > I am not very familiar with BUILD.gn files, so I added these dependencies based > on the imports that I made in the sources. Is there a better approach at making > sure that this list is as small as possible? If there's a link you are aware of, > please share. Thanks! No, I'm not aware of a better approach. I was mostly checking that these weren't just copied from components/suggestions :) https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/contextual_suggestions_service.cc (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:133: cookies_allowed: true On 2017/07/06 15:34:17, gcomanici wrote: > On 2017/07/06 08:32:20, Marc Treib wrote: > > Does this actually require cookies? If you're doing OAuth2 authentication, > then > > presumably cookies aren't necessary? > > Good point. I was using the same annotation tag as before, but indeed cookies > are no longer needed. Ah, but then you also need to set net::LOAD_DO_NOT_SEND_COOKIES below. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:148: if (!suggest_url.is_valid()) On 2017/07/06 15:34:18, gcomanici wrote: > On 2017/07/06 08:32:20, Marc Treib wrote: > > If this were the case, we shouldn't get here, right? If so, maybe just DCHECK > > that the URL is valid? > > Added a DCHECK. It's the wrong way around though ;) https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/contextual_suggestions_service.h (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:54: // executed with the result as a parameter. On 2017/07/06 15:34:18, gcomanici wrote: > On 2017/07/06 08:32:21, Marc Treib wrote: > > Sync or async? > > sync. I changed the comments to make this clear. No, I don't think that's correct. There are some error cases where it's sync, but fetching the access token is async. So if you get to the point of trying to get an access token, then it'll be async. https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... File components/omnibox/browser/zero_suggest_provider.cc (right): https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... components/omnibox/browser/zero_suggest_provider.cc:168: base::Unretained(this))); On 2017/07/06 15:34:19, gcomanici wrote: > On 2017/07/06 08:32:21, Marc Treib wrote: > > Is Unretained() safe to use here? If so, please add a comment explaining why. > If > > not, use a WeakPtr instead. > > I am not sure how to answer your question, so I will go with WeakPtr instead to > be safe. Unretained is only safe if you're absolutely sure that the callback won't be called after "this" has been destroyed. Maybe that's the case here, I can't tell, but anyway weakptr doesn't hurt. https://codereview.chromium.org/2965173002/diff/80001/chrome/browser/autocomp... File chrome/browser/autocomplete/contextual_suggestions_service_factory.h (right): https://codereview.chromium.org/2965173002/diff/80001/chrome/browser/autocomp... chrome/browser/autocomplete/contextual_suggestions_service_factory.h:17: } // namespace contextual_suggestions https://codereview.chromium.org/2965173002/diff/80001/components/contextual_s... File components/contextual_suggestions/contextual_suggestions_service.h (right): https://codereview.chromium.org/2965173002/diff/80001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:53: // * The service is already waiting for an authenticaiton token. s/authenticaiton/authentication/ https://codereview.chromium.org/2965173002/diff/80001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:66: // Creates an HTTTP Get request for experimental contextual suggestions. The s/HTTTP/HTTP/ https://codereview.chromium.org/2965173002/diff/80001/components/contextual_s... File components/contextual_suggestions/features.h (right): https://codereview.chromium.org/2965173002/diff/80001/components/contextual_s... components/contextual_suggestions/features.h:11: optional: Many places use a sub-namespace "features" for this. https://codereview.chromium.org/2965173002/diff/80001/components/omnibox/brow... File components/omnibox/browser/zero_suggest_provider.cc (right): https://codereview.chromium.org/2965173002/diff/80001/components/omnibox/brow... components/omnibox/browser/zero_suggest_provider.cc:199: LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); Is this change intended?
Description was changed from ========== Create a new component `contextual_suggestions`, which provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. The new component `contextual_suggestions` is a simplified version of `suggestions`. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the logic will be living in the new component. Design doc: https://docs.google.com/a/google.com/document/d/1ATAbcfUwqmEvGJRylUYqOFUDVpvP... BUG=692471,609084 ========== to ========== Create a new component `contextual_suggestions` This component provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. The new component `contextual_suggestions` is a simplified version of `suggestions`. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the logic will be living in the new component. Design doc: https://docs.google.com/a/google.com/document/d/1ATAbcfUwqmEvGJRylUYqOFUDVpvP... BUG=692471,609084 ==========
Patchset #3 (id:100001) has been deleted
Thanks Marc for the careful review :) I changed the subject of the CL, as you suggested. I also forgot to reply to your comment on the name of the component. I am not 100% happy with the name. I want to get mpearson's opinion on what would be best. I still prefer `contextual_suggestions` as we are interested in providing contextual suggestions more than just as zero suggest suggestions. It would be great to join efforts with the people that are working on adding contextual suggestions to Chrome Home in this regard. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/contextual_suggestions_service.cc (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:133: cookies_allowed: true On 2017/07/06 16:02:45, Marc Treib wrote: > On 2017/07/06 15:34:17, gcomanici wrote: > > On 2017/07/06 08:32:20, Marc Treib wrote: > > > Does this actually require cookies? If you're doing OAuth2 authentication, > > then > > > presumably cookies aren't necessary? > > > > Good point. I was using the same annotation tag as before, but indeed cookies > > are no longer needed. > > Ah, but then you also need to set net::LOAD_DO_NOT_SEND_COOKIES below. Done. https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.cc:148: if (!suggest_url.is_valid()) On 2017/07/06 16:02:45, Marc Treib wrote: > On 2017/07/06 15:34:18, gcomanici wrote: > > On 2017/07/06 08:32:20, Marc Treib wrote: > > > If this were the case, we shouldn't get here, right? If so, maybe just > DCHECK > > > that the URL is valid? > > > > Added a DCHECK. > > It's the wrong way around though ;) Fixed :) https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... File components/contextual_suggestions/contextual_suggestions_service.h (right): https://codereview.chromium.org/2965173002/diff/60001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:54: // executed with the result as a parameter. On 2017/07/06 16:02:45, Marc Treib wrote: > On 2017/07/06 15:34:18, gcomanici wrote: > > On 2017/07/06 08:32:21, Marc Treib wrote: > > > Sync or async? > > > > sync. I changed the comments to make this clear. > > No, I don't think that's correct. There are some error cases where it's sync, > but fetching the access token is async. So if you get to the point of trying to > get an access token, then it'll be async. You are right. I made the comment a bit more explicit in that regard. PTAL. https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... File components/omnibox/browser/zero_suggest_provider.cc (right): https://codereview.chromium.org/2965173002/diff/60001/components/omnibox/brow... components/omnibox/browser/zero_suggest_provider.cc:168: base::Unretained(this))); On 2017/07/06 16:02:45, Marc Treib wrote: > On 2017/07/06 15:34:19, gcomanici wrote: > > On 2017/07/06 08:32:21, Marc Treib wrote: > > > Is Unretained() safe to use here? If so, please add a comment explaining > why. > > If > > > not, use a WeakPtr instead. > > > > I am not sure how to answer your question, so I will go with WeakPtr instead > to > > be safe. > > Unretained is only safe if you're absolutely sure that the callback won't be > called after "this" has been destroyed. Maybe that's the case here, I can't > tell, but anyway weakptr doesn't hurt. Thanks. Indeed, we should go with weakptr. https://codereview.chromium.org/2965173002/diff/80001/chrome/browser/autocomp... File chrome/browser/autocomplete/contextual_suggestions_service_factory.h (right): https://codereview.chromium.org/2965173002/diff/80001/chrome/browser/autocomp... chrome/browser/autocomplete/contextual_suggestions_service_factory.h:17: } On 2017/07/06 16:02:46, Marc Treib wrote: > // namespace contextual_suggestions Done. https://codereview.chromium.org/2965173002/diff/80001/components/contextual_s... File components/contextual_suggestions/contextual_suggestions_service.h (right): https://codereview.chromium.org/2965173002/diff/80001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:53: // * The service is already waiting for an authenticaiton token. On 2017/07/06 16:02:46, Marc Treib wrote: > s/authenticaiton/authentication/ Done. https://codereview.chromium.org/2965173002/diff/80001/components/contextual_s... components/contextual_suggestions/contextual_suggestions_service.h:66: // Creates an HTTTP Get request for experimental contextual suggestions. The On 2017/07/06 16:02:46, Marc Treib wrote: > s/HTTTP/HTTP/ Done. https://codereview.chromium.org/2965173002/diff/80001/components/contextual_s... File components/contextual_suggestions/features.h (right): https://codereview.chromium.org/2965173002/diff/80001/components/contextual_s... components/contextual_suggestions/features.h:11: On 2017/07/06 16:02:46, Marc Treib wrote: > optional: Many places use a sub-namespace "features" for this. Done. https://codereview.chromium.org/2965173002/diff/80001/components/omnibox/brow... File components/omnibox/browser/zero_suggest_provider.cc (right): https://codereview.chromium.org/2965173002/diff/80001/components/omnibox/brow... components/omnibox/browser/zero_suggest_provider.cc:199: LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); On 2017/07/06 16:02:46, Marc Treib wrote: > Is this change intended? Yes. I forgot to add it before. It is quite important for out UMA metrics. We were getting it for free in the previous version of zero_suggest_provider.cc, but now I have to add it in this function.
LGTM (but again, you'll have to get an owner to approve this) markusheintz@ is a good contact person for the contextual suggestions in Chrome Home. I'm not completely up to date with the current efforts there, but I do know that a working end-to-end prototype exists already.
On 2017/07/06 15:41:44, gcomanici wrote: > On 2017/07/06 14:16:24, Justin Donnelly wrote: > > Is there a design doc for this new component? Per go/newchromefeature*, any > work > > crossing components (which a new component does by definition) should have a > > design doc sent out for review. Even if it's a simple one-pager, which is > > probably sufficient for your purposes. > > > > * In the Design docs section: > > > https://docs.google.com/document/d/1eqxrys_EnlCvLDXWhMZOPBDmPEuSs9xgw7VZ_CW5l... > > Hi Justin, > > That's a very good point. Since the feature is not new (see > https://docs.google.com/a/google.com/document/d/1ATAbcfUwqmEvGJRylUYqOFUDVpvP...) > we already have a design doc. Still, it does not include the creation of this > new component. I will add a new section with more details on the new component > and I will add it to the CL description. Thanks. Can you also send to chrome-design-docs@? I'd say a new component for this purpose seems reasonable but I pause at your statement, "The two components are providing very similar services". Why not use components/suggestions then? The fact that this is a simplified version of what's there doesn't seem on its own a compelling enough reason for a new component.
Description was changed from ========== Create a new component `contextual_suggestions` This component provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. The new component `contextual_suggestions` is a simplified version of `suggestions`. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the logic will be living in the new component. Design doc: https://docs.google.com/a/google.com/document/d/1ATAbcfUwqmEvGJRylUYqOFUDVpvP... BUG=692471,609084 ========== to ========== Create a new component `contextual_suggestions` This component provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. From a technical perspective, the new component `contextual_suggestions` is very similar to the `suggestions` component. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the corresponding logic will be living in the new component. Design doc: https://docs.google.com/a/google.com/document/d/1ATAbcfUwqmEvGJRylUYqOFUDVpvP... BUG=692471,609084 ==========
On 2017/07/06 17:06:37, Justin Donnelly wrote: > On 2017/07/06 15:41:44, gcomanici wrote: > > On 2017/07/06 14:16:24, Justin Donnelly wrote: > > > Is there a design doc for this new component? Per go/newchromefeature*, any > > work > > > crossing components (which a new component does by definition) should have a > > > design doc sent out for review. Even if it's a simple one-pager, which is > > > probably sufficient for your purposes. > > > > > > * In the Design docs section: > > > > > > https://docs.google.com/document/d/1eqxrys_EnlCvLDXWhMZOPBDmPEuSs9xgw7VZ_CW5l... > > > > Hi Justin, > > > > That's a very good point. Since the feature is not new (see > > > https://docs.google.com/a/google.com/document/d/1ATAbcfUwqmEvGJRylUYqOFUDVpvP...) > > we already have a design doc. Still, it does not include the creation of this > > new component. I will add a new section with more details on the new component > > and I will add it to the CL description. > > Thanks. Can you also send to chrome-design-docs@? I'd say a new component for > this purpose seems reasonable but I pause at your statement, "The two components > are providing very similar services". Why not use components/suggestions then? > The fact that this is a simplified version of what's there doesn't seem on its > own a compelling enough reason for a new component. @jdonnelly WRT the design doc: the feature already passed through all necessary reviews (crbug.com/692471). This CL is simply moving most of the related logic outside of components/omnibox/browser, as the previous implementations was a hack and was intended to be a short term solution. For various reasons, it seems that we will have to live with this fetcher for more than expected, hence the component creation. WRT components/suggestions: I should have been a bit more clear in that paragraph describing the similarity to `suggestions`. The similarity I am talking about is from a technical perspective. Ultimately, they generate different requests to different backends. The biggest difference is that for the new component the fetch response is processed by ZeroSuggestProvider (see ZeroSuggestProvider::OnURLFetchComplete), whereas the component/suggestions is processing the request directly (see SuggestionsServiceImpl::OnURLFetchComplete). Maybe this dependence on ZeroSuggestProvider could be eliminated in the future, but I think having a new component is the right solution for now.
Description was changed from ========== Create a new component `contextual_suggestions` This component provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. From a technical perspective, the new component `contextual_suggestions` is very similar to the `suggestions` component. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the corresponding logic will be living in the new component. Design doc: https://docs.google.com/a/google.com/document/d/1ATAbcfUwqmEvGJRylUYqOFUDVpvP... BUG=692471,609084 ========== to ========== Create a new component `contextual_suggestions` This component provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. From a technical perspective, the new component `contextual_suggestions` is very similar to the `suggestions` component. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the corresponding logic will be living in the new component. Design doc: https://docs.google.com/document/d/1FUowJo9AnSziiQfBumyicaTWDKjOcM574aOBwKIVp... BUG=692471,609084 ==========
On 2017/07/06 17:55:39, gcomanici wrote: > WRT the design doc: the feature already passed through all necessary reviews > (crbug.com/692471). This CL is simply moving most of the related logic outside > of components/omnibox/browser, as the previous implementations was a hack and > was intended to be a short term solution. For various reasons, it seems that we > will have to live with this fetcher for more than expected, hence the component > creation. Understood that the feature design went through the review process. But the introduction of a new component obviously didn't since you just added it to your design doc. I know it sounds like I'm trying to throw more process onto you unnecessarily. But I'm more just trying to give you heads up that when I introduced a new component recently I was directed to run that through chrome-design-docs@. Given that this is pretty straightforward, I doubt you'd encounter much friction. If you got any feedback at all other than lgtm it might even be helpful advice for how you structure your code going forward. But since you need a components OWNERS review of this CL anyway, I'll leave it to them to decide whether that's strictly necessary. > WRT components/suggestions: I should have been a bit more clear in that > paragraph describing the similarity to `suggestions`. The similarity I am > talking about is from a technical perspective. Ultimately, they generate > different requests to different backends. The biggest difference is that for the > new component the fetch response is processed by ZeroSuggestProvider (see > ZeroSuggestProvider::OnURLFetchComplete), whereas the component/suggestions is > processing the request directly (see > SuggestionsServiceImpl::OnURLFetchComplete). Maybe this dependence on > ZeroSuggestProvider could be eliminated in the future, but I think having a new > component is the right solution for now. Thanks for the explanation. And given that there are currently no DEPS between the two components in this change then keeping them separate sounds appropriate. But if you ever find one depending on the other because they need some similar parsing code or data models or something, then you may want to reconsider at that point.
gcomanici@chromium.org changed reviewers: + blundell@chromium.org
Hi Colin, Can you take a look for an OWNERS's review? We discussed in a different thread a bit about the main reason behind this new component. Please see here for more details. Thanks! Gheorghe
A gave this a quick, haphazard review. I have two main questions / concerns about this design: - it looks like a sizable chunk of code is being duplicated between components/omnibox/ and this new component. Can we refactor the code so that all suggest requests go through the same flow so the code is not duplicated? After all, the regular suggest flow also needs cookies attached to it; it just gets that for free right now. - is a new component the right place for this? I'm nervous about new components, especially ones that are only used for experimental features. Relatedly, does the component align with component layering design? Both of these questions are best answered by a primary component/ owner and/or a chrome design doc reviewer. I know I cannot answer them, as I periodically try to include a component in another and am told, no, no, no. :-) --mark https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... File chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc (right): https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc:130: contextual_suggestions::ContextualSuggestionsService* #include the file that gives you contextual_suggestions::ContextualSuggestionsService explicitly https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... File chrome/browser/autocomplete/chrome_autocomplete_provider_client.h (right): https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... chrome/browser/autocomplete/chrome_autocomplete_provider_client.h:11: #include "components/contextual_suggestions/contextual_suggestions_service.h" No need to add this here; you get it from the parent class. https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... File components/contextual_suggestions/contextual_suggestions_service.cc (right): https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... components/contextual_suggestions/contextual_suggestions_service.cc:119: I'm a bit bothered that the whole rest of this file is (nearly) a duplicate of code in components/omnibox/... https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... components/contextual_suggestions/contextual_suggestions_service.cc:124: net::DefineNetworkTrafficAnnotation("omnibox_contextual_zerosuggest", R"( Not sure if you should be using a new annotation here or not. https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... components/contextual_suggestions/contextual_suggestions_service.cc:161: fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | Are you sure you want to set this flag? https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... File components/omnibox/browser/autocomplete_provider_client.h (right): https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... components/omnibox/browser/autocomplete_provider_client.h:12: #include "components/contextual_suggestions/contextual_suggestions_service.h" forward declare; don't include https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... File components/omnibox/browser/zero_suggest_provider.cc (right): https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... components/omnibox/browser/zero_suggest_provider.cc:162: // Create a request for experimental suggestions with |this| as the bug: probably want to set done_ = false here.
On 2017/07/07 20:13:55, Mark P wrote: > A gave this a quick, haphazard review. I have two main questions / concerns > about this design: > > - it looks like a sizable chunk of code is being duplicated between > components/omnibox/ and this new component. Can we refactor the code so that > all suggest requests go through the same flow so the code is not duplicated? > After all, the regular suggest flow also needs cookies attached to it; it just > gets that for free right now. I responded to a similar comment you made in the code. I am all for refactoring the code, but I'd leave it for a different CL, if you don't mind. > > - is a new component the right place for this? I'm nervous about new > components, especially ones that are only used for experimental features. This is related to your other comment. Much like `components/suggestions`, the logic of fetching contextual suggestions from a remote server should live in its own component. This should not only include the logic used to fetch suggestions from a backend, but also the creation of the context. Indeed, currently the URL visited by the user and the oauth token are defining the context, but there is no reason to stop there (e.g. the last visited URL when on chrome://newtab, the last 5 visited urls etc.). It will definitely make it easier to maintain and to iterate in our experiments if all code related to this experimental feature is separate from its current client (i.e. the omnibox). > Relatedly, does the component align with component layering design? Both of > these questions are best answered by a primary component/ owner and/or a chrome > design doc reviewer. I know I cannot answer them, as I periodically try to > include a component in another and am told, no, no, no. :-) > > --mark > > https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... > File chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc (right): > > https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... > chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc:130: > contextual_suggestions::ContextualSuggestionsService* > #include the file that gives you > contextual_suggestions::ContextualSuggestionsService explicitly > > https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... > File chrome/browser/autocomplete/chrome_autocomplete_provider_client.h (right): > > https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... > chrome/browser/autocomplete/chrome_autocomplete_provider_client.h:11: #include > "components/contextual_suggestions/contextual_suggestions_service.h" > No need to add this here; you get it from the parent class. > > https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... > File components/contextual_suggestions/contextual_suggestions_service.cc > (right): > > https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... > components/contextual_suggestions/contextual_suggestions_service.cc:119: > I'm a bit bothered that the whole rest of this file is (nearly) a duplicate of > code in components/omnibox/... > > https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... > components/contextual_suggestions/contextual_suggestions_service.cc:124: > net::DefineNetworkTrafficAnnotation("omnibox_contextual_zerosuggest", R"( > Not sure if you should be using a new annotation here or not. > > https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... > components/contextual_suggestions/contextual_suggestions_service.cc:161: > fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | > Are you sure you want to set this flag? > > https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... > File components/omnibox/browser/autocomplete_provider_client.h (right): > > https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... > components/omnibox/browser/autocomplete_provider_client.h:12: #include > "components/contextual_suggestions/contextual_suggestions_service.h" > forward declare; don't include > > https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... > File components/omnibox/browser/zero_suggest_provider.cc (right): > > https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... > components/omnibox/browser/zero_suggest_provider.cc:162: // Create a request for > experimental suggestions with |this| as the > bug: probably want to set done_ = false here.
https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... File chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc (right): https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc:130: contextual_suggestions::ContextualSuggestionsService* On 2017/07/07 20:13:54, Mark P wrote: > #include the file that gives you > contextual_suggestions::ContextualSuggestionsService explicitly Done. https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... File chrome/browser/autocomplete/chrome_autocomplete_provider_client.h (right): https://codereview.chromium.org/2965173002/diff/120001/chrome/browser/autocom... chrome/browser/autocomplete/chrome_autocomplete_provider_client.h:11: #include "components/contextual_suggestions/contextual_suggestions_service.h" On 2017/07/07 20:13:54, Mark P wrote: > No need to add this here; you get it from the parent class. Removed. https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... File components/contextual_suggestions/contextual_suggestions_service.cc (right): https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... components/contextual_suggestions/contextual_suggestions_service.cc:119: On 2017/07/07 20:13:54, Mark P wrote: > I'm a bit bothered that the whole rest of this file is (nearly) a duplicate of > code in components/omnibox/... I share the feeling with you and I am willing to move the whole networking logic from components/omnibox here. I feel, though, that this CL is already large enough. If you don't mind, I can file a bug and deal with it later. The main purpose of this CL is to make sure that our backend gets the oauth token. I will deal with refactoring after. https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... components/contextual_suggestions/contextual_suggestions_service.cc:124: net::DefineNetworkTrafficAnnotation("omnibox_contextual_zerosuggest", R"( On 2017/07/07 20:13:54, Mark P wrote: > Not sure if you should be using a new annotation here or not. The annotation is different though. First, it sends "The user's OAuth2 credentials" along with the visited URL. Second, it does not allow cookies. Note that I also removed all the info/headers that our backend is not using. I am not familiar with the use of network traffic annotations, so I can't speak on whether a different annotation is a must or not, but the semantics and the policies are slightly different. https://codereview.chromium.org/2965173002/diff/120001/components/contextual_... components/contextual_suggestions/contextual_suggestions_service.cc:161: fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | On 2017/07/07 20:13:54, Mark P wrote: > Are you sure you want to set this flag? The request sends the oauth token. As such, there is no need to send cookies. https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... File components/omnibox/browser/autocomplete_provider_client.h (right): https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... components/omnibox/browser/autocomplete_provider_client.h:12: #include "components/contextual_suggestions/contextual_suggestions_service.h" On 2017/07/07 20:13:54, Mark P wrote: > forward declare; don't include Done. https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... File components/omnibox/browser/zero_suggest_provider.cc (right): https://codereview.chromium.org/2965173002/diff/120001/components/omnibox/bro... components/omnibox/browser/zero_suggest_provider.cc:162: // Create a request for experimental suggestions with |this| as the On 2017/07/07 20:13:54, Mark P wrote: > bug: probably want to set done_ = false here. I am setting it in the callback function (see ZeroSuggestProvider::OnContextualSuggestionsFetcherAvailable below). Unless I am mistaken, done_ keeps track of whether fetching is done. I would rather set it to false only when I start fetching. Here, I am only creating a request with OnContextualSuggestionsFetcherAvailable as a callback.
On 2017/07/07 21:24:29, gcomanici wrote: > On 2017/07/07 20:13:55, Mark P wrote: > > A gave this a quick, haphazard review. I have two main questions / concerns > > about this design: > > > > - it looks like a sizable chunk of code is being duplicated between > > components/omnibox/ and this new component. Can we refactor the code so that > > all suggest requests go through the same flow so the code is not duplicated? > > After all, the regular suggest flow also needs cookies attached to it; it just > > gets that for free right now. > > I responded to a similar comment you made in the code. I am all for refactoring > the code, but I'd leave it for a different CL, if you don't mind. Can you check how much the binary size increases with this new component? People are working to shave, say, things the size of 200k of memory on Android. If the code duplication here comes to even a fraction of that, it's worth fixing it before submitting. Client-side code has different priorities than server-side ones. :-) --mark
On 2017/07/07 23:55:43, Mark P wrote: > On 2017/07/07 21:24:29, gcomanici wrote: > > On 2017/07/07 20:13:55, Mark P wrote: > > > A gave this a quick, haphazard review. I have two main questions / concerns > > > about this design: > > > > > > - it looks like a sizable chunk of code is being duplicated between > > > components/omnibox/ and this new component. Can we refactor the code so > that > > > all suggest requests go through the same flow so the code is not duplicated? > > > > After all, the regular suggest flow also needs cookies attached to it; it > just > > > gets that for free right now. > > > > I responded to a similar comment you made in the code. I am all for > refactoring > > the code, but I'd leave it for a different CL, if you don't mind. > > Can you check how much the binary size increases with this new component? > People are working to shave, say, things the size of 200k of memory on Android. > If the code duplication here comes to even a fraction of that, it's worth fixing > it before submitting. > > Client-side code has different priorities than server-side ones. :-) > > --mark Given the concerns on duplication between //components/{omnibox, suggestions} and the new component, I'm hesitant to LG the addition of the new component as the discussion currently stands. If there's refactoring to be done between the two existing components and the new one, I'd strongly prefer that we do the refactoring first rather than leaving it for afterwards unless there are compelling reasons not to. I agree with others that having this discussion on chrome-design-docs@ seems like the right next step -- maybe there are compelling reasons to order it this way and I'm just missing them, but it will be easier to tease that discussion out over an email thread/design doc than inline in code review. Does that make sense?
On 2017/07/10 11:30:37, blundell wrote: > On 2017/07/07 23:55:43, Mark P wrote: > > On 2017/07/07 21:24:29, gcomanici wrote: > > > On 2017/07/07 20:13:55, Mark P wrote: > > > > A gave this a quick, haphazard review. I have two main questions / > concerns > > > > about this design: > > > > > > > > - it looks like a sizable chunk of code is being duplicated between > > > > components/omnibox/ and this new component. Can we refactor the code so > > that > > > > all suggest requests go through the same flow so the code is not > duplicated? > > > > > > After all, the regular suggest flow also needs cookies attached to it; it > > just > > > > gets that for free right now. > > > > > > I responded to a similar comment you made in the code. I am all for > > refactoring > > > the code, but I'd leave it for a different CL, if you don't mind. > > > > Can you check how much the binary size increases with this new component? > > People are working to shave, say, things the size of 200k of memory on > Android. > > If the code duplication here comes to even a fraction of that, it's worth > fixing > > it before submitting. > > > > Client-side code has different priorities than server-side ones. :-) > > > > --mark > > Given the concerns on duplication between //components/{omnibox, suggestions} > and the new component, I'm hesitant to LG the addition of the new component as > the discussion currently stands. If there's refactoring to be done between the > two existing components and the new one, I'd strongly prefer that we do the > refactoring first rather than leaving it for afterwards unless there are > compelling reasons not to. I agree with others that having this discussion on > chrome-design-docs@ seems like the right next step -- maybe there are compelling > reasons to order it this way and I'm just missing them, but it will be easier to > tease that discussion out over an email thread/design doc than inline in code > review. Does that make sense? TBH, I think the similarity between the new components/contextual_suggestions and the existing components/suggestions has been overstated. Despite the similar names and some conceptual similarities, code-wise they are quite different. The common part is essentially "a URL fetch with OAuth2 credentials". We have crbug.com/609084 to extract a helper class for that, but it won't be a lot of code, so I doubt that'd have any relevant impact on binary size. (I know nothing about duplication between the new component and components/omnibox, so that might still be a valid concern.)
On 2017/07/10 11:39:59, Marc Treib wrote: > On 2017/07/10 11:30:37, blundell wrote: > > On 2017/07/07 23:55:43, Mark P wrote: > > > On 2017/07/07 21:24:29, gcomanici wrote: > > > > On 2017/07/07 20:13:55, Mark P wrote: > > > > > A gave this a quick, haphazard review. I have two main questions / > > concerns > > > > > about this design: > > > > > > > > > > - it looks like a sizable chunk of code is being duplicated between > > > > > components/omnibox/ and this new component. Can we refactor the code so > > > that > > > > > all suggest requests go through the same flow so the code is not > > duplicated? > > > > > > > > After all, the regular suggest flow also needs cookies attached to it; > it > > > just > > > > > gets that for free right now. > > > > > > > > I responded to a similar comment you made in the code. I am all for > > > refactoring > > > > the code, but I'd leave it for a different CL, if you don't mind. > > > > > > Can you check how much the binary size increases with this new component? > > > People are working to shave, say, things the size of 200k of memory on > > Android. > > > If the code duplication here comes to even a fraction of that, it's worth > > fixing > > > it before submitting. > > > > > > Client-side code has different priorities than server-side ones. :-) > > > > > > --mark > > > > Given the concerns on duplication between //components/{omnibox, suggestions} > > and the new component, I'm hesitant to LG the addition of the new component as > > the discussion currently stands. If there's refactoring to be done between the > > two existing components and the new one, I'd strongly prefer that we do the > > refactoring first rather than leaving it for afterwards unless there are > > compelling reasons not to. I agree with others that having this discussion on > > chrome-design-docs@ seems like the right next step -- maybe there are > compelling > > reasons to order it this way and I'm just missing them, but it will be easier > to > > tease that discussion out over an email thread/design doc than inline in code > > review. Does that make sense? > > TBH, I think the similarity between the new components/contextual_suggestions > and the existing components/suggestions has been overstated. Despite the similar > names and some conceptual similarities, code-wise they are quite different. The > common part is essentially "a URL fetch with OAuth2 credentials". We have > crbug.com/609084 to extract a helper class for that, but it won't be a lot of > code, so I doubt that'd have any relevant impact on binary size. > > (I know nothing about duplication between the new component and > components/omnibox, so that might still be a valid concern.) I'm totally open to being convinced; I just think it will be an easier discussion to have as a design discussion than on a code review.
Patchset #5 (id:160001) has been deleted
I will be the first to admit that I was a bit too ambitious in having a new component do all the logic that I was looking for. I totally understand if this ambitious move requires convincing and a more in-depth review using a design doc. Ultimately, this CL should not be about a new feature which was already reviewed, but about new functionality (i.e. requests now have oauth2 tokens attached). I have no objections to leave the discussion on the new component for some later time and simply add the contextual_suggestion_service.cc to c/o/b. My main goal is for the experimental service to get the oauth2 token info. Whether that is through a new component (which I strongly believe to be the right way) or some other way, makes no difference to me. @mpearson. I believe the last patch is addressing the code duplication related to the omnibox component, and Marc clearly explained why code duplication with components/suggestions is not an issue. Please let me know if you have any strong objections to moving the contextual_suggestion_service to c/o/b.
On 2017/07/10 16:31:07, gcomanici wrote: > I will be the first to admit that I was a bit too ambitious in having a new > component do all the logic that I was looking for. I totally understand if this > ambitious move requires convincing and a more in-depth review using a design > doc. Ultimately, this CL should not be about a new feature which was already > reviewed, but about new functionality (i.e. requests now have oauth2 tokens > attached). > > I have no objections to leave the discussion on the new component for some later > time and simply add the contextual_suggestion_service.cc to c/o/b. My main goal > is for the experimental service to get the oauth2 token info. Whether that is > through a new component (which I strongly believe to be the right way) or some > other way, makes no difference to me. > > @mpearson. I believe the last patch is addressing the code duplication related > to the omnibox component, and Marc clearly explained why code duplication with > components/suggestions is not an issue. Please let me know if you have any > strong objections to moving the contextual_suggestion_service to c/o/b. This sounds fine to me (obviously I wouldn't be the one whose review you would need once you make those changes). I'm a little confused though as the latest patchset is still adding the new component.
Since I am going to be OOO for a few weeks starting tomorrow, I will add a patchset that moves the logic to c/o/b. jdonnelly@ or @mpearson, PTAL. Daniel (kenjitoyama@) will take over the effort and address any issues. Thanks!
Description was changed from ========== Create a new component `contextual_suggestions` This component provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own component, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. From a technical perspective, the new component `contextual_suggestions` is very similar to the `suggestions` component. The two components are providing very similar services (i.e. suggestions for different surfaces) but the new component is much simpler, as currently most of the logic related to contextual suggestions is performed on server side. Still, more functionality will soon be necessary on client side and all the corresponding logic will be living in the new component. Design doc: https://docs.google.com/document/d/1FUowJo9AnSziiQfBumyicaTWDKjOcM574aOBwKIVp... BUG=692471,609084 ========== to ========== Create a new class `ContextualSuggestionsService` This class provides a service to fetch experimental contextual suggestions for the omnibox. Experimental Contextual Suggestions will soon use user identity to provide personalized suggestions. The service that is creating a request with a oauth2 token attached is becoming more complex and should live in its own class, much like the service that is fetching suggestions for the NTP (new tab page). This makes the logic a lot easier to test and increases code readability for the fetcher, related experiments, and the zero suggest autocomplete provider. Additionally, b/609084 is traking an effort to unify all the URL Fetchers that use an oauth2 token. Creating this new component should facilitate future changes towards this effort. From a technical perspective, the new class is similar to SuggestionsService in componenents/suggestions. More functionality will soon be necessary on client side and all the corresponding logic will be handled by the ContextualSuggestionsService. Design doc: https://docs.google.com/document/d/1FUowJo9AnSziiQfBumyicaTWDKjOcM574aOBwKIVp... BUG=692471,609084 ==========
I did a limited review. (Ran out of time for more.) Here are my preliminary comments thus far. --mark https://codereview.chromium.org/2965173002/diff/200001/chrome/browser/BUILD.gn File chrome/browser/BUILD.gn (left): https://codereview.chromium.org/2965173002/diff/200001/chrome/browser/BUILD.g... chrome/browser/BUILD.gn:1: # Copyright 2014 The Chromium Authors. All rights reserved. I don't think we're supposed to remove lines that already exist. https://codereview.chromium.org/2965173002/diff/200001/chrome/browser/autocom... File chrome/browser/autocomplete/contextual_suggestions_service_factory.cc (right): https://codereview.chromium.org/2965173002/diff/200001/chrome/browser/autocom... chrome/browser/autocomplete/contextual_suggestions_service_factory.cc:34: Profile* profile = static_cast<Profile*>(context); This should be Profile::FromBrowserContext() instead. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/DEPS (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/DEPS:4: "+components/contextual_suggestions", This isn't necessary anymore. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/DEPS:19: "+components/signin/core/browser", I'm not sure it's okay to include components/.../browser stuffy in this non-browser component. I think it is because this component is basically only building a "browser" library plus some tests, but I'd like someone who understands what layers we're supposed to have to comment.
https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/DEPS (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/DEPS:19: "+components/signin/core/browser", On 2017/07/17 23:36:12, Mark P wrote: > I'm not sure it's okay to include components/.../browser stuffy in this > non-browser component. I think it is because this component is basically only > building a "browser" library plus some tests, but I'd like someone who > understands what layers we're supposed to have to comment. This should be absolutely fine unless there's something I'm missing. Why do you call //components/omnibox/browser a non-browser component?
I managed to review more of the changelist except for the bulk of components/omnibox/browser/contextual_suggestions_service.cc Below are my comments. Some things to check: * zero suggest (default settings) still work on desktop, and includes sending cookies (may need to use about:net-internals or a network sniffer or a LOG(INFO) or something to check this) * zero suggest (experimental settings) work on desktop, and includes sending oath tokens * zero suggest most visited still works (default settings) on desktop (appears instantly) * (nice to test but probably not affected so not strictly necessary) about:histograms shows requests sent at the right time (http versus non-https, incognito versus regular window) and that counts in the default setting and experimental agree for the histograms Omnibox.ZeroSuggestRequests. * (nice to test but not required) zero suggest (experimental settings) work on android --mark https://codereview.chromium.org/2965173002/diff/200001/chrome/browser/autocom... File chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc (right): https://codereview.chromium.org/2965173002/diff/200001/chrome/browser/autocom... chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc:32: #include "components/omnibox/browser/contextual_suggestions_service.h" nit: actually, probably this isn't appropriate / needed. (Sorry, Gheorghe, I think I told you the opposite.) https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/DEPS (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/DEPS:19: "+components/signin/core/browser", On 2017/07/18 15:21:14, blundell wrote: > On 2017/07/17 23:36:12, Mark P wrote: > > I'm not sure it's okay to include components/.../browser stuffy in this > > non-browser component. I think it is because this component is basically only > > building a "browser" library plus some tests, but I'd like someone who > > understands what layers we're supposed to have to comment. > > This should be absolutely fine unless there's something I'm missing. Why do you > call //components/omnibox/browser a non-browser component? No, you're not missing something. I'm missing something ... :-) (I missed the BROWSER part of the filename for components/omnibox/browser/DEPS.) https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/contextual_suggestions_service.cc (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.cc:77: ExperimentalZeroSuggestURL(/*visited_url=*/std::string()); Shouldn't you provide a real URL here? I wouldn't be surprised if ExperimentalZeroSuggestURL rejects constructing a suggestion URL if the provided context URL is invalid. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/contextual_suggestions_service.h (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:11: #include "base/feature_list.h" nit: necessary? https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:13: #include "components/search_engines/template_url_service.h" nit: just forward declare; no need to include https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:16: #include "net/url_request/url_request_context_getter.h" nit: just forward declare; no need to include https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:22: namespace contextual_suggestions { No need for namespace, as everything is already encapsulated in a class. (Generally this component doesn't put its things in namespaces.) https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:24: class ContextualSuggestionsService : public KeyedService { nit: Please comment the purpose of this class. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:26: ContextualSuggestionsService(SigninManagerBase* signin_manager, Please comment whether any of these are allowed to be null. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:38: // of the fetcher. Please add/revise here to make it clearer what relationship between |fetcher_delegate| that processes the response and |callback| are. I read all the comments below and I don't know. Then, with that in mind, please revise the comments below. There is also some formatting issues there and at least one typo, but the bigger issue is that they're confusing, likely due to a lack of explanation at the beginning about the relationship I mentioned. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:53: const std::string& visited_url, nit: visited_url -> current_url or simply url Apparently, from looking at the code, sometimes this is called with an empty URL. Normally URLs cannot be empty. This definitely needs to be commented. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:59: // * The |visited_url| is non-empty. non-empty? Probably this should be checking whether the url is valid. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:71: // Returns a string representing the address of the server where the zero Doesn't return a string... https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:74: static GURL ExperimentalZeroSuggestURL(const std::string& visited_url); nit: I'd prefer current_url rather than visited_url. What do you think? https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:77: // suggest request is being sent. This comment makes it unclear how this relates to the functions above. Do you want to add (if correct) // Uses the experimental suggest URL as appropriate. And why do you need to pass in the parameter |experimental|? Can't you just have this function call UseExperimentalZeroSuggestSuggestions(). Regardless, this function should probably go higher in this list of functions, perhaps before UseExperimentalZeroSuggestSuggestions(). https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:81: // does not include a header corresponding to an authorization token. nit: The return value does not include a header corresponding to an authorization token. -> The returned fetcher does not include a header with an authorization token. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:98: // Helper for fetching OAuth2 access tokens. This is non-null iff an access Does iff mean if and only if If so, simply say "when". https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:99: // token request is currently in progress. Roughly when does that happen? There probably should be some comment by one of these functions here that says "sends a request for an OAuth2 token". https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:101: }; nit: missing DISALLOW_COPY_AND_ASSIGN. Is that intentional? https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/omnibox_field_trial.cc (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/omnibox_field_trial.cc:88: // Feature used for the Zero Suggest Redirect to Chrome Field Trial nit: please restore the period. :-) https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/omnibox_field_trial.h (left): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/omnibox_field_trial.h:429: // For experiment redirecting zero suggest requests to a service provided by It would be nice to keep all the omnibox field trial logic in one place, so we can easily see what experiments exist and/or need to be retired. Please use these functions if possible. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/zero_suggest_provider.cc (left): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/zero_suggest_provider.cc:198: done_ = false; I think this line should probably stay. I wonder why Gheorghe removed it. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/zero_suggest_provider.cc (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/zero_suggest_provider.cc:153: bool attach_current_url = optional nit: how about can_attach_current_url? https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/zero_suggest_provider.cc:184: ->GetContextualSuggestionsService() Is GetContextualSuggestionsService() always going to be non-null? https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/zero_suggest_provider.cc:193: void ZeroSuggestProvider::OnContextualSuggestionsFetcherAvailable( nit: Definitions in the .cc file should be in the same order at in the header. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/zero_suggest_provider.cc:195: if (fetcher == nullptr) { Why / how can this happen? Also, since we're going to get any additional suggestions after this failure, I think you should set done_ to true here. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/zero_suggest_provider.cc:199: done_ = false; I don't think this is the right place to set done_ to false. I think it should remain set to false where it was. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/zero_suggest_provider.h (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/zero_suggest_provider.h:112: // service for the most visited URLs during Run(). It calls back to this Please revise, as Run() doesn't exist anymore. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/zero_suggest_provider.h:116: void OnContextualSuggestionsFetcherAvailable( Please comment.
kenjitoyama@chromium.org changed reviewers: + kenjitoyama@chromium.org
Hi Mark, can you take another look? Also, because this is not my issue, we should probably continue the review on https://chromium-review.googlesource.com/c/576284/ instead. Thanks! https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/contextual_suggestions_service.cc (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.cc:77: ExperimentalZeroSuggestURL(/*visited_url=*/std::string()); On 2017/07/18 19:11:28, Mark P wrote: > Shouldn't you provide a real URL here? I wouldn't be surprised if > ExperimentalZeroSuggestURL rejects constructing a suggestion URL if the provided > context URL is invalid. I don't have the right context here, but everything seems to be working just fine with or without current_url. I agree with you that it's probably better to pass something than an empty string. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/contextual_suggestions_service.h (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:11: #include "base/feature_list.h" On 2017/07/18 19:11:28, Mark P wrote: > nit: necessary? Done. (removed) https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:13: #include "components/search_engines/template_url_service.h" On 2017/07/18 19:11:28, Mark P wrote: > nit: just forward declare; no need to include Done. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:16: #include "net/url_request/url_request_context_getter.h" On 2017/07/18 19:11:29, Mark P wrote: > nit: just forward declare; no need to include Moved to .cc file. There are no symbols needed in this header. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:22: namespace contextual_suggestions { On 2017/07/18 19:11:29, Mark P wrote: > No need for namespace, as everything is already encapsulated in a class. > (Generally this component doesn't put its things in namespaces.) Done. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:24: class ContextualSuggestionsService : public KeyedService { On 2017/07/18 19:11:29, Mark P wrote: > nit: Please comment the purpose of this class. Done. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:26: ContextualSuggestionsService(SigninManagerBase* signin_manager, On 2017/07/18 19:11:28, Mark P wrote: > Please comment whether any of these are allowed to be null. Done. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:38: // of the fetcher. On 2017/07/18 19:11:29, Mark P wrote: > Please add/revise here to make it clearer what relationship between > |fetcher_delegate| that processes the response and |callback| are. I read all > the comments below and I don't know. > > Then, with that in mind, please revise the comments below. There is also some > formatting issues there and at least one typo, but the bigger issue is that > they're confusing, likely due to a lack of explanation at the beginning about > the relationship I mentioned. I read the code and I am myself a little bit confused. I rewrote the comment with my current understanding, but can you take a look and let me know what you think? https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:53: const std::string& visited_url, On 2017/07/18 19:11:28, Mark P wrote: > nit: visited_url -> current_url or simply url > Apparently, from looking at the code, sometimes this is called with an empty > URL. Normally URLs cannot be empty. This definitely needs to be commented. I s/visited_url/current_url/ everything in this code. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:59: // * The |visited_url| is non-empty. On 2017/07/18 19:11:28, Mark P wrote: > non-empty? Probably this should be checking whether the url is valid. The code is currently only checking it's not empty. What kinds of checks do you want to perform to ensure the URL is valid? Notice that the backend will check whether the URL is valid in its on way regardless if Chrome checks here. Also, the calling code for this service may check as well. IMHO I think it's OK to just check for empty, but I can add more checks if you think they are necessary. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:71: // Returns a string representing the address of the server where the zero On 2017/07/18 19:11:29, Mark P wrote: > Doesn't return a string... Done. s/string/URL/ https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:74: static GURL ExperimentalZeroSuggestURL(const std::string& visited_url); On 2017/07/18 19:11:29, Mark P wrote: > nit: I'd prefer current_url rather than visited_url. What do you think? Done. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:77: // suggest request is being sent. On 2017/07/18 19:11:29, Mark P wrote: > This comment makes it unclear how this relates to the functions above. Do you > want to add (if correct) > // Uses the experimental suggest URL as appropriate. > And why do you need to pass in the parameter |experimental|? Can't you just > have this function call UseExperimentalZeroSuggestSuggestions(). > > Regardless, this function should probably go higher in this list of functions, > perhaps before UseExperimentalZeroSuggestSuggestions(). I s/experimental/is_experimental/ to make the parameter a bit more clear. I added a comment to explain |is_experimental|. PTAL. As for calling UseExperimentalZeroSuggestions(), it is definitely possible, but that function is not exactly free and there are a number of calls there. I think Gheorghe's solution to memoize the call is not so bad. Do you feel strongly about this? https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:81: // does not include a header corresponding to an authorization token. On 2017/07/18 19:11:28, Mark P wrote: > nit: > The return value does not include a header corresponding to an authorization > token. > -> > The returned fetcher does not include a header with an authorization token. Done. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:98: // Helper for fetching OAuth2 access tokens. This is non-null iff an access On 2017/07/18 19:11:28, Mark P wrote: > Does > iff > mean > if and only if > > If so, simply say "when". iff == if and only if I think "iff" is stronger than "when", but we don't need to be pedantic here. I think when reads more naturally than iff in this case. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:99: // token request is currently in progress. On 2017/07/18 19:11:29, Mark P wrote: > Roughly when does that happen? There probably should be some comment by one of > these functions here that says "sends a request for an OAuth2 token". I added the comment to CreateContextualSuggestionsRequest(). PTAL. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:101: }; On 2017/07/18 19:11:29, Mark P wrote: > nit: missing DISALLOW_COPY_AND_ASSIGN. Is that intentional? I can't speak for Gheorghe, but I think it was not intentional. This class holds handles for some external objects, and copying is probably not the right thing I think. I added the macro.
On 2017/07/18 20:28:48, Toyama wrote: > Hi Mark, can you take another look? You replied to my comments as if you fixed them, yet didn't upload a new patch set in this issue. > Also, because this is not my issue, we should probably continue the review on > https://chromium-review.googlesource.com/c/576284/ instead. And the new issue that you want me to review contains only a single patchset that doesn't have the fixes to my comments. Did you forget to upload a new patch set? Also, I'll note that there are comments in this patchset that you didn't reply to at all. I will publish additional comments on https://chromium-review.googlesource.com/c/576284/ --mark
A few replies to your comments. --mark https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... File components/omnibox/browser/contextual_suggestions_service.h (right): https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:59: // * The |visited_url| is non-empty. On 2017/07/18 20:28:48, Toyama wrote: > On 2017/07/18 19:11:28, Mark P wrote: > > non-empty? Probably this should be checking whether the url is valid. > > The code is currently only checking it's not empty. What kinds of checks do you > want to perform to ensure the URL is valid? Usually we pass around GURL variables and use gurl.is_valid() to check that it's a proper URL. > Notice that the backend will check > whether the URL is valid in its on way regardless if Chrome checks here. Also, > the calling code for this service may check as well. IMHO I think it's OK to > just check for empty, but I can add more checks if you think they are necessary. It's not necessary, just confusing. You need to make the reasoning for this clear. It looks like this function doesn't do anything with the URL other than check whether it's empty or not. That makes me think you shouldn't be passing a string to this at all. https://codereview.chromium.org/2965173002/diff/200001/components/omnibox/bro... components/omnibox/browser/contextual_suggestions_service.h:77: // suggest request is being sent. On 2017/07/18 20:28:48, Toyama wrote: > On 2017/07/18 19:11:29, Mark P wrote: > > This comment makes it unclear how this relates to the functions above. Do you > > want to add (if correct) > > // Uses the experimental suggest URL as appropriate. > > And why do you need to pass in the parameter |experimental|? Can't you just > > have this function call UseExperimentalZeroSuggestSuggestions(). > > > > Regardless, this function should probably go higher in this list of functions, > > perhaps before UseExperimentalZeroSuggestSuggestions(). > > I s/experimental/is_experimental/ to make the parameter a bit more clear. I > added a comment to explain |is_experimental|. PTAL. > > As for calling UseExperimentalZeroSuggestions(), it is definitely possible, but > that function is not exactly free and there are a number of calls there. I think > Gheorghe's solution to memoize the call is not so bad. Do you feel strongly > about this? I don't feel strongly about memoizing as long as the comments are clear about what each function does.
On 2017/07/18 23:24:46, Mark P wrote: > On 2017/07/18 20:28:48, Toyama wrote: > > Hi Mark, can you take another look? > > You replied to my comments as if you fixed them, yet didn't upload a > new patch set in this issue. > > > Also, because this is not my issue, we should probably continue the review on > > https://chromium-review.googlesource.com/c/576284/ instead. > > And the new issue that you want me to review contains only a single patchset > that doesn't have the fixes to my comments. Did you forget to upload a new > patch set? > > Also, I'll note that there are comments in this patchset that you didn't > reply to at all. > > I will publish additional comments on > https://chromium-review.googlesource.com/c/576284/ > > --mark I'm sorry, I forgot to do "git cl upload". It's confusing to go back and forth between two code review systems. Let's do everything from Gerrit. |