-
Notifications
You must be signed in to change notification settings - Fork 868
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #912 from brave/mpilgrim_push_client_channel
Disable PushClientChannel
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
20
patches/components-invalidation-impl-push_client_channel.cc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters