OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_FACTORY_H_ |
6 #define CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_FACTORY_H_ | 6 #define CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_FACTORY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/sync/notifier/chrome_sync_notification_bridge.h" | |
13 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" | 12 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" |
14 #include "chrome/browser/sync/util/weak_handle.h" | 13 #include "chrome/browser/sync/util/weak_handle.h" |
15 | 14 |
16 class CommandLine; | 15 class CommandLine; |
17 class Profile; | |
18 | 16 |
19 namespace net { | 17 namespace net { |
20 class URLRequestContextGetter; | 18 class URLRequestContextGetter; |
21 } | 19 } |
22 | 20 |
23 namespace sync_notifier { | 21 namespace sync_notifier { |
24 | 22 |
25 class SyncNotifier; | 23 class SyncNotifier; |
26 | 24 |
27 // Class to instantiate various implementations of the SyncNotifier | 25 // Class to instantiate various implementations of the SyncNotifier |
28 // interface. Must be created/destroyed on the UI thread. | 26 // interface. Must be created/destroyed on the UI thread. |
29 class SyncNotifierFactory { | 27 class SyncNotifierFactory { |
30 public: | 28 public: |
31 // |client_info| is a string identifying the client, e.g. a user | 29 // |client_info| is a string identifying the client, e.g. a user |
32 // agent string. |invalidation_version_tracker| may be NULL (for | 30 // agent string. |invalidation_version_tracker| may be NULL (for |
33 // tests). | 31 // tests). |
34 SyncNotifierFactory( | 32 SyncNotifierFactory( |
35 const Profile* profile, | |
36 const std::string& client_info, | 33 const std::string& client_info, |
37 const scoped_refptr<net::URLRequestContextGetter>& | 34 const scoped_refptr<net::URLRequestContextGetter>& |
38 request_context_getter, | 35 request_context_getter, |
39 const base::WeakPtr<InvalidationVersionTracker>& | 36 const base::WeakPtr<InvalidationVersionTracker>& |
40 invalidation_version_tracker, | 37 invalidation_version_tracker, |
41 const CommandLine& command_line); | 38 const CommandLine& command_line); |
42 ~SyncNotifierFactory(); | 39 ~SyncNotifierFactory(); |
43 | 40 |
44 // Creates a sync notifier. Caller takes ownership of the returned | 41 // Creates a sync notifier. Caller takes ownership of the returned |
45 // object. However, the returned object must not outlive the | 42 // object. However, the returned object must not outlive the |
46 // factory from which it was created. Can be called on any thread. | 43 // factory from which it was created. Can be called on any thread. |
47 SyncNotifier* CreateSyncNotifier(); | 44 SyncNotifier* CreateSyncNotifier(); |
48 | 45 |
49 private: | 46 private: |
50 // A thread-safe listener for handling notifications triggered by chrome | |
51 // events. | |
52 ChromeSyncNotificationBridge chrome_notification_bridge_; | |
53 | |
54 const std::string client_info_; | 47 const std::string client_info_; |
55 const scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 48 const scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
56 const InvalidationVersionMap initial_max_invalidation_versions_; | 49 const InvalidationVersionMap initial_max_invalidation_versions_; |
57 const browser_sync::WeakHandle<InvalidationVersionTracker> | 50 const browser_sync::WeakHandle<InvalidationVersionTracker> |
58 invalidation_version_tracker_; | 51 invalidation_version_tracker_; |
59 const CommandLine& command_line_; | 52 const CommandLine& command_line_; |
60 }; | 53 }; |
61 | 54 |
62 } // namespace sync_notifier | 55 } // namespace sync_notifier |
63 | 56 |
64 #endif // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_FACTORY_H_ | 57 #endif // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_FACTORY_H_ |
OLD | NEW |