New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 637077 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Find the best way to return callback values with SavePageRequest and OfflinePageItem

Project Member Reported by petewil@chromium.org, Aug 11 2016

Issue description

Today we use a const std::vector<SavePageItem>&, which might force more copies than necessary.  Instead, we could use an approach based on std::move, so that only one copy is made.

However, initial investigations show that it is difficult to make it work with base::Bind() even using the Passed() wrapper.

If wre try to use const vector, it fails because you can't std::move out of a const vector, since std::move modifies the place you are moving from.

However, base::Bind seems to require a const parameter. Maybe
that makes sense, because it is getting passed among threads, and base::Bind wants to make sure it doesn't get changed out from under the callback while it is passing it along different theads.

So, it looks like the combination of trying to do std::move and
base::Bind is a bad one.

So, Bind should provide some workaround for us - Passed()?  Owned()?

Passed(std::move(mytype)) is failing to copy a non-const vector
onto a vector deep inside.

bind_unittest.cc seems to show this as possible, but mimicking it
doesn't let me compile.

Maybe try a smart pointer with a vector of SavePageResult?
 
Cc: bauerb@chromium.org
Status: Assigned (was: Untriaged)
I'm fairly certain Passed(std::move(mytype)) works if the signature of the callback takes a plain mytype, as that's exactly how unique_ptr's are passed, and they're noncopyable too.

(Also, bug with owner = Assigned ;-) )
Project Member

Comment 2 by bugdroid1@chromium.org, Sep 9 2016

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

commit 2f65c71a4b658c5555806222dda7fd3a1e39c31c
Author: petewil <petewil@chromium.org>
Date: Fri Sep 09 00:50:23 2016

Use a vector of smart pointers for callback return type.

We can't use references to large objects with std::move,
so change the code to use the vector of pointers itself
instead  of a reference to a vector of pointers.

BUG= 637077 

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

[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/chrome/browser/android/offline_pages/offline_page_bridge.cc
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_coordinator.cc
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_coordinator.h
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_coordinator_unittest.cc
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_picker.cc
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_picker.h
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_queue.cc
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_queue.h
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_queue_in_memory_store.cc
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_queue_store.h
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_queue_store_sql.cc
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_queue_store_unittest.cc
[modify] https://crrev.com/2f65c71a4b658c5555806222dda7fd3a1e39c31c/components/offline_pages/background/request_queue_unittest.cc

Status: Fixed (was: Assigned)

Sign in to add a comment