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

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: Fix typo 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
« no previous file with comments | « no previous file | content/browser/background_sync/background_sync_context_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
33
34 // Shutdown must be called before deleting this. Call on the UI thread.
29 void Shutdown(); 35 void Shutdown();
30 36
31 // Only callable on the IO thread. 37 // Create a BackgroundSyncServiceImpl that is owned by this. Call on the UI
38 // thread.
39 void CreateService(mojo::InterfaceRequest<BackgroundSyncService> request);
40
41 // Called by BackgroundSyncServiceImpl objects so that they can
42 // be deleted. Call on the IO thread.
43 void ServiceHadConnectionError(BackgroundSyncServiceImpl* service);
44
45 // Call on the IO thread.
32 BackgroundSyncManager* background_sync_manager() const override; 46 BackgroundSyncManager* background_sync_manager() const override;
33 47
34 protected: 48 protected:
35 ~BackgroundSyncContextImpl() override; 49 ~BackgroundSyncContextImpl() override;
36 50
37 private: 51 private:
38 void CreateBackgroundSyncManager( 52 void CreateBackgroundSyncManager(
39 const scoped_refptr<ServiceWorkerContextWrapper>& context); 53 const scoped_refptr<ServiceWorkerContextWrapper>& context);
40 54
55 void CreateServiceOnIOThread(
56 mojo::InterfaceRequest<BackgroundSyncService> request);
57
41 void ShutdownOnIO(); 58 void ShutdownOnIO();
42 59
43 // Only accessed on the IO thread. 60 // Only accessed on the IO thread.
44 scoped_ptr<BackgroundSyncManager> background_sync_manager_; 61 scoped_ptr<BackgroundSyncManager> background_sync_manager_;
45 62
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_;
67
46 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContextImpl); 68 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContextImpl);
47 }; 69 };
48 70
49 } // namespace content 71 } // namespace content
50 72
51 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_ 73 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/background_sync/background_sync_context_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698