summaryrefslogtreecommitdiffstats
path: root/chrome/service
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-17 02:11:48 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-17 02:11:48 +0000
commitfc43868654630100e0f5dd7beef20464ea434679 (patch)
treec3cb020b3b42959736480e33ef7c0c6ee050ccee /chrome/service
parent4593aa2be388ee1e028399d43e4e3f4d4491b5a2 (diff)
downloadchromium_src-fc43868654630100e0f5dd7beef20464ea434679.zip
chromium_src-fc43868654630100e0f5dd7beef20464ea434679.tar.gz
chromium_src-fc43868654630100e0f5dd7beef20464ea434679.tar.bz2
[Sync] Replace TalkMediator*/MediatorThread* with PushClient
Streamline methods of PushClient and its Observer subclass. Remove sync/protocol/service_constants.h and consolidate use of each constant in one place. Remove duplicate constant in cloud print code. BUG=76764 TEST= TBR=estade@chromium.org Review URL: https://chromiumcodereview.appspot.com/10398051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137615 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r--chrome/service/cloud_print/cloud_print_consts.cc1
-rw-r--r--chrome/service/cloud_print/cloud_print_consts.h1
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy_backend.cc50
3 files changed, 22 insertions, 30 deletions
diff --git a/chrome/service/cloud_print/cloud_print_consts.cc b/chrome/service/cloud_print/cloud_print_consts.cc
index ee3f42b..eb65207 100644
--- a/chrome/service/cloud_print/cloud_print_consts.cc
+++ b/chrome/service/cloud_print/cloud_print_consts.cc
@@ -34,7 +34,6 @@ const char kTagDryRunFlag[] = "__cp__dry_run";
const char kDefaultCloudPrintServerUrl[] = "https://www.google.com/cloudprint";
const char kCloudPrintGaiaServiceId[] = "cloudprint";
-const char kSyncGaiaServiceId[] = "chromiumsync";
const char kProxyAuthUserAgent[] = "ChromiumBrowser";
const char kCloudPrintPushNotificationsSource[] = "cloudprint.google.com";
diff --git a/chrome/service/cloud_print/cloud_print_consts.h b/chrome/service/cloud_print/cloud_print_consts.h
index c860448..b06c225 100644
--- a/chrome/service/cloud_print/cloud_print_consts.h
+++ b/chrome/service/cloud_print/cloud_print_consts.h
@@ -36,7 +36,6 @@ extern const char kTagsHashTagName[];
extern const char kTagDryRunFlag[];
extern const char kDefaultCloudPrintServerUrl[];
extern const char kCloudPrintGaiaServiceId[];
-extern const char kSyncGaiaServiceId[];
extern const char kProxyAuthUserAgent[];
extern const char kCloudPrintPushNotificationsSource[];
extern const char kCloudPrintUserAgent[];
diff --git a/chrome/service/cloud_print/cloud_print_proxy_backend.cc b/chrome/service/cloud_print/cloud_print_proxy_backend.cc
index fd11cae..e318c1a 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() {}