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

Issue 2833793002: Added AddDownload communication path and observers

Created:
3 years, 8 months ago by harkness
Modified:
3 years, 8 months ago
CC:
chromium-reviews, Peter Beverloo, darin-cc_chromium.org, jam, harkness+watch_chromium.org, awdf+watch_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Added AddDownload communication path and observers The BackgroundFetch lives in //content, but it uses functionality in //components/offline_items_collection to display notifications and receive signals when there is interaction with those notifications. The BackgroundFetchClientImpl is used to bridge the gap from //content to //chrome. A previous CL added //chrome to //content calls for things such as PauseDownload. This CL adds the first of the //content to //chrome calls, AddDownload. It also adds tracking for observers which can add to the provider and receive updates for events such as AddDownload. The CL also adds tests for AddObserver/SetDelegate ordering and basic AddDownload plumbing. BUG=692581

Patch Set 1 #

Total comments: 31

Patch Set 2 : Addressed comments and moved thrad jumps into the client proxy. #

Total comments: 6

Messages

Total messages: 6 (1 generated)
harkness
peter@ for pretty much everything. dtrainor@ for sync/async question in offline_content_aggregator.cc and background_fetch_client_impl observer behaviour. ...
3 years, 8 months ago (2017-04-20 12:25:17 UTC) #2
Peter Beverloo
https://codereview.chromium.org/2833793002/diff/1/chrome/browser/background_fetch/background_fetch_client_impl.cc File chrome/browser/background_fetch/background_fetch_client_impl.cc (right): https://codereview.chromium.org/2833793002/diff/1/chrome/browser/background_fetch/background_fetch_client_impl.cc#newcode73 chrome/browser/background_fetch/background_fetch_client_impl.cc:73: offline_items_collection::OfflineItem item( nit: drop offline_items_collection:: (you have a `using` ...
3 years, 8 months ago (2017-04-20 16:27:55 UTC) #3
harkness
This patch should address all code comments other than the OCA initialization one, which Peter ...
3 years, 8 months ago (2017-04-21 14:55:20 UTC) #4
Peter Beverloo
https://codereview.chromium.org/2833793002/diff/1/chrome/browser/background_fetch/background_fetch_client_impl.cc File chrome/browser/background_fetch/background_fetch_client_impl.cc (right): https://codereview.chromium.org/2833793002/diff/1/chrome/browser/background_fetch/background_fetch_client_impl.cc#newcode145 chrome/browser/background_fetch/background_fetch_client_impl.cc:145: observers_.RemoveObserver(observer); On 2017/04/21 14:55:19, harkness wrote: > On 2017/04/20 ...
3 years, 8 months ago (2017-04-24 14:39:15 UTC) #5
David Trainor- moved to gerrit
3 years, 8 months ago (2017-04-25 03:24:43 UTC) #6
https://codereview.chromium.org/2833793002/diff/1/components/offline_items_co...
File components/offline_items_collection/core/offline_content_aggregator.cc
(right):

https://codereview.chromium.org/2833793002/diff/1/components/offline_items_co...
components/offline_items_collection/core/offline_content_aggregator.cc:45: bool
need_add_observer = false;
On 2017/04/20 16:27:55, Peter Beverloo wrote:
> On 2017/04/20 12:25:16, harkness wrote:
> > dtrainor: This is ugly, but I threw it in there to get the tests to not
crash.
> 
> > 
> > Should the OfflineContentAggregator be able to support a synchronous
> > OnItemsAvailable call which is triggered from the AddObserver? I saw that in
> the
> > OfflineContentAggregator's AddObserver, you're doing an async
> > CheckAndNotifyItemsAvailable() call, but for the BFCI, we're making the
> > simplifying assumption that as long as the delegate is set, it's ready, so
we
> > shouldn't need the call to be async.
> 
> There's a race condition there. If the OCA would send us resume/click/other
> events before we're done initializing, they might be dropped on the floor. (I
> presume the OCA doesn't queue events until a provider is available.)

It actually does queue them up and flush them once you signal you're ready! :D

> 
> Perhaps we should:
>     a) Always register the delegate..
>     b) Have //content send us an ContentAvailable signal of sorts when stuff
is
> initialized. This would call OnItemsAvailable.
>     c) Queue events in the BGFetchClientImpl and only send them to the
delegate
> when the signal has been received.
> 
> That said, I agree that this is a footgun in the OCA API and would still
suggest
> this fix :).

Making it synchronous actually has more of an impact on the caller than on
anything else.  I wanted to try to have a consistent behavior for how the API
would work for anyone trying to register an observer.  Ideally it'd just all be
asynchronous since we need to support that anyway.  If we do this, could you add
a TODO in the bgfetch client code to make it asynchronous when possible?  I
think you can probably get away with it for now without causing issues.

Do you immediately call OnItemAdded right after you build and register your
delegate?

https://codereview.chromium.org/2833793002/diff/20001/chrome/browser/backgrou...
File chrome/browser/background_fetch/background_fetch_client_impl.cc (right):

https://codereview.chromium.org/2833793002/diff/20001/chrome/browser/backgrou...
chrome/browser/background_fetch/background_fetch_client_impl.cc:143:
observer->OnItemsAvailable(this);
Could we post this?

https://codereview.chromium.org/2833793002/diff/20001/components/offline_item...
File components/offline_items_collection/core/offline_content_aggregator.cc
(right):

https://codereview.chromium.org/2833793002/diff/20001/components/offline_item...
components/offline_items_collection/core/offline_content_aggregator.cc:45: bool
need_add_observer = false;
needs_add_observer = !MapContainsValue(providers_, provider_)?

Powered by Google App Engine
This is Rietveld 408576698