Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable PushClientChannel #912

Merged
merged 1 commit into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions components/invalidation/push_client_channel_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <stdint.h>

#include <string>

#include "base/compiler_specific.h"
#include "base/memory/ptr_util.h"
#include "components/invalidation/impl/push_client_channel.h"
#include "jingle/notifier/listener/fake_push_client.h"
#include "jingle/notifier/listener/notification_defines.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace syncer {
namespace {

class PushClientChannelTest
: public ::testing::Test,
public SyncNetworkChannel::Observer {
protected:
PushClientChannelTest()
: fake_push_client_(new notifier::FakePushClient()),
push_client_channel_(base::WrapUnique(fake_push_client_)) {
push_client_channel_.AddObserver(this);
push_client_channel_.SetMessageReceiver(
invalidation::NewPermanentCallback(
this, &PushClientChannelTest::OnIncomingMessage));
push_client_channel_.SetSystemResources(nullptr);
}

~PushClientChannelTest() override {
push_client_channel_.RemoveObserver(this);
}

void OnNetworkChannelStateChanged(
InvalidatorState invalidator_state) override {
NOTREACHED();
}

void OnIncomingMessage(std::string incoming_message) {
NOTREACHED();
}

notifier::FakePushClient* fake_push_client_;
PushClientChannel push_client_channel_;
};

const char kMessage[] = "message";
const char kServiceContext[] = "service context";
const int64_t kSchedulingHash = 100;

// Simulate an incoming notification. Nothing should happen because
// the channel should not be listening.
TEST_F(PushClientChannelTest, OnIncomingMessage) {
notifier::Notification notification;
notification.data =
PushClientChannel::EncodeMessageForTest(
kMessage, kServiceContext, kSchedulingHash);
fake_push_client_->SimulateIncomingNotification(notification);
}

} // namespace
} // namespace syncer
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/components/invalidation/impl/push_client_channel.cc b/components/invalidation/impl/push_client_channel.cc
index 709d8e562c22..9170819bb45e 100644
--- a/components/invalidation/impl/push_client_channel.cc
+++ b/components/invalidation/impl/push_client_channel.cc
@@ -28,6 +28,7 @@ PushClientChannel::PushClientChannel(
: push_client_(std::move(push_client)),
scheduling_hash_(0),
sent_messages_count_(0) {
+ return; // feature disabled in Brave
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these patches can also be removed with a chromium_src override on SyncNetworkChannel to subclass PushClientChannel

push_client_->AddObserver(this);
notifier::Subscription subscription;
subscription.channel = kChannelName;
@@ -43,6 +44,7 @@ PushClientChannel::~PushClientChannel() {

void PushClientChannel::UpdateCredentials(
const std::string& email, const std::string& token) {
+ return; // feature disabled in Brave
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("puch_client_channel", R"(
semantics {
1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ test("brave_unit_tests") {
"//brave/components/brave_sync/client/bookmark_change_processor_unittest.cc",
"//brave/components/brave_webtorrent/browser/net/brave_torrent_redirect_network_delegate_helper_unittest.cc",
"//brave/components/gcm_driver/gcm_unittest.cc",
"//brave/components/invalidation/push_client_channel_unittest.cc",
"//brave/components/omnibox/browser/topsites_provider_unittest.cc",
"//brave/components/spellcheck/spellcheck_unittest.cc",
"//brave/third_party/libaddressinput/chromium/chrome_metadata_source_unittest.cc",
Expand Down