Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: extensions/browser/api/cast_channel/keep_alive_delegate.cc

Issue 2609503002: Fix cast_channel::KeepAliveDelegate DCHECK failure. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/cast_channel/keep_alive_delegate.cc
diff --git a/extensions/browser/api/cast_channel/keep_alive_delegate.cc b/extensions/browser/api/cast_channel/keep_alive_delegate.cc
index f77c9b0beb00deceaa8f9a2011d1e6f27caf9d3a..d9ad15b773a519de5edaf37fb9c50368abd1bf60 100644
--- a/extensions/browser/api/cast_channel/keep_alive_delegate.cc
+++ b/extensions/browser/api/cast_channel/keep_alive_delegate.cc
@@ -176,21 +176,30 @@ void KeepAliveDelegate::OnError(ChannelError error_state) {
}
void KeepAliveDelegate::OnMessage(const CastMessage& message) {
- DCHECK(started_);
DCHECK(thread_checker_.CalledOnValidThread());
VLOG(2) << "KeepAlive::OnMessage : " << message.payload_utf8();
- ResetTimers();
-
- if (NestedPayloadTypeEquals(kHeartbeatPingType, message)) {
- VLOG(2) << "Received PING.";
- SendKeepAliveMessage(pong_message_, kHeartbeatPongType);
- } else if (NestedPayloadTypeEquals(kHeartbeatPongType, message)) {
- VLOG(2) << "Received PONG.";
+ if (started_) {
+ ResetTimers();
+
+ if (NestedPayloadTypeEquals(kHeartbeatPingType, message)) {
+ VLOG(2) << "Received PING.";
+ SendKeepAliveMessage(pong_message_, kHeartbeatPongType);
+ return;
+ } else if (NestedPayloadTypeEquals(kHeartbeatPongType, message)) {
+ VLOG(2) << "Received PONG.";
+ return;
+ }
} else {
- // PING and PONG messages are intentionally suppressed from layers above.
- inner_delegate_->OnMessage(message);
+ if (NestedPayloadTypeEquals(kHeartbeatPingType, message) ||
+ NestedPayloadTypeEquals(kHeartbeatPongType, message)) {
+ VLOG(2) << "Received PING or PONG before starting or after stopping.";
+ return;
+ }
}
+
+ // PING and PONG messages are intentionally suppressed from layers above.
Wez 2017/01/04 00:10:17 nit: This comment is not very clear, especially af
miu 2017/01/12 22:31:27 Done. Looking at this code again, I also couldn't
Wez 2017/01/13 22:37:11 Nice :)
+ inner_delegate_->OnMessage(message);
}
void KeepAliveDelegate::Stop() {

Powered by Google App Engine
This is Rietveld 408576698