rAc - revert invalid suggestions to edit mode
[chromium-blink-merge.git] / sync / notifier / push_client_channel.h
blob5e4f92b06ab23d03477157edcec0aa7518c2a815
1 // Copyright 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.
5 #ifndef SYNC_NOTIFIER_PUSH_CLIENT_CHANNEL_H_
6 #define SYNC_NOTIFIER_PUSH_CLIENT_CHANNEL_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "jingle/notifier/listener/push_client_observer.h"
14 #include "sync/base/sync_export.h"
15 #include "sync/notifier/sync_system_resources.h"
17 namespace notifier {
18 class PushClient;
19 } // namespace notifier
21 namespace syncer {
23 // A PushClientChannel is an implementation of NetworkChannel that
24 // routes messages through a PushClient.
25 class SYNC_EXPORT_PRIVATE PushClientChannel
26 : public SyncNetworkChannel,
27 public NON_EXPORTED_BASE(notifier::PushClientObserver) {
28 public:
29 // |push_client| is guaranteed to be destroyed only when this object
30 // is destroyed.
31 explicit PushClientChannel(scoped_ptr<notifier::PushClient> push_client);
33 virtual ~PushClientChannel();
35 // If not connected, connects with the given credentials. If
36 // already connected, the next connection attempt will use the given
37 // credentials.
38 virtual void UpdateCredentials(const std::string& email,
39 const std::string& token) OVERRIDE;
41 // SyncNetworkChannel implementation.
42 virtual void SendEncodedMessage(const std::string& encoded_message) OVERRIDE;
44 // notifier::PushClient::Observer implementation.
45 virtual void OnNotificationsEnabled() OVERRIDE;
46 virtual void OnNotificationsDisabled(
47 notifier::NotificationsDisabledReason reason) OVERRIDE;
48 virtual void OnIncomingNotification(
49 const notifier::Notification& notification) OVERRIDE;
51 private:
52 scoped_ptr<notifier::PushClient> push_client_;
54 DISALLOW_COPY_AND_ASSIGN(PushClientChannel);
57 } // namespace syncer
59 #endif // SYNC_NOTIFIER_PUSH_CLIENT_CHANNEL_H_