Index: content/browser/background_sync/background_sync_manager.cc |
diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc |
index 3560267144437fea2b3b32ba231a6fd6702303b1..479ccad99861e25b2cce3e88cf7952e4eb52c38c 100644 |
--- a/content/browser/background_sync/background_sync_manager.cc |
+++ b/content/browser/background_sync/background_sync_manager.cc |
@@ -23,7 +23,6 @@ |
#include "content/public/browser/browser_thread.h" |
#if defined(OS_ANDROID) |
-#include "content/browser/android/background_sync_launcher_android.h" |
#include "content/browser/android/background_sync_network_observer_android.h" |
#endif |
@@ -981,17 +980,36 @@ void BackgroundSyncManager::SchedulePendingRegistrations() { |
} |
} |
- // TODO(jkarlin): Use the context's path instead of the 'this' pointer as an |
- // identifier. See crbug.com/489705. |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |
- base::Bind(&BackgroundSyncLauncherAndroid::LaunchBrowserWhenNextOnline, |
- this, keep_browser_alive_for_one_shot)); |
+ base::Bind(&BackgroundSyncManager::SchedulePendingRegistrationsOnUIThread, |
+ base::Unretained(this), keep_browser_alive_for_one_shot)); |
+ |
#else |
// TODO(jkarlin): Toggle Chrome's background mode. |
#endif |
} |
+void BackgroundSyncManager::SchedulePendingRegistrationsOnUIThread( |
+ bool keep_browser_alive_for_one_shot) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ if (!service_worker_context_) // happens in tests? |
+ return; |
+ StoragePartitionImpl* storage_partition_impl = |
+ service_worker_context_->storage_partition(); |
+ if (!storage_partition_impl) // happens in tests |
+ return; |
+ BackgroundSyncController* background_sync_controller = |
+ storage_partition_impl->browser_context()->GetBackgroundSyncController(); |
jkarlin
2015/10/14 18:30:29
It seems like the above code should be consolidate
iclelland
2015/10/14 19:31:24
Done. That's a good idea. I've refactored the othe
|
+ |
+ if (background_sync_controller) { |
+ // TODO(jkarlin): Use the context's path instead of the 'this' pointer as an |
+ // identifier. See crbug.com/489705. |
+ background_sync_controller->LaunchBrowserWhenNextOnline( |
+ this, keep_browser_alive_for_one_shot); |
+ } |
+} |
+ |
void BackgroundSyncManager::FireReadyEvents() { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |