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

Unified Diff: content/browser/background_sync/background_sync_service_impl.cc

Issue 1283703003: Change ownership of BackgroundSyncServiceImpl to BackgroundSyncContextImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small fixes Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/background_sync/background_sync_service_impl.cc
diff --git a/content/browser/background_sync/background_sync_service_impl.cc b/content/browser/background_sync/background_sync_service_impl.cc
index 0fb81a464420f5dcbc74dfc328c8f64f95d34c23..5ace41e582cbcde1b908e9dc4aa21c18d75ab8c9 100644
--- a/content/browser/background_sync/background_sync_service_impl.cc
+++ b/content/browser/background_sync/background_sync_service_impl.cc
@@ -86,29 +86,8 @@ COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_ONE_SHOT,
COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_MAX,
SyncPeriodicity::SYNC_ONE_SHOT);
-// static
-void BackgroundSyncServiceImpl::Create(
- const scoped_refptr<BackgroundSyncContextImpl>& background_sync_context,
- mojo::InterfaceRequest<BackgroundSyncService> request) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&BackgroundSyncServiceImpl::CreateOnIOThread,
- background_sync_context, base::Passed(&request)));
-}
-
BackgroundSyncServiceImpl::~BackgroundSyncServiceImpl() {
- // Should always be destroyed on the IO thread, but can't check that with
- // DCHECK_CURRENTLY_ON because this class could be destroyed during thread
- // shutdown, at which point that check doesn't work.
-}
-
-// static
-void BackgroundSyncServiceImpl::CreateOnIOThread(
- const scoped_refptr<BackgroundSyncContextImpl>& background_sync_context,
- mojo::InterfaceRequest<BackgroundSyncService> request) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- new BackgroundSyncServiceImpl(background_sync_context, request.Pass());
}
BackgroundSyncServiceImpl::BackgroundSyncServiceImpl(
@@ -118,6 +97,15 @@ BackgroundSyncServiceImpl::BackgroundSyncServiceImpl(
binding_(this, request.Pass()),
weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ binding_.set_connection_error_handler(
+ base::Bind(&BackgroundSyncServiceImpl::OnConnectionError,
+ base::Unretained(this) /* the channel is owned by this */));
+}
+
+void BackgroundSyncServiceImpl::OnConnectionError() {
+ background_sync_context_->ServiceHadConnectionError(this);
+ // |this| is now deleted.
}
void BackgroundSyncServiceImpl::Register(content::SyncRegistrationPtr options,

Powered by Google App Engine
This is Rietveld 408576698