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

Side by Side Diff: content/browser/renderer_host/media/peer_connection_tracker_host.cc

Issue 1005683003: favor DCHECK_CURRENTLY_ON for better logs in content/browser/[q-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" 4 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h"
5 5
6 #include "base/power_monitor/power_monitor.h" 6 #include "base/power_monitor/power_monitor.h"
7 #include "content/browser/media/webrtc_internals.h" 7 #include "content/browser/media/webrtc_internals.h"
8 #include "content/common/media/peer_connection_tracker_messages.h" 8 #include "content/common/media/peer_connection_tracker_messages.h"
9 #include "content/public/browser/render_process_host.h" 9 #include "content/public/browser/render_process_host.h"
10 10
(...skipping 24 matching lines...) Expand all
35 void PeerConnectionTrackerHost::OverrideThreadForMessage( 35 void PeerConnectionTrackerHost::OverrideThreadForMessage(
36 const IPC::Message& message, BrowserThread::ID* thread) { 36 const IPC::Message& message, BrowserThread::ID* thread) {
37 if (IPC_MESSAGE_CLASS(message) == PeerConnectionTrackerMsgStart) 37 if (IPC_MESSAGE_CLASS(message) == PeerConnectionTrackerMsgStart)
38 *thread = BrowserThread::UI; 38 *thread = BrowserThread::UI;
39 } 39 }
40 40
41 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() { 41 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() {
42 } 42 }
43 43
44 void PeerConnectionTrackerHost::OnChannelConnected(int32 peer_pid) { 44 void PeerConnectionTrackerHost::OnChannelConnected(int32 peer_pid) {
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 45 DCHECK_CURRENTLY_ON(BrowserThread::IO);
46 // Add PowerMonitor when connected to channel rather than in constructor due 46 // Add PowerMonitor when connected to channel rather than in constructor due
47 // to thread safety concerns. Observers of PowerMonitor must be added and 47 // to thread safety concerns. Observers of PowerMonitor must be added and
48 // removed on the same thread. BrowserMessageFilter is created on the UI 48 // removed on the same thread. BrowserMessageFilter is created on the UI
49 // thread but can be destructed on the UI or IO thread because they are 49 // thread but can be destructed on the UI or IO thread because they are
50 // referenced by RenderProcessHostImpl on the UI thread and ChannelProxy on 50 // referenced by RenderProcessHostImpl on the UI thread and ChannelProxy on
51 // the IO thread. Using OnChannelConnected and OnChannelClosing guarantees 51 // the IO thread. Using OnChannelConnected and OnChannelClosing guarantees
52 // execution on the IO thread. 52 // execution on the IO thread.
53 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); 53 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
54 if (power_monitor) 54 if (power_monitor)
55 power_monitor->AddObserver(this); 55 power_monitor->AddObserver(this);
56 } 56 }
57 57
58 void PeerConnectionTrackerHost::OnChannelClosing() { 58 void PeerConnectionTrackerHost::OnChannelClosing() {
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 59 DCHECK_CURRENTLY_ON(BrowserThread::IO);
60 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); 60 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
61 if (power_monitor) 61 if (power_monitor)
62 power_monitor->RemoveObserver(this); 62 power_monitor->RemoveObserver(this);
63 } 63 }
64 64
65 void PeerConnectionTrackerHost::OnAddPeerConnection( 65 void PeerConnectionTrackerHost::OnAddPeerConnection(
66 const PeerConnectionInfo& info) { 66 const PeerConnectionInfo& info) {
67 WebRTCInternals::GetInstance()->OnAddPeerConnection( 67 WebRTCInternals::GetInstance()->OnAddPeerConnection(
68 render_process_id_, 68 render_process_id_,
69 peer_pid(), 69 peer_pid(),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 audio_constraints, 105 audio_constraints,
106 video_constraints); 106 video_constraints);
107 } 107 }
108 108
109 void PeerConnectionTrackerHost::OnSuspend() { 109 void PeerConnectionTrackerHost::OnSuspend() {
110 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 110 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
111 base::Bind(&PeerConnectionTrackerHost::SendOnSuspendOnUIThread, this)); 111 base::Bind(&PeerConnectionTrackerHost::SendOnSuspendOnUIThread, this));
112 } 112 }
113 113
114 void PeerConnectionTrackerHost::SendOnSuspendOnUIThread() { 114 void PeerConnectionTrackerHost::SendOnSuspendOnUIThread() {
115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 115 DCHECK_CURRENTLY_ON(BrowserThread::UI);
116 content::RenderProcessHost* host = 116 content::RenderProcessHost* host =
117 content::RenderProcessHost::FromID(render_process_id_); 117 content::RenderProcessHost::FromID(render_process_id_);
118 if (host) 118 if (host)
119 host->Send(new PeerConnectionTracker_OnSuspend()); 119 host->Send(new PeerConnectionTracker_OnSuspend());
120 } 120 }
121 121
122 } // namespace content 122 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698