summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/notifier
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-18 22:32:55 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-18 22:32:55 +0000
commit74ac334361011af6ac441cbc78ec7d7a2f4c6ce8 (patch)
tree2f8d894fefc46eea4985a316557d64db46ba37cb /chrome/browser/sync/notifier
parentd61e096b7e834877db979e73064b24f40a860ff4 (diff)
downloadchromium_src-74ac334361011af6ac441cbc78ec7d7a2f4c6ce8.zip
chromium_src-74ac334361011af6ac441cbc78ec7d7a2f4c6ce8.tar.gz
chromium_src-74ac334361011af6ac441cbc78ec7d7a2f4c6ce8.tar.bz2
[Sync] Remove dependency of SyncNotifierThread on webkit
Move the use of webkit_glue::GetUserAgent() to SyncBackendHost and pass it down as a string to SyncNotifierThread. This works around some linking problems when trying to make sync_listen_notifications use the new SyncNotifier interface, and is good to do anyway. BUG= TEST= Review URL: http://codereview.chromium.org/6712028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78769 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/notifier')
-rw-r--r--chrome/browser/sync/notifier/server_notifier_thread.cc13
-rw-r--r--chrome/browser/sync/notifier/server_notifier_thread.h4
-rw-r--r--chrome/browser/sync/notifier/server_notifier_thread_unittest.cc5
-rw-r--r--chrome/browser/sync/notifier/sync_notifier_factory.cc11
-rw-r--r--chrome/browser/sync/notifier/sync_notifier_factory.h11
-rw-r--r--chrome/browser/sync/notifier/sync_notifier_impl.cc6
-rw-r--r--chrome/browser/sync/notifier/sync_notifier_impl.h4
7 files changed, 34 insertions, 20 deletions
diff --git a/chrome/browser/sync/notifier/server_notifier_thread.cc b/chrome/browser/sync/notifier/server_notifier_thread.cc
index c64d5935..2476710 100644
--- a/chrome/browser/sync/notifier/server_notifier_thread.cc
+++ b/chrome/browser/sync/notifier/server_notifier_thread.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,18 +9,18 @@
#include "base/logging.h"
#include "chrome/browser/sync/notifier/chrome_invalidation_client.h"
-#include "googleurl/src/gurl.h"
#include "jingle/notifier/base/notifier_options.h"
#include "jingle/notifier/listener/notification_defines.h"
#include "talk/xmpp/xmppclient.h"
-#include "webkit/glue/webkit_glue.h"
namespace sync_notifier {
ServerNotifierThread::ServerNotifierThread(
const notifier::NotifierOptions& notifier_options,
- const std::string& state, StateWriter* state_writer)
+ const std::string& client_info, const std::string& state,
+ StateWriter* state_writer)
: notifier::MediatorThreadImpl(notifier_options),
+ client_info_(client_info),
state_(state),
state_writers_(new ObserverListThreadSafe<StateWriter>()),
state_writer_(state_writer) {
@@ -140,11 +140,8 @@ void ServerNotifierThread::DoListenForUpdates() {
// make it so that we won't receive any notifications that were
// generated from our own changes.
const std::string kClientId = "server_notifier_thread";
- // Use user agent as |client_info| so we can use it for debugging
- // server-side.
- const std::string& client_info = webkit_glue::GetUserAgent(GURL());
chrome_invalidation_client_->Start(
- kClientId, client_info, state_, this, this, base_task_);
+ kClientId, client_info_, state_, this, this, base_task_);
RegisterTypes();
state_.clear();
}
diff --git a/chrome/browser/sync/notifier/server_notifier_thread.h b/chrome/browser/sync/notifier/server_notifier_thread.h
index 8b926ac..1d4af47 100644
--- a/chrome/browser/sync/notifier/server_notifier_thread.h
+++ b/chrome/browser/sync/notifier/server_notifier_thread.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -39,6 +39,7 @@ class ServerNotifierThread
// be NULL).
explicit ServerNotifierThread(
const notifier::NotifierOptions& notifier_options,
+ const std::string& client_info,
const std::string& state, StateWriter* state_writer);
virtual ~ServerNotifierThread();
@@ -85,6 +86,7 @@ class ServerNotifierThread
// Posted to the worker thread by Logout().
void StopInvalidationListener();
+ const std::string client_info_;
std::string state_;
// Hack to get the nice thread-safe behavior for |state_writer_|.
scoped_refptr<ObserverListThreadSafe<StateWriter> > state_writers_;
diff --git a/chrome/browser/sync/notifier/server_notifier_thread_unittest.cc b/chrome/browser/sync/notifier/server_notifier_thread_unittest.cc
index 2c9f20b..bb35411 100644
--- a/chrome/browser/sync/notifier/server_notifier_thread_unittest.cc
+++ b/chrome/browser/sync/notifier/server_notifier_thread_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -21,7 +21,8 @@ namespace sync_notifier {
class FakeServerNotifierThread : public ServerNotifierThread {
public:
FakeServerNotifierThread()
- : ServerNotifierThread(notifier::NotifierOptions(), "fake state",
+ : ServerNotifierThread(notifier::NotifierOptions(),
+ "fake client info", "fake state",
ALLOW_THIS_IN_INITIALIZER_LIST(this)) {}
virtual ~FakeServerNotifierThread() {}
diff --git a/chrome/browser/sync/notifier/sync_notifier_factory.cc b/chrome/browser/sync/notifier/sync_notifier_factory.cc
index 9f2886a..3603d5a 100644
--- a/chrome/browser/sync/notifier/sync_notifier_factory.cc
+++ b/chrome/browser/sync/notifier/sync_notifier_factory.cc
@@ -41,7 +41,8 @@ net::HostPortPair StringToHostPortPair(const std::string& host_port_str,
return net::HostPortPair(host, port);
}
-SyncNotifier* CreateDefaultSyncNotifier(const CommandLine& command_line) {
+SyncNotifier* CreateDefaultSyncNotifier(const CommandLine& command_line,
+ const std::string& client_info) {
// Contains options specific to how sync clients send and listen to
// jingle notifications.
notifier::NotifierOptions notifier_options;
@@ -82,18 +83,18 @@ SyncNotifier* CreateDefaultSyncNotifier(const CommandLine& command_line) {
notifier::StringToNotificationMethod(notification_method_str);
}
- return new SyncNotifierImpl(notifier_options);
+ return new SyncNotifierImpl(notifier_options, client_info);
}
} // namespace
-SyncNotifierFactory::SyncNotifierFactory() {
-}
+SyncNotifierFactory::SyncNotifierFactory(const std::string& client_info)
+ : client_info_(client_info) {}
SyncNotifierFactory::~SyncNotifierFactory() {
}
SyncNotifier* SyncNotifierFactory::CreateSyncNotifier(
const CommandLine& command_line) {
- return CreateDefaultSyncNotifier(command_line);
+ return CreateDefaultSyncNotifier(command_line, client_info_);
}
} // namespace sync_notifier
diff --git a/chrome/browser/sync/notifier/sync_notifier_factory.h b/chrome/browser/sync/notifier/sync_notifier_factory.h
index a9da82e..010ba37 100644
--- a/chrome/browser/sync/notifier/sync_notifier_factory.h
+++ b/chrome/browser/sync/notifier/sync_notifier_factory.h
@@ -5,21 +5,30 @@
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_FACTORY_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_FACTORY_H_
+#include <string>
+
class CommandLine;
namespace sync_notifier {
+
class SyncNotifier;
// Class to instantiate various implementations of the SyncNotifier interface.
class SyncNotifierFactory {
public:
- SyncNotifierFactory();
+ // |client_info| is a string identifying the client, e.g. a user
+ // agent string.
+ explicit SyncNotifierFactory(const std::string& client_info);
~SyncNotifierFactory();
// Creates the appropriate sync notifier. The caller should take ownership
// of the object returned and delete it when no longer used.
SyncNotifier* CreateSyncNotifier(const CommandLine& command_line);
+
+ private:
+ const std::string client_info_;
};
+
} // namespace sync_notifier
#endif // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_FACTORY_H_
diff --git a/chrome/browser/sync/notifier/sync_notifier_impl.cc b/chrome/browser/sync/notifier/sync_notifier_impl.cc
index 4f95149..ec58f3d 100644
--- a/chrome/browser/sync/notifier/sync_notifier_impl.cc
+++ b/chrome/browser/sync/notifier/sync_notifier_impl.cc
@@ -20,8 +20,10 @@ using notifier::TalkMediatorImpl;
namespace sync_notifier {
SyncNotifierImpl::SyncNotifierImpl(
- const notifier::NotifierOptions& notifier_options)
+ const notifier::NotifierOptions& notifier_options,
+ const std::string& client_info)
: notifier_options_(notifier_options),
+ client_info_(client_info),
server_notifier_thread_(NULL) { }
SyncNotifierImpl::~SyncNotifierImpl() {
@@ -122,7 +124,7 @@ void SyncNotifierImpl::UpdateCredentials(
// but it is guaranteed that |sync_notifier_thread_| is destroyed only
// when |talk_mediator_| is (see the comments in talk_mediator.h).
server_notifier_thread_ = new sync_notifier::ServerNotifierThread(
- notifier_options_, state_, this);
+ notifier_options_, client_info_, state_, this);
talk_mediator_.reset(
new TalkMediatorImpl(server_notifier_thread_,
notifier_options_.invalidate_xmpp_login,
diff --git a/chrome/browser/sync/notifier/sync_notifier_impl.h b/chrome/browser/sync/notifier/sync_notifier_impl.h
index 2d5212a..c9151bc 100644
--- a/chrome/browser/sync/notifier/sync_notifier_impl.h
+++ b/chrome/browser/sync/notifier/sync_notifier_impl.h
@@ -26,7 +26,8 @@ class SyncNotifierImpl
public sync_notifier::StateWriter,
public notifier::TalkMediator::Delegate {
public:
- explicit SyncNotifierImpl(const notifier::NotifierOptions& notifier_options);
+ SyncNotifierImpl(const notifier::NotifierOptions& notifier_options,
+ const std::string& client_info);
virtual ~SyncNotifierImpl();
@@ -63,6 +64,7 @@ class SyncNotifierImpl
std::string state_;
notifier::NotifierOptions notifier_options_;
+ const std::string client_info_;
ServerNotifierThread* server_notifier_thread_;
ObserverList<SyncNotifierObserver> observer_list_;
};