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

Side by Side Diff: content/browser/background_sync/background_sync_manager.cc

Issue 2256173002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace a WrapUnique() nested inside a MakeUnique() Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/background_sync/background_sync_manager.h" 5 #include "content/browser/background_sync/background_sync_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/barrier_closure.h" 9 #include "base/barrier_closure.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 BackgroundSyncMetrics::REGISTRATION_IS_DUPLICATE); 521 BackgroundSyncMetrics::REGISTRATION_IS_DUPLICATE);
522 522
523 if (existing_registration->IsFiring()) { 523 if (existing_registration->IsFiring()) {
524 existing_registration->set_sync_state( 524 existing_registration->set_sync_state(
525 blink::mojom::BackgroundSyncState::REREGISTERED_WHILE_FIRING); 525 blink::mojom::BackgroundSyncState::REREGISTERED_WHILE_FIRING);
526 } 526 }
527 527
528 base::ThreadTaskRunnerHandle::Get()->PostTask( 528 base::ThreadTaskRunnerHandle::Get()->PostTask(
529 FROM_HERE, 529 FROM_HERE,
530 base::Bind(callback, BACKGROUND_SYNC_STATUS_OK, 530 base::Bind(callback, BACKGROUND_SYNC_STATUS_OK,
531 base::Passed(base::WrapUnique(new BackgroundSyncRegistration( 531 base::Passed(base::MakeUnique<BackgroundSyncRegistration>(
532 *existing_registration))))); 532 *existing_registration))));
533 return; 533 return;
534 } 534 }
535 535
536 BackgroundSyncRegistration new_registration; 536 BackgroundSyncRegistration new_registration;
537 537
538 *new_registration.options() = options; 538 *new_registration.options() = options;
539 539
540 BackgroundSyncRegistrations* registrations = 540 BackgroundSyncRegistrations* registrations =
541 &active_registrations_[sw_registration_id]; 541 &active_registrations_[sw_registration_id];
542 new_registration.set_id(registrations->next_id++); 542 new_registration.set_id(registrations->next_id++);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 : BackgroundSyncMetrics::REGISTRATION_COULD_NOT_FIRE; 693 : BackgroundSyncMetrics::REGISTRATION_COULD_NOT_FIRE;
694 BackgroundSyncMetrics::CountRegisterSuccess( 694 BackgroundSyncMetrics::CountRegisterSuccess(
695 registration_could_fire, 695 registration_could_fire,
696 BackgroundSyncMetrics::REGISTRATION_IS_NOT_DUPLICATE); 696 BackgroundSyncMetrics::REGISTRATION_IS_NOT_DUPLICATE);
697 697
698 FireReadyEvents(); 698 FireReadyEvents();
699 699
700 base::ThreadTaskRunnerHandle::Get()->PostTask( 700 base::ThreadTaskRunnerHandle::Get()->PostTask(
701 FROM_HERE, 701 FROM_HERE,
702 base::Bind(callback, BACKGROUND_SYNC_STATUS_OK, 702 base::Bind(callback, BACKGROUND_SYNC_STATUS_OK,
703 base::Passed(base::WrapUnique( 703 base::Passed(base::MakeUnique<BackgroundSyncRegistration>(
704 new BackgroundSyncRegistration(new_registration))))); 704 new_registration))));
705 } 705 }
706 706
707 void BackgroundSyncManager::RemoveActiveRegistration(int64_t sw_registration_id, 707 void BackgroundSyncManager::RemoveActiveRegistration(int64_t sw_registration_id,
708 const std::string& tag) { 708 const std::string& tag) {
709 DCHECK_CURRENTLY_ON(BrowserThread::IO); 709 DCHECK_CURRENTLY_ON(BrowserThread::IO);
710 DCHECK(LookupActiveRegistration(sw_registration_id, tag)); 710 DCHECK(LookupActiveRegistration(sw_registration_id, tag));
711 711
712 BackgroundSyncRegistrations* registrations = 712 BackgroundSyncRegistrations* registrations =
713 &active_registrations_[sw_registration_id]; 713 &active_registrations_[sw_registration_id];
714 714
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 parameters_->max_sync_attempts = max_attempts; 1191 parameters_->max_sync_attempts = max_attempts;
1192 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); 1192 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
1193 } 1193 }
1194 1194
1195 base::Closure BackgroundSyncManager::MakeEmptyCompletion() { 1195 base::Closure BackgroundSyncManager::MakeEmptyCompletion() {
1196 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1196 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1197 return op_scheduler_.WrapCallbackToRunNext(base::Bind(&base::DoNothing)); 1197 return op_scheduler_.WrapCallbackToRunNext(base::Bind(&base::DoNothing));
1198 } 1198 }
1199 1199
1200 } // namespace content 1200 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698