| Index: chrome/service/cloud_print/cloud_print_proxy_backend.cc
|
| diff --git a/chrome/service/cloud_print/cloud_print_proxy_backend.cc b/chrome/service/cloud_print/cloud_print_proxy_backend.cc
|
| index fd11caed6e1713d6640c2ecd80d965784e6067ce..e318c1a1f41a207884729571185959b124cbad05 100644
|
| --- a/chrome/service/cloud_print/cloud_print_proxy_backend.cc
|
| +++ b/chrome/service/cloud_print/cloud_print_proxy_backend.cc
|
| @@ -8,6 +8,7 @@
|
| #include <vector>
|
|
|
| #include "base/bind.h"
|
| +#include "base/compiler_specific.h"
|
| #include "base/file_util.h"
|
| #include "base/rand_util.h"
|
| #include "base/values.h"
|
| @@ -24,8 +25,7 @@
|
| #include "googleurl/src/gurl.h"
|
| #include "grit/generated_resources.h"
|
| #include "jingle/notifier/base/notifier_options.h"
|
| -#include "jingle/notifier/listener/mediator_thread_impl.h"
|
| -#include "jingle/notifier/listener/talk_mediator_impl.h"
|
| +#include "jingle/notifier/listener/push_client.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
|
|
| // The real guts of CloudPrintProxyBackend, to keep the public client API clean.
|
| @@ -33,7 +33,7 @@ class CloudPrintProxyBackend::Core
|
| : public base::RefCountedThreadSafe<CloudPrintProxyBackend::Core>,
|
| public CloudPrintAuth::Client,
|
| public CloudPrintConnector::Client,
|
| - public notifier::TalkMediator::Delegate {
|
| + public notifier::PushClient::Observer {
|
| public:
|
| // It is OK for print_server_url to be empty. In this case system should
|
| // use system default (local) print server.
|
| @@ -80,18 +80,17 @@ class CloudPrintProxyBackend::Core
|
| const std::string& access_token,
|
| const std::string& robot_oauth_refresh_token,
|
| const std::string& robot_email,
|
| - const std::string& user_email);
|
| - virtual void OnInvalidCredentials();
|
| + const std::string& user_email) OVERRIDE;
|
| + virtual void OnInvalidCredentials() OVERRIDE;
|
|
|
| // CloudPrintConnector::Client implementation.
|
| - virtual void OnAuthFailed();
|
| + virtual void OnAuthFailed() OVERRIDE;
|
|
|
| - // notifier::TalkMediator::Delegate implementation.
|
| + // notifier::PushClient::Delegate implementation.
|
| virtual void OnNotificationStateChange(
|
| - bool notifications_enabled);
|
| + bool notifications_enabled) OVERRIDE;
|
| virtual void OnIncomingNotification(
|
| - const notifier::Notification& notification);
|
| - virtual void OnOutgoingNotification();
|
| + const notifier::Notification& notification) OVERRIDE;
|
|
|
| private:
|
| friend class base::RefCountedThreadSafe<Core>;
|
| @@ -143,7 +142,7 @@ class CloudPrintProxyBackend::Core
|
| // OAuth client info.
|
| gaia::OAuthClientInfo oauth_client_info_;
|
| // Notification (xmpp) handler.
|
| - scoped_ptr<notifier::TalkMediator> talk_mediator_;
|
| + scoped_ptr<notifier::PushClient> push_client_;
|
| // Indicates whether XMPP notifications are currently enabled.
|
| bool notifications_enabled_;
|
| // The time when notifications were enabled. Valid only when
|
| @@ -351,10 +350,8 @@ void CloudPrintProxyBackend::Core::OnAuthenticationComplete(
|
| InitNotifications(robot_email, access_token);
|
| } else {
|
| // If we are refreshing a token, update the XMPP token too.
|
| - DCHECK(talk_mediator_.get());
|
| - talk_mediator_->SetAuthToken(robot_email,
|
| - access_token,
|
| - kSyncGaiaServiceId);
|
| + DCHECK(push_client_.get());
|
| + push_client_->UpdateCredentials(robot_email, access_token);
|
| }
|
| // Start cloud print connector if needed.
|
| if (!connector_->IsRunning()) {
|
| @@ -393,16 +390,14 @@ void CloudPrintProxyBackend::Core::InitNotifications(
|
| notifier_options.request_context_getter =
|
| g_service_process->GetServiceURLRequestContextGetter();
|
| notifier_options.auth_mechanism = "X-OAUTH2";
|
| - talk_mediator_.reset(new notifier::TalkMediatorImpl(
|
| - new notifier::MediatorThreadImpl(notifier_options),
|
| - notifier_options));
|
| + push_client_.reset(new notifier::PushClient(notifier_options));
|
| + push_client_->AddObserver(this);
|
| notifier::Subscription subscription;
|
| subscription.channel = kCloudPrintPushNotificationsSource;
|
| subscription.from = kCloudPrintPushNotificationsSource;
|
| - talk_mediator_->AddSubscription(subscription);
|
| - talk_mediator_->SetDelegate(this);
|
| - talk_mediator_->SetAuthToken(robot_email, access_token, kSyncGaiaServiceId);
|
| - talk_mediator_->Login();
|
| + push_client_->UpdateSubscriptions(
|
| + notifier::SubscriptionList(1, subscription));
|
| + push_client_->UpdateCredentials(robot_email, access_token);
|
| }
|
|
|
| void CloudPrintProxyBackend::Core::DoShutdown() {
|
| @@ -412,10 +407,11 @@ void CloudPrintProxyBackend::Core::DoShutdown() {
|
| if (connector_->IsRunning())
|
| connector_->Stop();
|
|
|
| - // Important to delete the TalkMediator on this thread.
|
| - if (talk_mediator_.get())
|
| - talk_mediator_->Logout();
|
| - talk_mediator_.reset();
|
| + // Important to delete the PushClient on this thread.
|
| + if (push_client_.get()) {
|
| + push_client_->RemoveObserver(this);
|
| + }
|
| + push_client_.reset();
|
| notifications_enabled_ = false;
|
| notifications_enabled_since_ = base::TimeTicks();
|
| token_store_.reset();
|
| @@ -536,5 +532,3 @@ void CloudPrintProxyBackend::Core::OnIncomingNotification(
|
| notification.channel.c_str()))
|
| HandlePrinterNotification(notification.data);
|
| }
|
| -
|
| -void CloudPrintProxyBackend::Core::OnOutgoingNotification() {}
|
|
|