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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/content_export.h"
11 #include "content/public/browser/background_sync_context.h"
15 class BackgroundSyncManager
;
16 class ServiceWorkerContextWrapper
;
18 // Implements the BackgroundSyncContext. One instance of this exists per
19 // StoragePartition, and services multiple child processes/origins. Most logic
20 // is delegated to the owned BackgroundSyncManager instance, which is only
21 // accessed on the IO thread.
22 class CONTENT_EXPORT BackgroundSyncContextImpl
: public BackgroundSyncContext
{
24 BackgroundSyncContextImpl();
26 // Init and Shutdown are for use on the UI thread when the
27 // StoragePartition is being setup and torn down.
28 void Init(const scoped_refptr
<ServiceWorkerContextWrapper
>& context
);
31 // Only callable on the IO thread.
32 BackgroundSyncManager
* background_sync_manager() const override
;
35 ~BackgroundSyncContextImpl() override
;
38 void CreateBackgroundSyncManager(
39 const scoped_refptr
<ServiceWorkerContextWrapper
>& context
);
43 // Only accessed on the IO thread.
44 scoped_ptr
<BackgroundSyncManager
> background_sync_manager_
;
46 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContextImpl
);
49 } // namespace content
51 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_