OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_XMPP_LISTENER_H_ |
| 6 #define CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_XMPP_LISTENER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "jingle/notifier/listener/push_client_observer.h" |
| 15 |
| 16 namespace base { |
| 17 |
| 18 class SingleThreadTaskRunner; |
| 19 |
| 20 } // namespace base |
| 21 |
| 22 namespace net { |
| 23 |
| 24 class URLRequestContextGetter; |
| 25 |
| 26 } // namespace net |
| 27 |
| 28 namespace notifier { |
| 29 |
| 30 class PushClient; |
| 31 |
| 32 } // namespace notifier |
| 33 |
| 34 class CloudPrintXmppListener: public notifier::PushClientObserver { |
| 35 public: |
| 36 class Delegate { |
| 37 public: |
| 38 virtual ~Delegate() {} |
| 39 |
| 40 // Invoked when XMPP connection was established. |
| 41 virtual void OnXmppConnected() = 0; |
| 42 |
| 43 // Invoked when server rejected our credentials. |
| 44 virtual void OnXmppAuthError() = 0; |
| 45 |
| 46 // Invoked when server is unavailable. |
| 47 virtual void OnXmppNetworkError() = 0; |
| 48 |
| 49 // Invoked when new printjob was received. |
| 50 virtual void OnXmppNewPrintJob(const std::string& device_id) = 0; |
| 51 |
| 52 // Invoked when local settings was updated. |
| 53 virtual void OnXmppNewLocalSettings(const std::string& device_id) = 0; |
| 54 |
| 55 // Invoked when printer was deleted from server. |
| 56 virtual void OnXmppDeleteNotification(const std::string& device_id) = 0; |
| 57 }; |
| 58 |
| 59 CloudPrintXmppListener( |
| 60 const std::string& robot_email, |
| 61 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 62 Delegate* delegate); |
| 63 |
| 64 virtual ~CloudPrintXmppListener(); |
| 65 |
| 66 // Connects to the server. |
| 67 void Connect(const std::string& access_token); |
| 68 |
| 69 private: |
| 70 // notifier::PushClientObserver methods: |
| 71 virtual void OnNotificationsEnabled() OVERRIDE; |
| 72 virtual void OnNotificationsDisabled( |
| 73 notifier::NotificationsDisabledReason reason) OVERRIDE; |
| 74 virtual void OnIncomingNotification( |
| 75 const notifier::Notification& notification) OVERRIDE; |
| 76 virtual void OnPingResponse() OVERRIDE; |
| 77 |
| 78 // Is used for reconnection when number of retries is now exhausted. |
| 79 void ReconnectInternal(); |
| 80 |
| 81 // Credentials: |
| 82 std::string robot_email_; |
| 83 std::string access_token_; |
| 84 |
| 85 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| 86 |
| 87 // Internal listener. |
| 88 scoped_ptr<notifier::PushClient> push_client_; |
| 89 |
| 90 Delegate* delegate_; |
| 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(CloudPrintXmppListener); |
| 93 }; |
| 94 |
| 95 #endif // CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_XMPP_LISTENER_H_ |
| 96 |
OLD | NEW |