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

Side by Side Diff: content/browser/background_sync/background_sync_context_impl.h

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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_ 5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_ 6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_
7 7
8 #include <set>
9
8 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/background_sync_service.mojom.h"
10 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
11 #include "content/public/browser/background_sync_context.h" 14 #include "content/public/browser/background_sync_context.h"
12 15
13 namespace content { 16 namespace content {
14 17
15 class BackgroundSyncManager; 18 class BackgroundSyncManager;
19 class BackgroundSyncServiceImpl;
16 class ServiceWorkerContextWrapper; 20 class ServiceWorkerContextWrapper;
17 21
18 // Implements the BackgroundSyncContext. One instance of this exists per 22 // Implements the BackgroundSyncContext. One instance of this exists per
19 // StoragePartition, and services multiple child processes/origins. Most logic 23 // StoragePartition, and services multiple child processes/origins. Most logic
20 // is delegated to the owned BackgroundSyncManager instance, which is only 24 // is delegated to the owned BackgroundSyncManager instance, which is only
21 // accessed on the IO thread. 25 // accessed on the IO thread.
22 class CONTENT_EXPORT BackgroundSyncContextImpl : public BackgroundSyncContext { 26 class CONTENT_EXPORT BackgroundSyncContextImpl : public BackgroundSyncContext {
23 public: 27 public:
24 BackgroundSyncContextImpl(); 28 BackgroundSyncContextImpl();
25 29
26 // Init and Shutdown are for use on the UI thread when the 30 // Init and Shutdown are for use on the UI thread when the
27 // StoragePartition is being setup and torn down. 31 // StoragePartition is being setup and torn down.
28 void Init(const scoped_refptr<ServiceWorkerContextWrapper>& context); 32 void Init(const scoped_refptr<ServiceWorkerContextWrapper>& context);
29 void Shutdown(); 33 void Shutdown();
30 34
31 // Only callable on the IO thread. 35 // Only callable on the IO thread.
32 BackgroundSyncManager* background_sync_manager() const override; 36 BackgroundSyncManager* background_sync_manager() const override;
33 37
38 // Create a BackgroundSyncServiceImpl that is owned by this.
39 static void CreateService(
40 const scoped_refptr<BackgroundSyncContextImpl>& context,
41 mojo::InterfaceRequest<BackgroundSyncService> request);
42 void CreateServiceOnIOThread(
43 mojo::InterfaceRequest<BackgroundSyncService> request);
44
45 // Called by BackgroundSyncServciceImpl objects so that they can
46 // be deleted.
47 void ServiceHadConnectionError(BackgroundSyncServiceImpl* service);
48
34 protected: 49 protected:
35 ~BackgroundSyncContextImpl() override; 50 ~BackgroundSyncContextImpl() override;
36 51
37 private: 52 private:
38 void CreateBackgroundSyncManager( 53 void CreateBackgroundSyncManager(
39 const scoped_refptr<ServiceWorkerContextWrapper>& context); 54 const scoped_refptr<ServiceWorkerContextWrapper>& context);
40 55
41 void ShutdownOnIO(); 56 void ShutdownOnIO();
42 57
43 // Only accessed on the IO thread. 58 // Only accessed on the IO thread.
44 scoped_ptr<BackgroundSyncManager> background_sync_manager_; 59 scoped_ptr<BackgroundSyncManager> background_sync_manager_;
45 60
61 // The services are owned by this. They're either deleted
62 // during ShutdownOnIO or when the channel is closed via
63 // ServiceHadConnectionError.
64 std::set<BackgroundSyncServiceImpl*> services_;
65
46 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContextImpl); 66 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContextImpl);
47 }; 67 };
48 68
49 } // namespace content 69 } // namespace content
50 70
51 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_ 71 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698