| OLD | NEW |
| 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 "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 if (status_code != SERVICE_WORKER_OK) { | 1027 if (status_code != SERVICE_WORKER_OK) { |
| 1028 // TODO(jkarlin) Fire the sync event on the next page load controlled by | 1028 // TODO(jkarlin) Fire the sync event on the next page load controlled by |
| 1029 // this registration. (crbug.com/479665) | 1029 // this registration. (crbug.com/479665) |
| 1030 registration->set_sync_state(BACKGROUND_SYNC_STATE_FAILED); | 1030 registration->set_sync_state(BACKGROUND_SYNC_STATE_FAILED); |
| 1031 } else { | 1031 } else { |
| 1032 RegistrationKey key(*registration); | 1032 RegistrationKey key(*registration); |
| 1033 // Remove the registration if it's still active. | 1033 // Remove the registration if it's still active. |
| 1034 RefCountedRegistration* active_registration = | 1034 RefCountedRegistration* active_registration = |
| 1035 LookupActiveRegistration(service_worker_id, key); | 1035 LookupActiveRegistration(service_worker_id, key); |
| 1036 if (active_registration && | 1036 if (active_registration && |
| 1037 active_registration->value()->id() == registration->id()) | 1037 active_registration->value()->id() == registration->id()) { |
| 1038 RemoveActiveRegistration(service_worker_id, key); | 1038 RemoveActiveRegistration(service_worker_id, key); |
| 1039 } |
| 1039 } | 1040 } |
| 1040 } else { | 1041 } else { |
| 1041 // TODO(jkarlin): Add support for running periodic syncs. (crbug.com/479674) | 1042 // TODO(jkarlin): Add support for running periodic syncs. (crbug.com/479674) |
| 1042 NOTREACHED(); | 1043 NOTREACHED(); |
| 1043 } | 1044 } |
| 1044 | 1045 |
| 1045 StoreRegistrations( | 1046 StoreRegistrations( |
| 1046 service_worker_id, | 1047 service_worker_id, |
| 1047 base::Bind(&BackgroundSyncManager::EventCompleteDidStore, | 1048 base::Bind(&BackgroundSyncManager::EventCompleteDidStore, |
| 1048 weak_ptr_factory_.GetWeakPtr(), service_worker_id, callback)); | 1049 weak_ptr_factory_.GetWeakPtr(), service_worker_id, callback)); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { | 1185 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { |
| 1185 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1186 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1186 | 1187 |
| 1187 return base::Bind( | 1188 return base::Bind( |
| 1188 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, | 1189 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, |
| 1189 BackgroundSyncStatus>, | 1190 BackgroundSyncStatus>, |
| 1190 weak_ptr_factory_.GetWeakPtr(), callback); | 1191 weak_ptr_factory_.GetWeakPtr(), callback); |
| 1191 } | 1192 } |
| 1192 | 1193 |
| 1193 } // namespace content | 1194 } // namespace content |
| OLD | NEW |