OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_BRIDGED_SYNC_NOTIFIER_H_ | |
6 #define CHROME_BROWSER_SYNC_NOTIFIER_BRIDGED_SYNC_NOTIFIER_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "chrome/browser/sync/notifier/sync_notifier.h" | |
11 | |
12 namespace sync_notifier { | |
13 | |
14 class ChromeSyncNotificationBridge; | |
15 | |
16 // A SyncNotifier implementation that wraps a ChromeSyncNotificationBridge | |
17 // and a SyncNotifier delegate (which it takes ownership of). All SyncNotifier | |
18 // calls are passed straight through to the delegate, with the exception of | |
19 // AddObserver/RemoveObserver, which also result in the observer being | |
20 // registered/deregistered with the ChromeSyncNotificationBridge. | |
21 class BridgedSyncNotifier : public SyncNotifier { | |
22 public: | |
23 // Does not take ownership of |bridge|. Takes ownership of |delegate|. | |
24 BridgedSyncNotifier(ChromeSyncNotificationBridge* bridge, | |
25 SyncNotifier* delegate); | |
26 virtual ~BridgedSyncNotifier(); | |
27 | |
28 // SyncNotifier implementation. Passes through all calls to the delegate. | |
29 // AddObserver/RemoveObserver will also register/deregister |observer| with | |
30 // the bridge. | |
31 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; | |
32 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; | |
33 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; | |
34 virtual void SetState(const std::string& state) OVERRIDE; | |
35 virtual void UpdateCredentials( | |
36 const std::string& email, const std::string& token) OVERRIDE; | |
37 virtual void UpdateEnabledTypes( | |
38 syncable::ModelTypeSet enabled_types) OVERRIDE; | |
39 virtual void SendNotification( | |
40 syncable::ModelTypeSet changed_types) OVERRIDE; | |
41 | |
42 private: | |
43 // The notification bridge that we register the observers with. | |
44 ChromeSyncNotificationBridge* bridge_; | |
45 | |
46 // The delegate we are wrapping. | |
47 scoped_ptr<SyncNotifier> delegate_; | |
48 }; | |
49 | |
50 } // namespace sync_notifier | |
51 | |
52 #endif // CHROME_BROWSER_SYNC_NOTIFIER_BRIDGED_SYNC_NOTIFIER_H_ | |
OLD | NEW |