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

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

Issue 1960843002: [OnionSoup] Move background_sync.mojom from //content to //third_party/WebKit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address dcheng@'s comment Created 4 years, 7 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_H_ 5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_H_
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_H_ 6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "content/common/background_sync_service.mojom.h"
14 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "third_party/WebKit/public/platform/modules/background_sync/background_ sync.mojom.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 class BackgroundSyncManager; 18 class BackgroundSyncManager;
19 class BackgroundSyncServiceImpl; 19 class BackgroundSyncServiceImpl;
20 class ServiceWorkerContextWrapper; 20 class ServiceWorkerContextWrapper;
21 21
22 // One instance of this exists per StoragePartition, and services multiple child 22 // One instance of this exists per StoragePartition, and services multiple child
23 // processes/origins. Most logic is delegated to the owned BackgroundSyncManager 23 // processes/origins. Most logic is delegated to the owned BackgroundSyncManager
24 // instance, which is only accessed on the IO thread. 24 // instance, which is only accessed on the IO thread.
25 class CONTENT_EXPORT BackgroundSyncContext 25 class CONTENT_EXPORT BackgroundSyncContext
26 : public base::RefCountedThreadSafe<BackgroundSyncContext> { 26 : public base::RefCountedThreadSafe<BackgroundSyncContext> {
27 public: 27 public:
28 BackgroundSyncContext(); 28 BackgroundSyncContext();
29 29
30 // 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
31 // StoragePartition is being setup and torn down. 31 // StoragePartition is being setup and torn down.
32 void Init(const scoped_refptr<ServiceWorkerContextWrapper>& context); 32 void Init(const scoped_refptr<ServiceWorkerContextWrapper>& context);
33 33
34 // Shutdown must be called before deleting this. Call on the UI thread. 34 // Shutdown must be called before deleting this. Call on the UI thread.
35 void Shutdown(); 35 void Shutdown();
36 36
37 // Create a BackgroundSyncServiceImpl that is owned by this. Call on the UI 37 // Create a BackgroundSyncServiceImpl that is owned by this. Call on the UI
38 // thread. 38 // thread.
39 void CreateService( 39 void CreateService(
40 mojo::InterfaceRequest<mojom::BackgroundSyncService> request); 40 mojo::InterfaceRequest<blink::mojom::BackgroundSyncService> request);
41 41
42 // Called by BackgroundSyncServiceImpl objects so that they can 42 // Called by BackgroundSyncServiceImpl objects so that they can
43 // be deleted. Call on the IO thread. 43 // be deleted. Call on the IO thread.
44 void ServiceHadConnectionError(BackgroundSyncServiceImpl* service); 44 void ServiceHadConnectionError(BackgroundSyncServiceImpl* service);
45 45
46 // Call on the IO thread. 46 // Call on the IO thread.
47 BackgroundSyncManager* background_sync_manager() const; 47 BackgroundSyncManager* background_sync_manager() const;
48 48
49 protected: 49 protected:
50 friend class base::RefCountedThreadSafe<BackgroundSyncContext>; 50 friend class base::RefCountedThreadSafe<BackgroundSyncContext>;
51 virtual ~BackgroundSyncContext(); 51 virtual ~BackgroundSyncContext();
52 52
53 void set_background_sync_manager_for_testing( 53 void set_background_sync_manager_for_testing(
54 std::unique_ptr<BackgroundSyncManager> manager); 54 std::unique_ptr<BackgroundSyncManager> manager);
55 55
56 private: 56 private:
57 friend class BackgroundSyncServiceImplTest; 57 friend class BackgroundSyncServiceImplTest;
58 58
59 virtual void CreateBackgroundSyncManager( 59 virtual void CreateBackgroundSyncManager(
60 scoped_refptr<ServiceWorkerContextWrapper> context); 60 scoped_refptr<ServiceWorkerContextWrapper> context);
61 61
62 void CreateServiceOnIOThread( 62 void CreateServiceOnIOThread(
63 mojo::InterfaceRequest<mojom::BackgroundSyncService> request); 63 mojo::InterfaceRequest<blink::mojom::BackgroundSyncService> request);
64 64
65 void ShutdownOnIO(); 65 void ShutdownOnIO();
66 66
67 // Only accessed on the IO thread. 67 // Only accessed on the IO thread.
68 std::unique_ptr<BackgroundSyncManager> background_sync_manager_; 68 std::unique_ptr<BackgroundSyncManager> background_sync_manager_;
69 69
70 // The services are owned by this. They're either deleted 70 // The services are owned by this. They're either deleted
71 // during ShutdownOnIO or when the channel is closed via 71 // during ShutdownOnIO or when the channel is closed via
72 // ServiceHadConnectionError. Only accessed on the IO thread. 72 // ServiceHadConnectionError. Only accessed on the IO thread.
73 std::set<BackgroundSyncServiceImpl*> services_; 73 std::set<BackgroundSyncServiceImpl*> services_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContext); 75 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContext);
76 }; 76 };
77 77
78 } // namespace content 78 } // namespace content
79 79
80 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_H_ 80 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698