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

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

Issue 1059183004: [BackgroundSyncManager] Remove dead code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove moar! Created 5 years, 8 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
« no previous file with comments | « content/browser/background_sync/background_sync_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/barrier_closure.h" 7 #include "base/barrier_closure.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "content/browser/background_sync/background_sync.pb.h" 9 #include "content/browser/background_sync/background_sync.pb.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 return; 375 return;
376 } 376 }
377 377
378 // TODO(jkarlin): Run the registration algorithm. 378 // TODO(jkarlin): Run the registration algorithm.
379 base::MessageLoop::current()->PostTask( 379 base::MessageLoop::current()->PostTask(
380 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, new_registration)); 380 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, new_registration));
381 } 381 }
382 382
383 void BackgroundSyncManager::RemoveRegistrationFromMap( 383 void BackgroundSyncManager::RemoveRegistrationFromMap(
384 int64 sw_registration_id, 384 int64 sw_registration_id,
385 const std::string& sync_registration_name, 385 const std::string& sync_registration_name) {
386 BackgroundSyncRegistration* old_registration) {
387 DCHECK( 386 DCHECK(
388 LookupRegistration(sw_registration_id, sync_registration_name, nullptr)); 387 LookupRegistration(sw_registration_id, sync_registration_name, nullptr));
389 388
390 BackgroundSyncRegistrations* registrations = 389 BackgroundSyncRegistrations* registrations =
391 &sw_to_registrations_map_[sw_registration_id]; 390 &sw_to_registrations_map_[sw_registration_id];
392 391
393 const auto name_and_registration_iter = 392 registrations->name_to_registration_map.erase(sync_registration_name);
394 registrations->name_to_registration_map.find(sync_registration_name);
395 if (old_registration)
396 *old_registration = name_and_registration_iter->second;
397
398 registrations->name_to_registration_map.erase(name_and_registration_iter);
399 } 393 }
400 394
401 void BackgroundSyncManager::AddRegistrationToMap( 395 void BackgroundSyncManager::AddRegistrationToMap(
402 int64 sw_registration_id, 396 int64 sw_registration_id,
403 const BackgroundSyncRegistration& sync_registration) { 397 const BackgroundSyncRegistration& sync_registration) {
404 DCHECK_NE(BackgroundSyncRegistration::kInvalidRegistrationId, 398 DCHECK_NE(BackgroundSyncRegistration::kInvalidRegistrationId,
405 sw_registration_id); 399 sw_registration_id);
406 400
407 BackgroundSyncRegistrations* registrations = 401 BackgroundSyncRegistrations* registrations =
408 &sw_to_registrations_map_[sw_registration_id]; 402 &sw_to_registrations_map_[sw_registration_id];
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 438
445 BackgroundSyncRegistration existing_registration; 439 BackgroundSyncRegistration existing_registration;
446 if (!LookupRegistration(sw_registration_id, sync_registration_name, 440 if (!LookupRegistration(sw_registration_id, sync_registration_name,
447 &existing_registration) || 441 &existing_registration) ||
448 existing_registration.id != sync_registration_id) { 442 existing_registration.id != sync_registration_id) {
449 base::MessageLoop::current()->PostTask( 443 base::MessageLoop::current()->PostTask(
450 FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND)); 444 FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND));
451 return; 445 return;
452 } 446 }
453 447
454 BackgroundSyncRegistration old_sync_registration; 448 RemoveRegistrationFromMap(sw_registration_id, sync_registration_name);
455 RemoveRegistrationFromMap(sw_registration_id, sync_registration_name,
456 &old_sync_registration);
457 449
458 StoreRegistrations( 450 StoreRegistrations(
459 origin, sw_registration_id, 451 origin, sw_registration_id,
460 base::Bind(&BackgroundSyncManager::UnregisterDidStore, 452 base::Bind(&BackgroundSyncManager::UnregisterDidStore,
461 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, 453 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, callback));
462 old_sync_registration, callback));
463 } 454 }
464 455
465 void BackgroundSyncManager::UnregisterDidStore( 456 void BackgroundSyncManager::UnregisterDidStore(
466 int64 sw_registration_id, 457 int64 sw_registration_id,
467 const BackgroundSyncRegistration& old_sync_registration,
468 const StatusCallback& callback, 458 const StatusCallback& callback,
469 ServiceWorkerStatusCode status) { 459 ServiceWorkerStatusCode status) {
470 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { 460 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) {
471 // ServiceWorker was unregistered. 461 // ServiceWorker was unregistered.
472 sw_to_registrations_map_.erase(sw_registration_id); 462 sw_to_registrations_map_.erase(sw_registration_id);
473 base::MessageLoop::current()->PostTask( 463 base::MessageLoop::current()->PostTask(
474 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); 464 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE));
475 return; 465 return;
476 } 466 }
477 467
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 weak_ptr_factory_.GetWeakPtr(), callback); 559 weak_ptr_factory_.GetWeakPtr(), callback);
570 } 560 }
571 561
572 BackgroundSyncManager::StatusCallback 562 BackgroundSyncManager::StatusCallback
573 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { 563 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) {
574 return base::Bind(&BackgroundSyncManager::PendingStatusCallback, 564 return base::Bind(&BackgroundSyncManager::PendingStatusCallback,
575 weak_ptr_factory_.GetWeakPtr(), callback); 565 weak_ptr_factory_.GetWeakPtr(), callback);
576 } 566 }
577 567
578 } // namespace content 568 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/background_sync/background_sync_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698