Commit dc0d8b03 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Invalidations cleanup: Delete NetworkChannel interface

It had a single implementation, FCMSyncNetworkChannel, and nothing
actually referred to the interface.

Bug: 1029481
Change-Id: I4791dd4a4760687f29499faee7986d1dfefb5745
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2062422
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Auto-Submit: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743029}
parent 9fb27316
......@@ -40,7 +40,6 @@ static_library("impl") {
"invalidator_registrar_with_memory.h",
"mock_ack_handler.cc",
"mock_ack_handler.h",
"network_channel.h",
"per_user_topic_subscription_manager.cc",
"per_user_topic_subscription_manager.h",
"per_user_topic_subscription_request.cc",
......
......@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
#include "components/invalidation/impl/network_channel.h"
#include "components/invalidation/public/invalidation_util.h"
#include "components/invalidation/public/object_id_invalidation_map.h"
#include "components/invalidation/public/topic_invalidation_map.h"
......
......@@ -22,7 +22,6 @@
#include "components/gcm_driver/instance_id/instance_id.h"
#include "components/gcm_driver/instance_id/instance_id_driver.h"
#include "components/invalidation/impl/invalidation_switches.h"
#include "components/invalidation/impl/network_channel.h"
#include "components/invalidation/impl/status.h"
#include "google_apis/gcm/engine/account_mapping.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
......@@ -167,7 +166,7 @@ class MockInstanceIDDriver : public InstanceIDDriver {
class MockOnTokenCallback {
public:
TokenCallback Get() {
FCMSyncNetworkChannel::TokenCallback Get() {
return base::BindRepeating(&MockOnTokenCallback::Run,
base::Unretained(this));
}
......@@ -177,7 +176,7 @@ class MockOnTokenCallback {
class MockOnMessageCallback {
public:
MessageCallback Get() {
FCMSyncNetworkChannel::MessageCallback Get() {
return base::BindRepeating(&MockOnMessageCallback::Run,
base::Unretained(this));
}
......@@ -214,7 +213,7 @@ class FCMNetworkHandlerTest : public testing::Test {
}
std::unique_ptr<FCMNetworkHandler> MakeHandlerReadyForMessage(
MessageCallback mock_on_message_callback) {
FCMSyncNetworkChannel::MessageCallback mock_on_message_callback) {
std::unique_ptr<FCMNetworkHandler> handler = MakeHandler();
handler->SetMessageReceiver(mock_on_message_callback);
EXPECT_CALL(*mock_instance_id(), GetToken(_, _, _, _, _, _))
......
......@@ -5,11 +5,12 @@
#ifndef COMPONENTS_INVALIDATION_IMPL_FCM_SYNC_NETWORK_CHANNEL_H_
#define COMPONENTS_INVALIDATION_IMPL_FCM_SYNC_NETWORK_CHANNEL_H_
#include <string>
#include "base/callback.h"
#include "base/observer_list.h"
#include "base/values.h"
#include "components/invalidation/impl/channels_states.h"
#include "components/invalidation/impl/network_channel.h"
namespace syncer {
......@@ -17,7 +18,7 @@ namespace syncer {
// client:
// - registering message callbacks
// - notifying on network problems
class FCMSyncNetworkChannel : public NetworkChannel {
class FCMSyncNetworkChannel {
public:
class Observer {
public:
......@@ -25,14 +26,36 @@ class FCMSyncNetworkChannel : public NetworkChannel {
FcmChannelState invalidator_state) = 0;
};
// See SetMessageReceiver below.
// payload - additional info specific to the invalidation
// private_topic - the internal (to FCM) representation for the public topic
// public_topic - the topic which was invalidated, e.g. in case of Chrome
// Sync it'll be BOOKMARK or PASSWORD
// version - version number of the invalidation
using MessageCallback =
base::RepeatingCallback<void(const std::string& payload,
const std::string& private_topic,
const std::string& public_topic,
int64_t version)>;
using TokenCallback = base::RepeatingCallback<void(const std::string& token)>;
FCMSyncNetworkChannel();
~FCMSyncNetworkChannel() override;
virtual ~FCMSyncNetworkChannel();
virtual void StartListening() = 0;
virtual void StopListening() = 0;
void SetMessageReceiver(MessageCallback incoming_receiver) override;
void SetTokenReceiver(TokenCallback token_receiver) override;
// Sets the receiver to which messages from the data center will be delivered.
// The callback will be invoked whenever an invalidation message is received
// from FCM. It is *not* guaranteed to be invoked exactly once or in-order
// (with respect to the invalidation's version number).
void SetMessageReceiver(MessageCallback incoming_receiver);
// Sets the receiver to which FCM registration token will be delivered.
// The callback will be invoked whenever a new InstanceID token becomes
// available.
void SetTokenReceiver(TokenCallback token_receiver);
// Classes interested in network channel state changes should implement
// FCMSyncNetworkChannel::Observer and register here.
......
// Copyright 2018 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.
#ifndef COMPONENTS_INVALIDATION_IMPL_NETWORK_CHANNEL_H_
#define COMPONENTS_INVALIDATION_IMPL_NETWORK_CHANNEL_H_
#include "base/callback.h"
namespace syncer {
// See SetMessageReceiver below.
// payload - additional info specific to the invalidation
// private_topic - the internal (to FCM) representation for the public topic
// public_topic - the topic which was invalidated, e.g. in case of Chrome
// Sync it'll be BOOKMARK or PASSWORD
// version - version number of the invalidation
using MessageCallback =
base::RepeatingCallback<void(const std::string& payload,
const std::string& private_topic,
const std::string& public_topic,
int64_t version)>;
using TokenCallback = base::RepeatingCallback<void(const std::string& token)>;
// Interface specifying the functionality of the network, required by
// invalidation client.
// TODO(crbug.com/1029481): Get rid of this interface; it has a single
// implementation and nothing refers to it directly.
class NetworkChannel {
public:
virtual ~NetworkChannel() {}
// Sets the receiver to which messages from the data center will be delivered.
// The callback will be invoked whenever an invalidation message is received
// from FCM. It is *not* guaranteed to be invoked exactly once or in-order
// (with respect to the invalidation's version number).
virtual void SetMessageReceiver(MessageCallback incoming_receiver) = 0;
// Sets the receiver to which FCM registration token will be delivered.
// The callback will be invoked whenever a new InstanceID token becomes
// available.
virtual void SetTokenReceiver(TokenCallback incoming_receiver) = 0;
};
} // namespace syncer
#endif // COMPONENTS_INVALIDATION_IMPL_NETWORK_CHANNEL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment