Skip to content

Commit

Permalink
Merge pull request #912 from brave/mpilgrim_push_client_channel
Browse files Browse the repository at this point in the history
Disable PushClientChannel
  • Loading branch information
pilgrim-brave authored Nov 15, 2018
2 parents 0295402 + 809905f commit e91cf89
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
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
20 changes: 20 additions & 0 deletions patches/components-invalidation-impl-push_client_channel.cc.patch
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
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 @@ -67,6 +67,7 @@ test("brave_unit_tests") {
"//brave/components/brave_webtorrent/browser/net/brave_torrent_redirect_network_delegate_helper_unittest.cc",
"//brave/components/invalidation/fcm_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

0 comments on commit e91cf89

Please sign in to comment.