New issue
Advanced search Search tips

Issue 689981 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug

Blocking:
issue 689965



Sign in to add a comment

Provide last access time in DownloadItem.

Project Member Reported by vitaliii@chromium.org, Feb 8 2017

Issue description

Currently DownloadItem contains only when it has been started and finished and whether it has been opened. However, there are some clients (e.g. NTP), who  are interested in having also time when a download was last opened. Offline Pages do this already.

As dtrainor@ described in a private conversation, the following should be done:

1. Add last_access_time_ to the DownloadItem and the underlying DownloadDatabase.
2. Update last_access_time_ on download open.
3. Add a task to update last_access_time_ from external sources (other Android apps).
 
Cc: dtrainor@chromium.org
Owner: shaktisahu@chromium.org
Shakti can you start ramping up on this?  I'm hoping we can add it before M58.
Status: Started (was: Assigned)
Project Member

Comment 3 by bugdroid1@chromium.org, Mar 3 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/60eb97fc48ad3a8df63c8b17aacb30985af52dd1

commit 60eb97fc48ad3a8df63c8b17aacb30985af52dd1
Author: shaktisahu <shaktisahu@chromium.org>
Date: Fri Mar 03 08:53:23 2017

Added last_access_time to DownloadItem and History DB

Added the last access time for a download item. If the item has not
been accessed yet, it should default to 0. This involves adding a
column to the History DB and migrating the older versions to have
the same default value for this field.

Download home and DownloadSnackbarController currently open the
download item directly. Since they use the filename to open the
file directly, the native DownloadItem::Open() is not called from
android. So a public method UpdateLastAccessTime was added to
DownloadItem and hence DownloadServiceManager to directly update
last access time.

Probably we should change all the download open paths to use native
DownloadItem::Open in future.

BUG= 689981 

Review-Url: https://codereview.chromium.org/2705283003
Cr-Commit-Position: refs/heads/master@{#454548}

[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadInfo.java
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/android/java/src/org/chromium/chrome/browser/download/ui/BackendProvider.java
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/StubbedProvider.java
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/android/download/download_manager_service.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/android/download/download_manager_service.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/apps/guest_view/web_view_browsertest.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/browsing_data/downloads_counter_browsertest.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/download/download_history.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/download/download_history_unittest.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/download/download_ui_controller_unittest.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/ntp_snippets/fake_download_item.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/ntp_snippets/fake_download_item.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/chrome/browser/safe_browsing/incident_reporting/last_download_finder_unittest.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/components/history/core/browser/download_database.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/components/history/core/browser/download_database.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/components/history/core/browser/download_row.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/components/history/core/browser/download_row.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/components/history/core/browser/history_backend_db_unittest.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/components/history/core/browser/history_database.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/components/history/core/test/history_backend_db_base_test.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/browser/download/download_browsertest.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/browser/download/download_item_factory.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/browser/download/download_item_impl.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/browser/download/download_item_impl.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/browser/download/download_manager_impl.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/browser/download/download_manager_impl.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/browser/download/download_manager_impl_unittest.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/browser/download/mock_download_item_impl.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/browser/download/mock_download_item_impl.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/public/browser/download_item.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/public/browser/download_manager.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/public/test/mock_download_item.h
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/public/test/mock_download_manager.cc
[modify] https://crrev.com/60eb97fc48ad3a8df63c8b17aacb30985af52dd1/content/public/test/mock_download_manager.h

I experimented with GetLastAccessTime() and found out that the time is not updated when a download is opened from NTP (we use DownloadUtils.openFile). Could you address this? Having one proper entry point for opening downloads is a very good thing in my view.
Sure. Could you give me the steps to verify my fix locally?
To reproduce:

1) Apply attached patch (git apply logging_patch.txt).

2) Go to wikipedia.org

3) Save some image

4) Kill Chrome

5) Observe logcat
third_party/android_tools/sdk/platform-tools/adb logcat -v time | grep MYMYMY

6) Start Chrome

In the log I see
===========
03-06 10:20:18.361 I/chromium(28200): [INFO:download_suggestions_provider.cc(515)] MYMYMY I see https://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Leekfrith_Torcs.jpg/160px-Leekfrith_Torcs.jpg 1601-01-01 00:00:00.000 UTC
===========

7) From the NTP open the image

8) Go back to the NTP

9) Kill Chrome and start it again, in the log I see
===========
03-06 10:21:11.333 I/chromium(28562): [INFO:download_suggestions_provider.cc(515)] MYMYMY I see https://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Leekfrith_Torcs.jpg/160px-Leekfrith_Torcs.jpg 1601-01-01 00:00:00.000 UTC
===========

10) Open the image from Downloads Home

11) Kill Chrome and start it again, in the log I see
===========
03-06 10:22:13.911 I/chromium(28890): [INFO:download_suggestions_provider.cc(515)] MYMYMY I see https://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Leekfrith_Torcs.jpg/160px-Leekfrith_Torcs.jpg 2017-03-06 09:21:55.530 UTC
===========






logging_patch.txt
1.3 KB View Download
Labels: -M-58 M-59
vitaliii@ do you need this on M58 or would it be possible to not worry about cherry picking the fixes?  Moving to M59.  If you want need it feel free to change it back.  Thanks!
Project Member

Comment 9 by bugdroid1@chromium.org, Mar 10 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/aa394d93072283f792da83ae88412562169539e3

commit aa394d93072283f792da83ae88412562169539e3
Author: shaktisahu <shaktisahu@chromium.org>
Date: Fri Mar 10 23:14:07 2017

Downloads : Last access time update for NTP and notifications

This CL tries to update the last access time for a download item correctly.
The download items have several clients and the access does not go through
a common code path. One option is to look at the file system's last access
time (atime in Unix) and update it from a non-UI thread task. However, it
was found that the last access time is not updated or at best lazily updated
by most of the POSIX systems in case of a file read. So the other approach
is to update the last access time manually whenever the file is opened
through chrome. NTP, download infobar, duplicate download infobar,
download home and download notification are the entry points where
we fire an intent to open the downloaded file. To find the download
item, we need a GUID and the correct profile which was passed correctly
to the appropriate call sites.

BUG= 689981 

Review-Url: https://codereview.chromium.org/2737723002
Cr-Commit-Position: refs/heads/master@{#456211}

[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadBroadcastReceiver.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/java/src/org/chromium/chrome/browser/infobar/DuplicateDownloadInfoBar.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/java/src/org/chromium/chrome/browser/suggestions/SuggestionsNavigationDelegateImpl.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadNotificationServiceTest.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/android/javatests/src/org/chromium/chrome/browser/download/MockDownloadNotificationService.java
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/browser/android/ntp/ntp_snippets_bridge.cc
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/browser/ntp_snippets/download_suggestions_provider.cc
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/browser/ntp_snippets/fake_download_item.cc
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/chrome/browser/ntp_snippets/fake_download_item.h
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/components/ntp_snippets/content_suggestion.cc
[modify] https://crrev.com/aa394d93072283f792da83ae88412562169539e3/components/ntp_snippets/content_suggestion.h

Status: Fixed (was: Started)

Sign in to add a comment