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"
14 class BackgroundSyncManager
;
15 class ServiceWorkerContextWrapper
;
17 // One instance of this exists per StoragePartition, and services multiple
18 // child processes/origins. Most logic is delegated to the owned
19 // BackgroundSyncManager instance, which is only accessed on the IO
21 // TODO(jkarlin): Make a public/ BackgroundSyncContext.
22 class CONTENT_EXPORT BackgroundSyncContextImpl
23 : public base::RefCountedThreadSafe
<BackgroundSyncContextImpl
> {
25 BackgroundSyncContextImpl();
27 // Init and Shutdown are for use on the UI thread when the profile,
28 // storagepartition is being setup and torn down.
29 void Init(const scoped_refptr
<ServiceWorkerContextWrapper
>& context
);
32 // Only callable on the IO thread.
33 BackgroundSyncManager
* background_sync_manager() const;
36 friend class base::RefCountedThreadSafe
<BackgroundSyncContextImpl
>;
38 ~BackgroundSyncContextImpl();
40 void CreateBackgroundSyncManager(
41 const scoped_refptr
<ServiceWorkerContextWrapper
>& context
);
45 // Only accessed on the IO thread.
46 scoped_ptr
<BackgroundSyncManager
> background_sync_manager_
;
48 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContextImpl
);
51 } // namespace content
53 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_