Commit c8c5abba authored by Maksim Ivanov's avatar Maksim Ivanov Committed by Commit Bot

Fix use-after-move in //content/browser/background_fetch/

Fix use-after-move (potential) bugs found by the
"bugprone-use-after-move" clang-tidy check.

Bug: 1122844
Change-Id: Ic193475f84e8f43193ad141477a5265ea81e458f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382077Reviewed-by: default avatarRayan Kanso <rayankans@chromium.org>
Commit-Queue: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803470}
parent 296c1e24
...@@ -2327,8 +2327,6 @@ TEST_F(BackgroundFetchDataManagerTest, CreateInParallel) { ...@@ -2327,8 +2327,6 @@ TEST_F(BackgroundFetchDataManagerTest, CreateInParallel) {
ASSERT_NE(blink::mojom::kInvalidServiceWorkerRegistrationId, ASSERT_NE(blink::mojom::kInvalidServiceWorkerRegistrationId,
service_worker_registration_id); service_worker_registration_id);
std::vector<blink::mojom::FetchAPIRequestPtr> requests =
CreateValidRequests(origin());
auto options = blink::mojom::BackgroundFetchOptions::New(); auto options = blink::mojom::BackgroundFetchOptions::New();
std::vector<blink::mojom::BackgroundFetchError> errors(5); std::vector<blink::mojom::BackgroundFetchError> errors(5);
...@@ -2343,6 +2341,8 @@ TEST_F(BackgroundFetchDataManagerTest, CreateInParallel) { ...@@ -2343,6 +2341,8 @@ TEST_F(BackgroundFetchDataManagerTest, CreateInParallel) {
base::BarrierClosure(num_parallel_creates, run_loop.QuitClosure()); base::BarrierClosure(num_parallel_creates, run_loop.QuitClosure());
for (int i = 0; i < num_parallel_creates; i++) { for (int i = 0; i < num_parallel_creates; i++) {
std::vector<blink::mojom::FetchAPIRequestPtr> requests =
CreateValidRequests(origin());
// New |unique_id| per iteration, since each is a distinct registration. // New |unique_id| per iteration, since each is a distinct registration.
BackgroundFetchRegistrationId registration_id( BackgroundFetchRegistrationId registration_id(
service_worker_registration_id, origin(), kExampleDeveloperId, service_worker_registration_id, origin(), kExampleDeveloperId,
......
...@@ -113,7 +113,7 @@ void BackgroundFetchEventDispatcher::DispatchBackgroundFetchCompletionEvent( ...@@ -113,7 +113,7 @@ void BackgroundFetchEventDispatcher::DispatchBackgroundFetchCompletionEvent(
auto registration = blink::mojom::BackgroundFetchRegistration::New( auto registration = blink::mojom::BackgroundFetchRegistration::New(
std::move(registration_data), std::move(registration_data),
BackgroundFetchRegistrationServiceImpl::CreateInterfaceInfo( BackgroundFetchRegistrationServiceImpl::CreateInterfaceInfo(
std::move(registration_id), background_fetch_context_->GetWeakPtr())); registration_id, background_fetch_context_->GetWeakPtr()));
switch (registration->registration_data->failure_reason) { switch (registration->registration_data->failure_reason) {
case blink::mojom::BackgroundFetchFailureReason::NONE: case blink::mojom::BackgroundFetchFailureReason::NONE:
...@@ -184,7 +184,7 @@ void BackgroundFetchEventDispatcher::DispatchBackgroundFetchClickEvent( ...@@ -184,7 +184,7 @@ void BackgroundFetchEventDispatcher::DispatchBackgroundFetchClickEvent(
auto registration = blink::mojom::BackgroundFetchRegistration::New( auto registration = blink::mojom::BackgroundFetchRegistration::New(
std::move(registration_data), std::move(registration_data),
BackgroundFetchRegistrationServiceImpl::CreateInterfaceInfo( BackgroundFetchRegistrationServiceImpl::CreateInterfaceInfo(
std::move(registration_id), background_fetch_context_->GetWeakPtr())); registration_id, background_fetch_context_->GetWeakPtr()));
LoadServiceWorkerRegistrationForDispatch( LoadServiceWorkerRegistrationForDispatch(
registration_id, ServiceWorkerMetrics::EventType::BACKGROUND_FETCH_CLICK, registration_id, ServiceWorkerMetrics::EventType::BACKGROUND_FETCH_CLICK,
......
...@@ -193,8 +193,9 @@ void MarkRequestCompleteTask::DidOpenCache( ...@@ -193,8 +193,9 @@ void MarkRequestCompleteTask::DidOpenCache(
// TODO(crbug.com/774054): The request blob stored in the cache is being // TODO(crbug.com/774054): The request blob stored in the cache is being
// overwritten here, it should be written back. // overwritten here, it should be written back.
handle.value()->Put( CacheStorageCache* handle_ptr = handle.value();
std::move(request), BackgroundFetchSettledFetch::CloneResponse(response_), handle_ptr->Put(std::move(request),
BackgroundFetchSettledFetch::CloneResponse(response_),
trace_id, trace_id,
base::BindOnce(&MarkRequestCompleteTask::DidWriteToCache, base::BindOnce(&MarkRequestCompleteTask::DidWriteToCache,
weak_factory_.GetWeakPtr(), std::move(handle), weak_factory_.GetWeakPtr(), std::move(handle),
......
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