summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/tools
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-11-01 12:19:54 +0000
committerIain Merrick <husky@google.com>2010-11-03 10:21:10 +0000
commit731df977c0511bca2206b5f333555b1205ff1f43 (patch)
tree0e750b949b3f00a1ac11fda25d3c2de512f2b465 /chrome/browser/sync/tools
parent5add15e10e7bb80512f2c597ca57221314abe577 (diff)
downloadexternal_chromium-731df977c0511bca2206b5f333555b1205ff1f43.zip
external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.gz
external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.bz2
Merge Chromium at r63472 : Initial merge by git.
Change-Id: Ifb9ee821af006a5f2211e81471be93ae440a1f5a
Diffstat (limited to 'chrome/browser/sync/tools')
-rw-r--r--chrome/browser/sync/tools/sync_listen_notifications.cc37
1 files changed, 31 insertions, 6 deletions
diff --git a/chrome/browser/sync/tools/sync_listen_notifications.cc b/chrome/browser/sync/tools/sync_listen_notifications.cc
index e436a81..c619e14 100644
--- a/chrome/browser/sync/tools/sync_listen_notifications.cc
+++ b/chrome/browser/sync/tools/sync_listen_notifications.cc
@@ -6,6 +6,7 @@
#include <vector>
#include "base/at_exit.h"
+#include "base/base64.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -157,9 +158,12 @@ class ChromeInvalidationListener
// Delegate for server-side notifications.
class CacheInvalidationNotifierDelegate
- : public XmppNotificationClient::Observer {
+ : public XmppNotificationClient::Observer,
+ public sync_notifier::StateWriter {
public:
- CacheInvalidationNotifierDelegate() {}
+ explicit CacheInvalidationNotifierDelegate(
+ const std::string& cache_invalidation_state)
+ : cache_invalidation_state_(cache_invalidation_state) {}
virtual ~CacheInvalidationNotifierDelegate() {}
@@ -168,9 +172,9 @@ class CacheInvalidationNotifierDelegate
// TODO(akalin): app_name should be per-client unique.
const std::string kAppName = "cc_sync_listen_notifications";
- chrome_invalidation_client_.Start(kAppName,
+ chrome_invalidation_client_.Start(kAppName, cache_invalidation_state_,
&chrome_invalidation_listener_,
- base_task);
+ this, base_task);
chrome_invalidation_client_.RegisterTypes();
}
@@ -178,8 +182,18 @@ class CacheInvalidationNotifierDelegate
chrome_invalidation_client_.Stop();
}
+ virtual void WriteState(const std::string& state) {
+ std::string base64_state;
+ CHECK(base::Base64Encode(state, &base64_state));
+ LOG(INFO) << "New state: " << base64_state;
+ }
+
private:
ChromeInvalidationListener chrome_invalidation_listener_;
+ // Opaque blob capturing the notifications state of a previous run
+ // (i.e., the base64-decoded value of a string output by
+ // WriteState()).
+ std::string cache_invalidation_state_;
sync_notifier::ChromeInvalidationClient chrome_invalidation_client_;
};
@@ -201,7 +215,8 @@ int main(int argc, char* argv[]) {
if (email.empty()) {
printf("Usage: %s --email=foo@bar.com [--password=mypassword] "
"[--server=talk.google.com] [--port=5222] [--allow-plain] "
- "[--disable-tls] [--use-cache-invalidation] [--use-ssl-tcp]\n",
+ "[--disable-tls] [--use-cache-invalidation] [--use-ssl-tcp] "
+ "[--cache-invalidtion-state]\n",
argv[0]);
return -1;
}
@@ -230,6 +245,15 @@ int main(int argc, char* argv[]) {
LOG(WARNING) << switches::kSyncUseSslTcp << " is set but port is " << port
<< " instead of 443";
}
+ std::string cache_invalidation_state;
+ std::string cache_invalidation_state_encoded =
+ command_line.GetSwitchValueASCII("cache-invalidation-state");
+ if (!cache_invalidation_state_encoded.empty() &&
+ !base::Base64Decode(cache_invalidation_state_encoded,
+ &cache_invalidation_state)) {
+ LOG(ERROR) << "Could not decode state: "
+ << cache_invalidation_state_encoded;
+ }
// Build XMPP client settings.
buzz::XmppClientSettings xmpp_client_settings;
@@ -257,7 +281,8 @@ int main(int argc, char* argv[]) {
// Connect and listen.
LegacyNotifierDelegate legacy_notifier_delegate;
- CacheInvalidationNotifierDelegate cache_invalidation_notifier_delegate;
+ CacheInvalidationNotifierDelegate cache_invalidation_notifier_delegate(
+ cache_invalidation_state);
std::vector<XmppNotificationClient::Observer*> observers;
// TODO(akalin): Add switch to listen to both.
if (command_line.HasSwitch(switches::kSyncUseCacheInvalidation)) {