Permission messages: Add a bunch of missing combinations/suppressions.
[chromium-blink-merge.git] / content / browser / background_sync / background_sync_context_impl.h
blobbf252071d3009c230f8d18253647b0d9f271ff91
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 <set>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/background_sync_service.mojom.h"
13 #include "content/common/content_export.h"
14 #include "content/public/browser/background_sync_context.h"
16 namespace content {
18 class BackgroundSyncManager;
19 class BackgroundSyncServiceImpl;
20 class ServiceWorkerContextWrapper;
22 // Implements the BackgroundSyncContext. One instance of this exists per
23 // StoragePartition, and services multiple child processes/origins. Most logic
24 // is delegated to the owned BackgroundSyncManager instance, which is only
25 // accessed on the IO thread.
26 class CONTENT_EXPORT BackgroundSyncContextImpl : public BackgroundSyncContext {
27 public:
28 BackgroundSyncContextImpl();
30 // Init and Shutdown are for use on the UI thread when the
31 // StoragePartition is being setup and torn down.
32 void Init(const scoped_refptr<ServiceWorkerContextWrapper>& context);
34 // Shutdown must be called before deleting this. Call on the UI thread.
35 void Shutdown();
37 // Create a BackgroundSyncServiceImpl that is owned by this. Call on the UI
38 // thread.
39 void CreateService(mojo::InterfaceRequest<BackgroundSyncService> request);
41 // Called by BackgroundSyncServiceImpl objects so that they can
42 // be deleted. Call on the IO thread.
43 void ServiceHadConnectionError(BackgroundSyncServiceImpl* service);
45 // Call on the IO thread.
46 BackgroundSyncManager* background_sync_manager() const override;
48 protected:
49 ~BackgroundSyncContextImpl() override;
51 private:
52 void CreateBackgroundSyncManager(
53 const scoped_refptr<ServiceWorkerContextWrapper>& context);
55 void CreateServiceOnIOThread(
56 mojo::InterfaceRequest<BackgroundSyncService> request);
58 void ShutdownOnIO();
60 // Only accessed on the IO thread.
61 scoped_ptr<BackgroundSyncManager> background_sync_manager_;
63 // The services are owned by this. They're either deleted
64 // during ShutdownOnIO or when the channel is closed via
65 // ServiceHadConnectionError. Only accessed on the IO thread.
66 std::set<BackgroundSyncServiceImpl*> services_;
68 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContextImpl);
71 } // namespace content
73 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_