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

Side by Side Diff: chrome/renderer/media/cast_ipc_dispatcher.cc

Issue 169063003: Cast: make global_instance_ more strict (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/public/test/mock_render_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/media/cast_ipc_dispatcher.h" 5 #include "chrome/renderer/media/cast_ipc_dispatcher.h"
6 6
7 #include "chrome/common/cast_messages.h" 7 #include "chrome/common/cast_messages.h"
8 #include "chrome/renderer/media/cast_transport_sender_ipc.h" 8 #include "chrome/renderer/media/cast_transport_sender_ipc.h"
9 #include "ipc/ipc_message_macros.h" 9 #include "ipc/ipc_message_macros.h"
10 10
11 CastIPCDispatcher* CastIPCDispatcher::global_instance_ = NULL; 11 CastIPCDispatcher* CastIPCDispatcher::global_instance_ = NULL;
12 12
13 CastIPCDispatcher::CastIPCDispatcher( 13 CastIPCDispatcher::CastIPCDispatcher(
14 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) 14 const scoped_refptr<base::MessageLoopProxy>& io_message_loop)
15 : channel_(NULL), 15 : channel_(NULL),
16 io_message_loop_(io_message_loop) { 16 io_message_loop_(io_message_loop) {
17 DCHECK(io_message_loop_); 17 DCHECK(io_message_loop_);
18 DCHECK(!global_instance_); 18 DCHECK(!global_instance_);
19 } 19 }
20 20
21 CastIPCDispatcher::~CastIPCDispatcher() { 21 CastIPCDispatcher::~CastIPCDispatcher() {
22 DCHECK(io_message_loop_->BelongsToCurrentThread()); 22 DCHECK(io_message_loop_->BelongsToCurrentThread());
23 // Unfortunately, you do not always get a OnFilterRemoved call. 23 DCHECK(!global_instance_);
24 global_instance_ = NULL;
25 } 24 }
26 25
27 CastIPCDispatcher* CastIPCDispatcher::Get() { 26 CastIPCDispatcher* CastIPCDispatcher::Get() {
28 return global_instance_; 27 return global_instance_;
29 } 28 }
30 29
31 void CastIPCDispatcher::Send(IPC::Message* message) { 30 void CastIPCDispatcher::Send(IPC::Message* message) {
32 DCHECK(io_message_loop_->BelongsToCurrentThread()); 31 DCHECK(io_message_loop_->BelongsToCurrentThread());
33 if (channel_) { 32 if (channel_) {
34 channel_->Send(message); 33 channel_->Send(message);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void CastIPCDispatcher::OnFilterRemoved() { 66 void CastIPCDispatcher::OnFilterRemoved() {
68 DCHECK(io_message_loop_->BelongsToCurrentThread()); 67 DCHECK(io_message_loop_->BelongsToCurrentThread());
69 DCHECK_EQ(this, global_instance_); 68 DCHECK_EQ(this, global_instance_);
70 global_instance_ = NULL; 69 global_instance_ = NULL;
71 channel_ = NULL; 70 channel_ = NULL;
72 } 71 }
73 72
74 void CastIPCDispatcher::OnChannelClosing() { 73 void CastIPCDispatcher::OnChannelClosing() {
75 DCHECK(io_message_loop_->BelongsToCurrentThread()); 74 DCHECK(io_message_loop_->BelongsToCurrentThread());
76 DCHECK_EQ(this, global_instance_); 75 DCHECK_EQ(this, global_instance_);
77 channel_ = NULL;
78 } 76 }
79 77
80 void CastIPCDispatcher::OnReceivedPacket( 78 void CastIPCDispatcher::OnReceivedPacket(
81 int32 channel_id, 79 int32 channel_id,
82 const media::cast::transport::Packet& packet) { 80 const media::cast::transport::Packet& packet) {
83 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); 81 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id);
84 if (sender) { 82 if (sender) {
85 sender->OnReceivedPacket(packet); 83 sender->OnReceivedPacket(packet);
86 } else { 84 } else {
87 LOG(ERROR) << "CastIPCDispatcher::OnReceivedPacket " 85 LOG(ERROR) << "CastIPCDispatcher::OnReceivedPacket "
(...skipping 20 matching lines...) Expand all
108 base::TimeTicks time_sent, 106 base::TimeTicks time_sent,
109 uint32 rtp_timestamp) { 107 uint32 rtp_timestamp) {
110 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); 108 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id);
111 if (sender) { 109 if (sender) {
112 sender->OnRtpStatistics(audio, sender_info, time_sent, rtp_timestamp); 110 sender->OnRtpStatistics(audio, sender_info, time_sent, rtp_timestamp);
113 } else { 111 } else {
114 LOG(ERROR) 112 LOG(ERROR)
115 << "CastIPCDispatcher::OnNotifystatusChange on non-existing channel."; 113 << "CastIPCDispatcher::OnNotifystatusChange on non-existing channel.";
116 } 114 }
117 } 115 }
OLDNEW
« no previous file with comments | « no previous file | content/public/test/mock_render_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698