summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-01 07:45:26 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-01 07:45:26 +0000
commit3fd7d7ca4dd5d484c541ff4983e3e83d0917baee (patch)
treee60c62e38a109e6b20aae5cc3e887cd44b31c034
parentf8c3aead7e7812724f1c21bb697464aca0edd89b (diff)
downloadchromium_src-3fd7d7ca4dd5d484c541ff4983e3e83d0917baee.zip
chromium_src-3fd7d7ca4dd5d484c541ff4983e3e83d0917baee.tar.gz
chromium_src-3fd7d7ca4dd5d484c541ff4983e3e83d0917baee.tar.bz2
[Sync] Move BridgedSyncNotifier and ChromeSyncNotificationBridge to glue/
sync_notifier isn't supposed to have dependencies on chrome. BUG=113723 TEST= Review URL: https://chromiumcodereview.appspot.com/9512005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124381 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/glue/DEPS6
-rw-r--r--chrome/browser/sync/glue/bridged_sync_notifier.cc (renamed from chrome/browser/sync/notifier/bridged_sync_notifier.cc)16
-rw-r--r--chrome/browser/sync/glue/bridged_sync_notifier.h (renamed from chrome/browser/sync/notifier/bridged_sync_notifier.h)22
-rw-r--r--chrome/browser/sync/glue/bridged_sync_notifier_unittest.cc (renamed from chrome/browser/sync/notifier/bridged_sync_notifier_unittest.cc)22
-rw-r--r--chrome/browser/sync/glue/chrome_sync_notification_bridge.cc (renamed from chrome/browser/sync/notifier/chrome_sync_notification_bridge.cc)19
-rw-r--r--chrome/browser/sync/glue/chrome_sync_notification_bridge.h (renamed from chrome/browser/sync/notifier/chrome_sync_notification_bridge.h)19
-rw-r--r--chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc (renamed from chrome/browser/sync/notifier/chrome_sync_notification_bridge_unittest.cc)18
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc12
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.h7
-rw-r--r--chrome/browser/sync/notifier/DEPS1
-rw-r--r--chrome/browser/sync/notifier/sync_notifier_factory.cc18
-rw-r--r--chrome/browser/sync/notifier/sync_notifier_factory.h7
-rw-r--r--chrome/browser/sync/notifier/sync_notifier_factory_unittest.cc57
-rw-r--r--chrome/browser/sync/tools/sync_listen_notifications.cc4
-rw-r--r--chrome/chrome.gyp4
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--chrome/chrome_tests.gypi5
17 files changed, 100 insertions, 141 deletions
diff --git a/chrome/browser/sync/glue/DEPS b/chrome/browser/sync/glue/DEPS
index a3f6fa1..fecb67e 100644
--- a/chrome/browser/sync/glue/DEPS
+++ b/chrome/browser/sync/glue/DEPS
@@ -13,12 +13,16 @@ include_rules = [
"+chrome/browser/sync/engine/passive_model_worker.h",
"+chrome/browser/sync/notifier/sync_notifier.h",
"+chrome/browser/sync/notifier/sync_notifier_factory.h",
+ "+chrome/browser/sync/notifier/sync_notifier_observer.h",
"+chrome/browser/sync/syncable/model_type.h",
+ "+chrome/browser/sync/syncable/model_type_payload_map.h",
"+chrome/browser/sync/sessions/session_state.h",
- # Mocks.
+ # Mocks/tests.
"+chrome/browser/sync/engine/read_node_mock.h",
"+chrome/browser/sync/engine/syncapi_mock.h",
+ "+chrome/browser/sync/notifier/mock_sync_notifier_observer.h",
+ "+chrome/browser/sync/syncable/model_type_test_util.h",
"+chrome/browser/sync/syncable/syncable_mock.h",
# TODO(zea): SessionModelAssociator shouldn't need this.
diff --git a/chrome/browser/sync/notifier/bridged_sync_notifier.cc b/chrome/browser/sync/glue/bridged_sync_notifier.cc
index f2e72d3..fd299bd 100644
--- a/chrome/browser/sync/notifier/bridged_sync_notifier.cc
+++ b/chrome/browser/sync/glue/bridged_sync_notifier.cc
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/sync/notifier/bridged_sync_notifier.h"
+#include "chrome/browser/sync/glue/bridged_sync_notifier.h"
-#include "chrome/browser/sync/notifier/chrome_sync_notification_bridge.h"
+#include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h"
-namespace sync_notifier {
+namespace browser_sync {
BridgedSyncNotifier::BridgedSyncNotifier(
- ChromeSyncNotificationBridge* bridge, SyncNotifier* delegate)
+ ChromeSyncNotificationBridge* bridge,
+ sync_notifier::SyncNotifier* delegate)
: bridge_(bridge), delegate_(delegate) {
DCHECK(bridge_);
DCHECK(delegate_.get());
@@ -18,13 +19,14 @@ BridgedSyncNotifier::BridgedSyncNotifier(
BridgedSyncNotifier::~BridgedSyncNotifier() {
}
-void BridgedSyncNotifier::AddObserver(SyncNotifierObserver* observer) {
+void BridgedSyncNotifier::AddObserver(
+ sync_notifier::SyncNotifierObserver* observer) {
delegate_->AddObserver(observer);
bridge_->AddObserver(observer);
}
void BridgedSyncNotifier::RemoveObserver(
- SyncNotifierObserver* observer) {
+ sync_notifier::SyncNotifierObserver* observer) {
bridge_->RemoveObserver(observer);
delegate_->RemoveObserver(observer);
}
@@ -52,4 +54,4 @@ void BridgedSyncNotifier::SendNotification(
delegate_->SendNotification(changed_types);
}
-} // namespace sync_notifier
+} // namespace browser_sync
diff --git a/chrome/browser/sync/notifier/bridged_sync_notifier.h b/chrome/browser/sync/glue/bridged_sync_notifier.h
index a7cbedb..d758597 100644
--- a/chrome/browser/sync/notifier/bridged_sync_notifier.h
+++ b/chrome/browser/sync/glue/bridged_sync_notifier.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SYNC_NOTIFIER_BRIDGED_SYNC_NOTIFIER_H_
-#define CHROME_BROWSER_SYNC_NOTIFIER_BRIDGED_SYNC_NOTIFIER_H_
+#ifndef CHROME_BROWSER_SYNC_GLUE_BRIDGED_SYNC_NOTIFIER_H_
+#define CHROME_BROWSER_SYNC_GLUE_BRIDGED_SYNC_NOTIFIER_H_
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/sync/notifier/sync_notifier.h"
-namespace sync_notifier {
+namespace browser_sync {
class ChromeSyncNotificationBridge;
@@ -18,18 +18,20 @@ class ChromeSyncNotificationBridge;
// calls are passed straight through to the delegate, with the exception of
// AddObserver/RemoveObserver, which also result in the observer being
// registered/deregistered with the ChromeSyncNotificationBridge.
-class BridgedSyncNotifier : public SyncNotifier {
+class BridgedSyncNotifier : public sync_notifier::SyncNotifier {
public:
// Does not take ownership of |bridge|. Takes ownership of |delegate|.
BridgedSyncNotifier(ChromeSyncNotificationBridge* bridge,
- SyncNotifier* delegate);
+ sync_notifier::SyncNotifier* delegate);
virtual ~BridgedSyncNotifier();
// SyncNotifier implementation. Passes through all calls to the delegate.
// AddObserver/RemoveObserver will also register/deregister |observer| with
// the bridge.
- virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE;
- virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE;
+ virtual void AddObserver(
+ sync_notifier::SyncNotifierObserver* observer) OVERRIDE;
+ virtual void RemoveObserver(
+ sync_notifier::SyncNotifierObserver* observer) OVERRIDE;
virtual void SetUniqueId(const std::string& unique_id) OVERRIDE;
virtual void SetState(const std::string& state) OVERRIDE;
virtual void UpdateCredentials(
@@ -44,9 +46,9 @@ class BridgedSyncNotifier : public SyncNotifier {
ChromeSyncNotificationBridge* bridge_;
// The delegate we are wrapping.
- scoped_ptr<SyncNotifier> delegate_;
+ scoped_ptr<sync_notifier::SyncNotifier> delegate_;
};
-} // namespace sync_notifier
+} // namespace browser_sync
-#endif // CHROME_BROWSER_SYNC_NOTIFIER_BRIDGED_SYNC_NOTIFIER_H_
+#endif // CHROME_BROWSER_SYNC_GLUE_BRIDGED_SYNC_NOTIFIER_H_
diff --git a/chrome/browser/sync/notifier/bridged_sync_notifier_unittest.cc b/chrome/browser/sync/glue/bridged_sync_notifier_unittest.cc
index c6fde30..42a2ec1 100644
--- a/chrome/browser/sync/notifier/bridged_sync_notifier_unittest.cc
+++ b/chrome/browser/sync/glue/bridged_sync_notifier_unittest.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/sync/notifier/bridged_sync_notifier.h"
+#include "chrome/browser/sync/glue/bridged_sync_notifier.h"
#include <string>
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "base/threading/thread.h"
-#include "chrome/browser/sync/notifier/chrome_sync_notification_bridge.h"
+#include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h"
#include "chrome/browser/sync/notifier/mock_sync_notifier_observer.h"
#include "chrome/browser/sync/notifier/sync_notifier.h"
#include "chrome/browser/sync/syncable/model_type.h"
@@ -19,7 +19,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace sync_notifier {
+namespace browser_sync {
namespace {
using ::testing::NiceMock;
@@ -33,19 +33,19 @@ class MockChromeSyncNotificationBridge : public ChromeSyncNotificationBridge {
: ChromeSyncNotificationBridge(&mock_profile_) {}
virtual ~MockChromeSyncNotificationBridge() {}
- MOCK_METHOD1(AddObserver, void(SyncNotifierObserver*));
- MOCK_METHOD1(RemoveObserver, void(SyncNotifierObserver*));
+ MOCK_METHOD1(AddObserver, void(sync_notifier::SyncNotifierObserver*));
+ MOCK_METHOD1(RemoveObserver, void(sync_notifier::SyncNotifierObserver*));
private:
NiceMock<ProfileMock> mock_profile_;
};
-class MockSyncNotifier : public SyncNotifier {
+class MockSyncNotifier : public sync_notifier::SyncNotifier {
public:
MockSyncNotifier() {}
virtual ~MockSyncNotifier() {}
- MOCK_METHOD1(AddObserver, void(SyncNotifierObserver*));
- MOCK_METHOD1(RemoveObserver, void(SyncNotifierObserver*));
+ MOCK_METHOD1(AddObserver, void(sync_notifier::SyncNotifierObserver*));
+ MOCK_METHOD1(RemoveObserver, void(sync_notifier::SyncNotifierObserver*));
MOCK_METHOD1(SetUniqueId, void(const std::string&));
MOCK_METHOD1(SetState, void(const std::string&));
MOCK_METHOD2(UpdateCredentials, void(const std::string&, const std::string&));
@@ -73,14 +73,14 @@ class BridgedSyncNotifierTest : public testing::Test {
};
TEST_F(BridgedSyncNotifierTest, AddObserver) {
- MockSyncNotifierObserver observer;
+ sync_notifier::MockSyncNotifierObserver observer;
EXPECT_CALL(mock_bridge_, AddObserver(&observer));
EXPECT_CALL(*mock_delegate_, AddObserver(&observer));
bridged_notifier_.AddObserver(&observer);
}
TEST_F(BridgedSyncNotifierTest, RemoveObserver) {
- MockSyncNotifierObserver observer;
+ sync_notifier::MockSyncNotifierObserver observer;
EXPECT_CALL(mock_bridge_, RemoveObserver(&observer));
EXPECT_CALL(*mock_delegate_, RemoveObserver(&observer));
bridged_notifier_.RemoveObserver(&observer);
@@ -121,4 +121,4 @@ TEST_F(BridgedSyncNotifierTest, SendNotification) {
}
} // namespace
-} // namespace sync_notifier
+} // namespace browser_sync
diff --git a/chrome/browser/sync/notifier/chrome_sync_notification_bridge.cc b/chrome/browser/sync/glue/chrome_sync_notification_bridge.cc
index 3a724b4..a3c8107 100644
--- a/chrome/browser/sync/notifier/chrome_sync_notification_bridge.cc
+++ b/chrome/browser/sync/glue/chrome_sync_notification_bridge.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/sync/notifier/chrome_sync_notification_bridge.h"
+#include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h"
#include "chrome/browser/sync/notifier/sync_notifier_observer.h"
#include "chrome/common/chrome_notification_types.h"
@@ -11,11 +11,12 @@
using content::BrowserThread;
-namespace sync_notifier {
+namespace browser_sync {
ChromeSyncNotificationBridge::ChromeSyncNotificationBridge(
const Profile* profile)
- : observers_(new ObserverListThreadSafe<SyncNotifierObserver>()) {
+ : observers_(
+ new ObserverListThreadSafe<sync_notifier::SyncNotifierObserver>()) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(profile);
registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH,
@@ -24,12 +25,13 @@ ChromeSyncNotificationBridge::ChromeSyncNotificationBridge(
ChromeSyncNotificationBridge::~ChromeSyncNotificationBridge() {}
-void ChromeSyncNotificationBridge::AddObserver(SyncNotifierObserver* observer) {
+void ChromeSyncNotificationBridge::AddObserver(
+ sync_notifier::SyncNotifierObserver* observer) {
observers_->AddObserver(observer);
}
void ChromeSyncNotificationBridge::RemoveObserver(
- SyncNotifierObserver* observer) {
+ sync_notifier::SyncNotifierObserver* observer) {
observers_->RemoveObserver(observer);
}
@@ -46,8 +48,9 @@ void ChromeSyncNotificationBridge::Observe(
DCHECK_EQ(syncable::SESSIONS, model_type);
syncable::ModelTypePayloadMap payload_map;
payload_map[model_type] = "";
- observers_->Notify(&SyncNotifierObserver::OnIncomingNotification,
- payload_map, LOCAL_NOTIFICATION);
+ observers_->Notify(
+ &sync_notifier::SyncNotifierObserver::OnIncomingNotification,
+ payload_map, sync_notifier::LOCAL_NOTIFICATION);
}
-} // namespace sync_notifier
+} // namespace browser_sync
diff --git a/chrome/browser/sync/notifier/chrome_sync_notification_bridge.h b/chrome/browser/sync/glue/chrome_sync_notification_bridge.h
index 06d8056..69db3ff 100644
--- a/chrome/browser/sync/notifier/chrome_sync_notification_bridge.h
+++ b/chrome/browser/sync/glue/chrome_sync_notification_bridge.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYNC_NOTIFICATION_BRIDGE_H_
-#define CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYNC_NOTIFICATION_BRIDGE_H_
+#ifndef CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_
+#define CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
@@ -14,8 +14,10 @@
class Profile;
namespace sync_notifier {
-
class SyncNotifierObserver;
+} // namespace
+
+namespace browser_sync {
// A thread-safe bridge for chrome events that can trigger sync notifications.
// Currently only listens to NOTIFICATION_SYNC_REFRESH, triggering each
@@ -29,8 +31,8 @@ class ChromeSyncNotificationBridge : public content::NotificationObserver {
virtual ~ChromeSyncNotificationBridge();
// These can be called on any thread.
- virtual void AddObserver(SyncNotifierObserver* observer);
- virtual void RemoveObserver(SyncNotifierObserver* observer);
+ virtual void AddObserver(sync_notifier::SyncNotifierObserver* observer);
+ virtual void RemoveObserver(sync_notifier::SyncNotifierObserver* observer);
// NotificationObserver implementation. Called on UI thread.
virtual void Observe(int type,
@@ -42,9 +44,10 @@ class ChromeSyncNotificationBridge : public content::NotificationObserver {
// Because [Add/Remove]Observer can be called from any thread, we need a
// thread-safe observerlist.
- scoped_refptr<ObserverListThreadSafe<SyncNotifierObserver> > observers_;
+ scoped_refptr<ObserverListThreadSafe<sync_notifier::SyncNotifierObserver> >
+ observers_;
};
-} // namespace sync_notifier
+} // namespace browser_sync
-#endif // CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYNC_NOTIFICATION_BRIDGE_H_
+#endif // CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_
diff --git a/chrome/browser/sync/notifier/chrome_sync_notification_bridge_unittest.cc b/chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc
index ffc56f5..abd2c7b 100644
--- a/chrome/browser/sync/notifier/chrome_sync_notification_bridge_unittest.cc
+++ b/chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/sync/notifier/chrome_sync_notification_bridge.h"
+#include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
@@ -22,7 +22,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace sync_notifier {
+namespace browser_sync {
namespace {
using ::testing::Mock;
@@ -37,7 +37,8 @@ using content::BrowserThread;
// Note: Because this object lives on the IO thread, we use a fake (vs a mock)
// so we don't have to worry about possible thread safety issues within
// GTest/GMock.
-class FakeSyncNotifierObserverIO : public SyncNotifierObserver {
+class FakeSyncNotifierObserverIO
+ : public sync_notifier::SyncNotifierObserver {
public:
FakeSyncNotifierObserverIO(
ChromeSyncNotificationBridge* bridge,
@@ -57,10 +58,10 @@ class FakeSyncNotifierObserverIO : public SyncNotifierObserver {
// SyncNotifierObserver implementation.
virtual void OnIncomingNotification(
const syncable::ModelTypePayloadMap& type_payloads,
- IncomingNotificationSource source) OVERRIDE {
+ sync_notifier::IncomingNotificationSource source) OVERRIDE {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
notification_count_++;
- if (source != LOCAL_NOTIFICATION) {
+ if (source != sync_notifier::LOCAL_NOTIFICATION) {
LOG(ERROR) << "Received notification with wrong source.";
received_improper_notification_ = true;
}
@@ -189,9 +190,10 @@ class ChromeSyncNotificationBridgeTest : public testing::Test {
TEST_F(ChromeSyncNotificationBridgeTest, Basic) {
syncable::ModelTypePayloadMap payload_map;
payload_map[syncable::SESSIONS] = "";
- StrictMock<MockSyncNotifierObserver> observer;
+ StrictMock<sync_notifier::MockSyncNotifierObserver> observer;
EXPECT_CALL(observer,
- OnIncomingNotification(payload_map, LOCAL_NOTIFICATION));
+ OnIncomingNotification(payload_map,
+ sync_notifier::LOCAL_NOTIFICATION));
bridge_.AddObserver(&observer);
TriggerRefreshNotification();
ui_loop_.RunAllPending();
@@ -210,4 +212,4 @@ TEST_F(ChromeSyncNotificationBridgeTest, BasicThreaded) {
}
} // namespace
-} // namespace sync_notifier
+} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index abb0840..be85c26 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -20,6 +20,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/token_service.h"
+#include "chrome/browser/sync/glue/bridged_sync_notifier.h"
#include "chrome/browser/sync/glue/change_processor.h"
#include "chrome/browser/sync/glue/chrome_encryptor.h"
#include "chrome/browser/sync/glue/http_bridge.h"
@@ -234,8 +235,8 @@ SyncBackendHost::SyncBackendHost(const std::string& name,
weak_ptr_factory_.GetWeakPtr())),
initialization_state_(NOT_ATTEMPTED),
sync_prefs_(sync_prefs),
+ chrome_sync_notification_bridge_(profile_),
sync_notifier_factory_(
- profile_,
content::GetUserAgent(GURL()),
profile_->GetRequestContext(),
sync_prefs,
@@ -251,8 +252,8 @@ SyncBackendHost::SyncBackendHost(Profile* profile)
profile_(profile),
name_("Unknown"),
initialization_state_(NOT_ATTEMPTED),
+ chrome_sync_notification_bridge_(profile_),
sync_notifier_factory_(
- profile_,
content::GetUserAgent(GURL()),
NULL,
base::WeakPtr<sync_notifier::InvalidationVersionTracker>(),
@@ -310,6 +311,7 @@ void SyncBackendHost::Initialize(
base::Bind(&MakeHttpBridgeFactory,
make_scoped_refptr(profile_->GetRequestContext())),
credentials,
+ &chrome_sync_notification_bridge_,
&sync_notifier_factory_,
delete_sync_data_folder,
sync_prefs_->GetEncryptionBootstrapToken(),
@@ -722,6 +724,7 @@ SyncBackendHost::DoInitializeOptions::DoInitializeOptions(
const GURL& service_url,
MakeHttpBridgeFactoryFn make_http_bridge_factory_fn,
const sync_api::SyncCredentials& credentials,
+ ChromeSyncNotificationBridge* chrome_sync_notification_bridge,
sync_notifier::SyncNotifierFactory* sync_notifier_factory,
bool delete_sync_data_folder,
const std::string& restored_key_for_bootstrapping,
@@ -735,6 +738,7 @@ SyncBackendHost::DoInitializeOptions::DoInitializeOptions(
service_url(service_url),
make_http_bridge_factory_fn(make_http_bridge_factory_fn),
credentials(credentials),
+ chrome_sync_notification_bridge(chrome_sync_notification_bridge),
sync_notifier_factory(sync_notifier_factory),
delete_sync_data_folder(delete_sync_data_folder),
restored_key_for_bootstrapping(restored_key_for_bootstrapping),
@@ -971,7 +975,9 @@ void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) {
options.registrar /* as SyncManager::ChangeDelegate */,
MakeUserAgentForSyncApi(),
options.credentials,
- options.sync_notifier_factory->CreateSyncNotifier(),
+ new BridgedSyncNotifier(
+ options.chrome_sync_notification_bridge,
+ options.sync_notifier_factory->CreateSyncNotifier()),
options.restored_key_for_bootstrapping,
options.setup_for_test_mode,
&encryptor_,
diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h
index 0f24252..66f8a5d 100644
--- a/chrome/browser/sync/glue/sync_backend_host.h
+++ b/chrome/browser/sync/glue/sync_backend_host.h
@@ -17,6 +17,7 @@
#include "chrome/browser/sync/engine/model_safe_worker.h"
#include "chrome/browser/sync/glue/backend_data_type_configurer.h"
#include "chrome/browser/sync/glue/chrome_extensions_activity_monitor.h"
+#include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h"
#include "chrome/browser/sync/internal_api/includes/report_unrecoverable_error_function.h"
#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h"
#include "chrome/browser/sync/internal_api/configure_reason.h"
@@ -289,6 +290,7 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
const GURL& service_url,
MakeHttpBridgeFactoryFn make_http_bridge_factory_fn,
const sync_api::SyncCredentials& credentials,
+ ChromeSyncNotificationBridge* chrome_sync_notification_bridge,
sync_notifier::SyncNotifierFactory* sync_notifier_factory,
bool delete_sync_data_folder,
const std::string& restored_key_for_bootstrapping,
@@ -305,6 +307,7 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
// Overridden by tests.
MakeHttpBridgeFactoryFn make_http_bridge_factory_fn;
sync_api::SyncCredentials credentials;
+ ChromeSyncNotificationBridge* const chrome_sync_notification_bridge;
sync_notifier::SyncNotifierFactory* const sync_notifier_factory;
std::string lsid;
bool delete_sync_data_folder;
@@ -483,6 +486,10 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
const base::WeakPtr<SyncPrefs> sync_prefs_;
+ // A thread-safe listener for handling notifications triggered by
+ // chrome events.
+ ChromeSyncNotificationBridge chrome_sync_notification_bridge_;
+
sync_notifier::SyncNotifierFactory sync_notifier_factory_;
ChromeExtensionsActivityMonitor extensions_activity_monitor_;
diff --git a/chrome/browser/sync/notifier/DEPS b/chrome/browser/sync/notifier/DEPS
index 6355c95..19b4f38 100644
--- a/chrome/browser/sync/notifier/DEPS
+++ b/chrome/browser/sync/notifier/DEPS
@@ -11,7 +11,6 @@ include_rules = [
"+chrome/browser/sync/util",
"+chrome/common/chrome_switches.h",
- "+chrome/common/chrome_notification_types.h",
"+google/cacheinvalidation",
"+jingle/notifier",
diff --git a/chrome/browser/sync/notifier/sync_notifier_factory.cc b/chrome/browser/sync/notifier/sync_notifier_factory.cc
index 56fb236..9542f5f 100644
--- a/chrome/browser/sync/notifier/sync_notifier_factory.cc
+++ b/chrome/browser/sync/notifier/sync_notifier_factory.cc
@@ -10,7 +10,6 @@
#include "base/logging.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
-#include "chrome/browser/sync/notifier/bridged_sync_notifier.h"
#include "chrome/browser/sync/notifier/non_blocking_invalidation_notifier.h"
#include "chrome/browser/sync/notifier/p2p_notifier.h"
#include "chrome/browser/sync/notifier/sync_notifier.h"
@@ -119,15 +118,13 @@ SyncNotifier* CreateDefaultSyncNotifier(
} // namespace
SyncNotifierFactory::SyncNotifierFactory(
- const Profile* profile,
const std::string& client_info,
const scoped_refptr<net::URLRequestContextGetter>&
request_context_getter,
const base::WeakPtr<InvalidationVersionTracker>&
invalidation_version_tracker,
const CommandLine& command_line)
- : chrome_notification_bridge_(profile),
- client_info_(client_info),
+ : client_info_(client_info),
request_context_getter_(request_context_getter),
initial_max_invalidation_versions_(
invalidation_version_tracker.get() ?
@@ -136,7 +133,6 @@ SyncNotifierFactory::SyncNotifierFactory(
invalidation_version_tracker_(invalidation_version_tracker),
command_line_(command_line) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(profile);
}
SyncNotifierFactory::~SyncNotifierFactory() {
@@ -144,12 +140,10 @@ SyncNotifierFactory::~SyncNotifierFactory() {
}
SyncNotifier* SyncNotifierFactory::CreateSyncNotifier() {
- return new BridgedSyncNotifier(
- &chrome_notification_bridge_,
- CreateDefaultSyncNotifier(command_line_,
- request_context_getter_,
- initial_max_invalidation_versions_,
- invalidation_version_tracker_,
- client_info_));
+ return CreateDefaultSyncNotifier(command_line_,
+ request_context_getter_,
+ initial_max_invalidation_versions_,
+ invalidation_version_tracker_,
+ 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 32d61f3..8ad7c44 100644
--- a/chrome/browser/sync/notifier/sync_notifier_factory.h
+++ b/chrome/browser/sync/notifier/sync_notifier_factory.h
@@ -9,12 +9,10 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/sync/notifier/chrome_sync_notification_bridge.h"
#include "chrome/browser/sync/notifier/invalidation_version_tracker.h"
#include "chrome/browser/sync/util/weak_handle.h"
class CommandLine;
-class Profile;
namespace net {
class URLRequestContextGetter;
@@ -32,7 +30,6 @@ class SyncNotifierFactory {
// agent string. |invalidation_version_tracker| may be NULL (for
// tests).
SyncNotifierFactory(
- const Profile* profile,
const std::string& client_info,
const scoped_refptr<net::URLRequestContextGetter>&
request_context_getter,
@@ -47,10 +44,6 @@ class SyncNotifierFactory {
SyncNotifier* CreateSyncNotifier();
private:
- // A thread-safe listener for handling notifications triggered by chrome
- // events.
- ChromeSyncNotificationBridge chrome_notification_bridge_;
-
const std::string client_info_;
const scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
const InvalidationVersionMap initial_max_invalidation_versions_;
diff --git a/chrome/browser/sync/notifier/sync_notifier_factory_unittest.cc b/chrome/browser/sync/notifier/sync_notifier_factory_unittest.cc
index 63ece70..70783a5 100644
--- a/chrome/browser/sync/notifier/sync_notifier_factory_unittest.cc
+++ b/chrome/browser/sync/notifier/sync_notifier_factory_unittest.cc
@@ -16,12 +16,8 @@
#include "chrome/browser/sync/notifier/sync_notifier.h"
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/syncable/model_type_payload_map.h"
-#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/test/base/profile_mock.h"
#include "chrome/test/base/test_url_request_context_getter.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_details.h"
#include "content/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -35,19 +31,16 @@ using ::testing::StrictMock;
using content::BrowserThread;
class SyncNotifierFactoryTest : public testing::Test {
- public:
- // TODO(zea): switch to using real io_thread instead of shared message loop.
+ protected:
SyncNotifierFactoryTest()
: ui_thread_(BrowserThread::UI, &message_loop_),
io_thread_(BrowserThread::IO, &message_loop_),
command_line_(CommandLine::NO_PROGRAM) {}
virtual ~SyncNotifierFactoryTest() {}
- protected:
virtual void SetUp() OVERRIDE {
request_context_getter_ = new TestURLRequestContextGetter;
factory_.reset(new SyncNotifierFactory(
- &mock_profile_,
"fake_client_info",
request_context_getter_,
base::WeakPtr<sync_notifier::InvalidationVersionTracker>(),
@@ -56,25 +49,15 @@ class SyncNotifierFactoryTest : public testing::Test {
}
virtual void TearDown() OVERRIDE {
- Mock::VerifyAndClearExpectations(&mock_profile_);
Mock::VerifyAndClearExpectations(&mock_observer_);
request_context_getter_ = NULL;
message_loop_.RunAllPending();
command_line_ = CommandLine(CommandLine::NO_PROGRAM);
}
- void TriggerRefreshNotification() {
- const syncable::ModelType type = syncable::SESSIONS;
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_SYNC_REFRESH,
- content::Source<Profile>(&mock_profile_),
- content::Details<const syncable::ModelType>(&type));
- }
-
MessageLoop message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread io_thread_;
- NiceMock<ProfileMock> mock_profile_;
scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
StrictMock<MockSyncNotifierObserver> mock_observer_;
scoped_ptr<SyncNotifierFactory> factory_;
@@ -98,43 +81,5 @@ TEST_F(SyncNotifierFactoryTest, Basic_P2P) {
notifier->RemoveObserver(&mock_observer_);
}
-// Create a default sync notifier (NonBlockingInvalidationNotifier wrapped by a
-// BridgedSyncNotifier) and then trigger a sync refresh notification. The
-// observer should receive the notification as a LOCAL_NOTIFICATION.
-TEST_F(SyncNotifierFactoryTest, ChromeSyncNotification) {
- syncable::ModelTypePayloadMap type_payloads;
- type_payloads[syncable::SESSIONS] = "";
- EXPECT_CALL(mock_observer_,
- OnIncomingNotification(type_payloads,
- LOCAL_NOTIFICATION));
-
- scoped_ptr<SyncNotifier> notifier(factory_->CreateSyncNotifier());
- ASSERT_TRUE(notifier.get());
- notifier->AddObserver(&mock_observer_);
- TriggerRefreshNotification();
- message_loop_.RunAllPending();
- notifier->RemoveObserver(&mock_observer_);
-}
-
-
-// Create a P2P sync notifier (wrapped by a BridgedSyncNotifier)
-// and then trigger a sync refresh notification. The observer should receive
-// the notification as a LOCAL_NOTIFICATION.
-TEST_F(SyncNotifierFactoryTest, ChromeSyncNotification_P2P) {
- syncable::ModelTypePayloadMap type_payloads;
- type_payloads[syncable::SESSIONS] = "";
- EXPECT_CALL(mock_observer_,
- OnIncomingNotification(type_payloads,
- LOCAL_NOTIFICATION));
-
- command_line_.AppendSwitchASCII(switches::kSyncNotificationMethod, "p2p");
- scoped_ptr<SyncNotifier> notifier(factory_->CreateSyncNotifier());
- ASSERT_TRUE(notifier.get());
- notifier->AddObserver(&mock_observer_);
- TriggerRefreshNotification();
- message_loop_.RunAllPending();
- notifier->RemoveObserver(&mock_observer_);
-}
-
} // namespace
} // namespace sync_notifier
diff --git a/chrome/browser/sync/tools/sync_listen_notifications.cc b/chrome/browser/sync/tools/sync_listen_notifications.cc
index 7395508..c5836ab 100644
--- a/chrome/browser/sync/tools/sync_listen_notifications.cc
+++ b/chrome/browser/sync/tools/sync_listen_notifications.cc
@@ -22,7 +22,6 @@
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/syncable/model_type_payload_map.h"
#include "chrome/test/base/test_url_request_context_getter.h"
-#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/browser_thread.h"
#include "content/test/test_browser_thread.h"
@@ -128,9 +127,8 @@ int main(int argc, char* argv[]) {
scoped_refptr<TestURLRequestContextGetter> request_context_getter(
new TestURLRequestContextGetter());
NullInvalidationVersionTracker null_invalidation_version_tracker;
- TestingProfile profile_;
sync_notifier::SyncNotifierFactory sync_notifier_factory(
- &profile_, kClientInfo, request_context_getter,
+ kClientInfo, request_context_getter,
null_invalidation_version_tracker.AsWeakPtr(), command_line);
scoped_ptr<sync_notifier::SyncNotifier> sync_notifier(
sync_notifier_factory.CreateSyncNotifier());
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 08a07a1..86de393 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -556,14 +556,10 @@
'type': 'static_library',
'variables': { 'enable_wexit_time_destructors': 1, },
'sources': [
- 'browser/sync/notifier/bridged_sync_notifier.h',
- 'browser/sync/notifier/bridged_sync_notifier.cc',
'browser/sync/notifier/cache_invalidation_packet_handler.cc',
'browser/sync/notifier/cache_invalidation_packet_handler.h',
'browser/sync/notifier/chrome_invalidation_client.cc',
'browser/sync/notifier/chrome_invalidation_client.h',
- 'browser/sync/notifier/chrome_sync_notification_bridge.h',
- 'browser/sync/notifier/chrome_sync_notification_bridge.cc',
'browser/sync/notifier/chrome_system_resources.cc',
'browser/sync/notifier/chrome_system_resources.h',
'browser/sync/notifier/invalidation_notifier.h',
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index d801023..29d8bd5 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2381,6 +2381,8 @@
'browser/sync/glue/bookmark_data_type_controller.h',
'browser/sync/glue/bookmark_model_associator.cc',
'browser/sync/glue/bookmark_model_associator.h',
+ 'browser/sync/glue/bridged_sync_notifier.h',
+ 'browser/sync/glue/bridged_sync_notifier.cc',
'browser/sync/glue/browser_thread_model_worker.cc',
'browser/sync/glue/browser_thread_model_worker.h',
'browser/sync/glue/change_processor.cc',
@@ -2391,6 +2393,8 @@
'browser/sync/glue/chrome_extensions_activity_monitor.h',
'browser/sync/glue/chrome_report_unrecoverable_error.cc',
'browser/sync/glue/chrome_report_unrecoverable_error.h',
+ 'browser/sync/glue/chrome_sync_notification_bridge.h',
+ 'browser/sync/glue/chrome_sync_notification_bridge.cc',
'browser/sync/glue/data_type_controller.h',
'browser/sync/glue/data_type_error_handler.h',
'browser/sync/glue/data_type_manager.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index de7d276..019811d 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1226,6 +1226,7 @@
'test_support_sync',
'test_support_syncapi',
'test_support_syncapi_service',
+ 'test_support_sync_notifier',
'test_support_unit',
# 3) anything tests directly depend on
'../skia/skia.gyp:skia',
@@ -1724,10 +1725,12 @@
'browser/sync/glue/app_notification_data_type_controller_unittest.cc',
'browser/sync/glue/autofill_data_type_controller_unittest.cc',
'browser/sync/glue/bookmark_data_type_controller_unittest.cc',
+ 'browser/sync/glue/bridged_sync_notifier_unittest.cc',
'browser/sync/glue/browser_thread_model_worker_unittest.cc',
'browser/sync/glue/change_processor_mock.cc',
'browser/sync/glue/change_processor_mock.h',
'browser/sync/glue/chrome_extensions_activity_monitor_unittest.cc',
+ 'browser/sync/glue/chrome_sync_notification_bridge_unittest.cc',
'browser/sync/glue/data_type_controller_mock.cc',
'browser/sync/glue/data_type_controller_mock.h',
'browser/sync/glue/data_type_error_handler_mock.cc',
@@ -3613,11 +3616,9 @@
'browser/sync/js/js_event_details_unittest.cc',
'browser/sync/js/js_mutation_event_observer_unittest.cc',
'browser/sync/js/js_sync_manager_observer_unittest.cc',
- 'browser/sync/notifier/bridged_sync_notifier_unittest.cc',
'browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc',
'browser/sync/notifier/chrome_invalidation_client_unittest.cc',
'browser/sync/notifier/chrome_system_resources_unittest.cc',
- 'browser/sync/notifier/chrome_sync_notification_bridge_unittest.cc',
'browser/sync/notifier/invalidation_notifier_unittest.cc',
'browser/sync/notifier/non_blocking_invalidation_notifier_unittest.cc',
'browser/sync/notifier/p2p_notifier_unittest.cc',