Commit a97b4417 authored by vabr's avatar vabr Committed by Commit bot

FormFetcherImpl: MakeWeakCopies no longer a template

MakeWeakCopies is a helper function inside the FormFetcherImpl implementation.
It transforms a vector of unique_ptrs into the result of calling get() on them.
It used to be used for pointers of different types, therefore it was a function
template. But after https://codereview.chromium.org/2552263002, MakeWeakCopies
is only used with PasswordForms.

This CL:
 * Converts MakeWeakCopies to a simple function.
 * Removes some unnecessary "autofill::" in the same file.

BUG=621355
R=vasilii@chromium.org

Review-Url: https://codereview.chromium.org/2587313002
Cr-Commit-Position: refs/heads/master@{#439795}
parent 05e0ae38
...@@ -45,14 +45,14 @@ std::vector<std::unique_ptr<PasswordForm>> SplitFederatedMatches( ...@@ -45,14 +45,14 @@ std::vector<std::unique_ptr<PasswordForm>> SplitFederatedMatches(
return federated_matches; return federated_matches;
} }
// Create a vector of const T* from a vector of unique_ptr<T>. // Create a vector of const PasswordForm from a vector of
template <typename T> // unique_ptr<PasswordForm> by applying get() item-wise.
std::vector<const T*> MakeWeakCopies( std::vector<const PasswordForm*> MakeWeakCopies(
const std::vector<std::unique_ptr<T>>& owning) { const std::vector<std::unique_ptr<PasswordForm>>& owning) {
std::vector<const T*> result; std::vector<const PasswordForm*> result(owning.size());
result.resize(owning.size()); std::transform(
std::transform(owning.begin(), owning.end(), result.begin(), owning.begin(), owning.end(), result.begin(),
[](const std::unique_ptr<T>& ptr) { return ptr.get(); }); [](const std::unique_ptr<PasswordForm>& ptr) { return ptr.get(); });
return result; return result;
} }
...@@ -80,13 +80,13 @@ const std::vector<InteractionsStats>& FormFetcherImpl::GetInteractionsStats() ...@@ -80,13 +80,13 @@ const std::vector<InteractionsStats>& FormFetcherImpl::GetInteractionsStats()
return interactions_stats_; return interactions_stats_;
} }
const std::vector<const autofill::PasswordForm*>& const std::vector<const PasswordForm*>& FormFetcherImpl::GetFederatedMatches()
FormFetcherImpl::GetFederatedMatches() const { const {
return weak_federated_; return weak_federated_;
} }
void FormFetcherImpl::OnGetPasswordStoreResults( void FormFetcherImpl::OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) { std::vector<std::unique_ptr<PasswordForm>> results) {
DCHECK_EQ(State::WAITING, state_); DCHECK_EQ(State::WAITING, state_);
state_ = State::NOT_WAITING; state_ = State::NOT_WAITING;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment