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 SYNC_NOTIFIER_PUSH_CLIENT_CHANNEL_H_ | 5 #ifndef SYNC_NOTIFIER_PUSH_CLIENT_CHANNEL_H_ |
6 #define SYNC_NOTIFIER_PUSH_CLIENT_CHANNEL_H_ | 6 #define SYNC_NOTIFIER_PUSH_CLIENT_CHANNEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "google/cacheinvalidation/include/system-resources.h" | 15 #include "google/cacheinvalidation/include/system-resources.h" |
16 #include "jingle/notifier/listener/push_client_observer.h" | 16 #include "jingle/notifier/listener/push_client_observer.h" |
17 | 17 |
18 namespace notifier { | 18 namespace notifier { |
19 class PushClient; | 19 class PushClient; |
20 } // namespace notifier | 20 } // namespace notifier |
21 | 21 |
22 namespace sync_notifier { | 22 namespace sync_notifier { |
23 | 23 |
24 // A PushClientChannel is an implementation of NetworkChannel that | 24 // A PushClientChannel is an implementation of NetworkChannel that |
25 // routes messages through a PushClient. | 25 // routes messages through a PushClient. |
26 class PushClientChannel | 26 class PushClientChannel |
27 : public invalidation::NetworkChannel, | 27 : public invalidation::NetworkChannel, |
28 public notifier::PushClientObserver { | 28 public notifier::PushClientObserver { |
29 public: | 29 public: |
| 30 // |push_client| is guaranteed to be destroyed only when this object |
| 31 // is destroyed. |
30 explicit PushClientChannel(scoped_ptr<notifier::PushClient> push_client); | 32 explicit PushClientChannel(scoped_ptr<notifier::PushClient> push_client); |
31 | 33 |
32 virtual ~PushClientChannel(); | 34 virtual ~PushClientChannel(); |
33 | 35 |
34 // If not connected, connects with the given credentials. If | 36 // If not connected, connects with the given credentials. If |
35 // already connected, the next connection attempt will use the given | 37 // already connected, the next connection attempt will use the given |
36 // credentials. | 38 // credentials. |
37 void UpdateCredentials(const std::string& email, const std::string& token); | 39 void UpdateCredentials(const std::string& email, const std::string& token); |
38 | 40 |
39 // invalidation::NetworkChannel implementation. | 41 // invalidation::NetworkChannel implementation. |
40 virtual void SendMessage(const std::string& outgoing_message) OVERRIDE; | 42 virtual void SendMessage(const std::string& outgoing_message) OVERRIDE; |
41 virtual void SetMessageReceiver( | 43 virtual void SetMessageReceiver( |
42 invalidation::MessageCallback* incoming_receiver) OVERRIDE; | 44 invalidation::MessageCallback* incoming_receiver) OVERRIDE; |
43 virtual void AddNetworkStatusReceiver( | 45 virtual void AddNetworkStatusReceiver( |
44 invalidation::NetworkStatusCallback* network_status_receiver) OVERRIDE; | 46 invalidation::NetworkStatusCallback* network_status_receiver) OVERRIDE; |
45 virtual void SetSystemResources( | 47 virtual void SetSystemResources( |
46 invalidation::SystemResources* resources) OVERRIDE; | 48 invalidation::SystemResources* resources) OVERRIDE; |
47 | 49 |
48 // notifier::PushClient::Observer implementation. | 50 // notifier::PushClient::Observer implementation. |
49 virtual void OnNotificationStateChange(bool notifications_enabled) OVERRIDE; | 51 virtual void OnNotificationsEnabled() OVERRIDE; |
| 52 virtual void OnNotificationsDisabled( |
| 53 notifier::NotificationsDisabledReason reason) OVERRIDE; |
50 virtual void OnIncomingNotification( | 54 virtual void OnIncomingNotification( |
51 const notifier::Notification& notification) OVERRIDE; | 55 const notifier::Notification& notification) OVERRIDE; |
52 | 56 |
53 const std::string& GetServiceContextForTest() const; | 57 const std::string& GetServiceContextForTest() const; |
54 | 58 |
55 int64 GetSchedulingHashForTest() const; | 59 int64 GetSchedulingHashForTest() const; |
56 | 60 |
57 static notifier::Notification EncodeMessageForTest( | 61 static notifier::Notification EncodeMessageForTest( |
58 const std::string& message, | 62 const std::string& message, |
59 const std::string& service_context, | 63 const std::string& service_context, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 95 |
92 // Scheduling hash. | 96 // Scheduling hash. |
93 int64 scheduling_hash_; | 97 int64 scheduling_hash_; |
94 | 98 |
95 DISALLOW_COPY_AND_ASSIGN(PushClientChannel); | 99 DISALLOW_COPY_AND_ASSIGN(PushClientChannel); |
96 }; | 100 }; |
97 | 101 |
98 } // namespace sync_notifier | 102 } // namespace sync_notifier |
99 | 103 |
100 #endif // SYNC_NOTIFIER_PUSH_CLIENT_CHANNEL_H_ | 104 #endif // SYNC_NOTIFIER_PUSH_CLIENT_CHANNEL_H_ |
OLD | NEW |