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

Side by Side Diff: chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc

Issue 1100293004: [chrome/browser/renderer_host] favor DCHECK_CURRENTLY_ON for better logs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing changes Created 5 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 4
5 #include "chrome/browser/renderer_host/pepper/pepper_output_protection_message_f ilter.h" 5 #include "chrome/browser/renderer_host/pepper/pepper_output_protection_message_f ilter.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 8 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
9 #include "content/public/browser/browser_ppapi_host.h" 9 #include "content/public/browser/browser_ppapi_host.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_NETWORK), 59 static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_NETWORK),
60 "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NETWORK value mismatch"); 60 "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NETWORK value mismatch");
61 static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE) == 61 static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE) ==
62 static_cast<int>(ui::CONTENT_PROTECTION_METHOD_NONE), 62 static_cast<int>(ui::CONTENT_PROTECTION_METHOD_NONE),
63 "PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE value mismatch"); 63 "PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE value mismatch");
64 static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP) == 64 static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP) ==
65 static_cast<int>(ui::CONTENT_PROTECTION_METHOD_HDCP), 65 static_cast<int>(ui::CONTENT_PROTECTION_METHOD_HDCP),
66 "PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP value mismatch"); 66 "PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP value mismatch");
67 67
68 bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) { 68 bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) {
69 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 69 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
70 gfx::NativeView native_view = rfh->GetNativeView(); 70 gfx::NativeView native_view = rfh->GetNativeView();
71 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); 71 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view);
72 if (!screen) 72 if (!screen)
73 return false; 73 return false;
74 gfx::Display display = screen->GetDisplayNearestWindow(native_view); 74 gfx::Display display = screen->GetDisplayNearestWindow(native_view);
75 *display_id = display.id(); 75 *display_id = display.id();
76 return true; 76 return true;
77 } 77 }
78 78
79 void DoNothing(bool status) { 79 void DoNothing(bool status) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 }; 137 };
138 138
139 PepperOutputProtectionMessageFilter::Delegate::Delegate(int render_process_id, 139 PepperOutputProtectionMessageFilter::Delegate::Delegate(int render_process_id,
140 int render_frame_id) 140 int render_frame_id)
141 : render_process_id_(render_process_id), 141 : render_process_id_(render_process_id),
142 render_frame_id_(render_frame_id), 142 render_frame_id_(render_frame_id),
143 window_(NULL), 143 window_(NULL),
144 client_id_(ui::DisplayConfigurator::kInvalidClientId), 144 client_id_(ui::DisplayConfigurator::kInvalidClientId),
145 display_id_(0), 145 display_id_(0),
146 weak_ptr_factory_(this) { 146 weak_ptr_factory_(this) {
147 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 147 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
148 } 148 }
149 149
150 PepperOutputProtectionMessageFilter::Delegate::~Delegate() { 150 PepperOutputProtectionMessageFilter::Delegate::~Delegate() {
151 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 151 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
152 152
153 ui::DisplayConfigurator* configurator = 153 ui::DisplayConfigurator* configurator =
154 ash::Shell::GetInstance()->display_configurator(); 154 ash::Shell::GetInstance()->display_configurator();
155 configurator->UnregisterContentProtectionClient(client_id_); 155 configurator->UnregisterContentProtectionClient(client_id_);
156 156
157 if (window_) 157 if (window_)
158 window_->RemoveObserver(this); 158 window_->RemoveObserver(this);
159 } 159 }
160 160
161 ui::DisplayConfigurator::ContentProtectionClientId 161 ui::DisplayConfigurator::ContentProtectionClientId
162 PepperOutputProtectionMessageFilter::Delegate::GetClientId() { 162 PepperOutputProtectionMessageFilter::Delegate::GetClientId() {
163 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 163 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
164 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) { 164 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) {
165 content::RenderFrameHost* rfh = 165 content::RenderFrameHost* rfh =
166 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); 166 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
167 if (!GetCurrentDisplayId(rfh, &display_id_)) 167 if (!GetCurrentDisplayId(rfh, &display_id_))
168 return ui::DisplayConfigurator::kInvalidClientId; 168 return ui::DisplayConfigurator::kInvalidClientId;
169 169
170 window_ = rfh->GetNativeView(); 170 window_ = rfh->GetNativeView();
171 if (!window_) 171 if (!window_)
172 return ui::DisplayConfigurator::kInvalidClientId; 172 return ui::DisplayConfigurator::kInvalidClientId;
173 173
174 ui::DisplayConfigurator* configurator = 174 ui::DisplayConfigurator* configurator =
175 ash::Shell::GetInstance()->display_configurator(); 175 ash::Shell::GetInstance()->display_configurator();
176 client_id_ = configurator->RegisterContentProtectionClient(); 176 client_id_ = configurator->RegisterContentProtectionClient();
177 177
178 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) 178 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId)
179 window_->AddObserver(this); 179 window_->AddObserver(this);
180 } 180 }
181 return client_id_; 181 return client_id_;
182 } 182 }
183 183
184 void PepperOutputProtectionMessageFilter::Delegate::QueryStatus( 184 void PepperOutputProtectionMessageFilter::Delegate::QueryStatus(
185 const QueryStatusCallback& callback) { 185 const QueryStatusCallback& callback) {
186 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 186 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
187 187
188 content::RenderFrameHost* rfh = 188 content::RenderFrameHost* rfh =
189 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); 189 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
190 if (!rfh) { 190 if (!rfh) {
191 LOG(WARNING) << "RenderFrameHost is not alive."; 191 LOG(WARNING) << "RenderFrameHost is not alive.";
192 callback.Run(PP_ERROR_FAILED, 0, 0); 192 callback.Run(PP_ERROR_FAILED, 0, 0);
193 return; 193 return;
194 } 194 }
195 195
196 ui::DisplayConfigurator* configurator = 196 ui::DisplayConfigurator* configurator =
197 ash::Shell::GetInstance()->display_configurator(); 197 ash::Shell::GetInstance()->display_configurator();
198 configurator->QueryContentProtectionStatus( 198 configurator->QueryContentProtectionStatus(
199 GetClientId(), display_id_, 199 GetClientId(), display_id_,
200 base::Bind( 200 base::Bind(
201 &PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete, 201 &PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete,
202 weak_ptr_factory_.GetWeakPtr(), callback)); 202 weak_ptr_factory_.GetWeakPtr(), callback));
203 } 203 }
204 204
205 void PepperOutputProtectionMessageFilter::Delegate::EnableProtection( 205 void PepperOutputProtectionMessageFilter::Delegate::EnableProtection(
206 uint32_t desired_method_mask, 206 uint32_t desired_method_mask,
207 const EnableProtectionCallback& callback) { 207 const EnableProtectionCallback& callback) {
208 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 208 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
209 209
210 ui::DisplayConfigurator* configurator = 210 ui::DisplayConfigurator* configurator =
211 ash::Shell::GetInstance()->display_configurator(); 211 ash::Shell::GetInstance()->display_configurator();
212 configurator->EnableContentProtection( 212 configurator->EnableContentProtection(
213 GetClientId(), display_id_, desired_method_mask, 213 GetClientId(), display_id_, desired_method_mask,
214 base::Bind(&PepperOutputProtectionMessageFilter::Delegate:: 214 base::Bind(&PepperOutputProtectionMessageFilter::Delegate::
215 EnableProtectionComplete, 215 EnableProtectionComplete,
216 weak_ptr_factory_.GetWeakPtr(), callback)); 216 weak_ptr_factory_.GetWeakPtr(), callback));
217 desired_method_mask_ = desired_method_mask; 217 desired_method_mask_ = desired_method_mask;
218 } 218 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 window_->RemoveObserver(this); 287 window_->RemoveObserver(this);
288 window_ = NULL; 288 window_ = NULL;
289 } 289 }
290 #endif // defined(OS_CHROMEOS) 290 #endif // defined(OS_CHROMEOS)
291 291
292 PepperOutputProtectionMessageFilter::PepperOutputProtectionMessageFilter( 292 PepperOutputProtectionMessageFilter::PepperOutputProtectionMessageFilter(
293 content::BrowserPpapiHost* host, 293 content::BrowserPpapiHost* host,
294 PP_Instance instance) 294 PP_Instance instance)
295 : weak_ptr_factory_(this) { 295 : weak_ptr_factory_(this) {
296 #if defined(OS_CHROMEOS) 296 #if defined(OS_CHROMEOS)
297 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 297 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
298 int render_process_id = 0; 298 int render_process_id = 0;
299 int render_frame_id = 0; 299 int render_frame_id = 0;
300 host->GetRenderFrameIDsForInstance( 300 host->GetRenderFrameIDsForInstance(
301 instance, &render_process_id, &render_frame_id); 301 instance, &render_process_id, &render_frame_id);
302 delegate_ = new Delegate(render_process_id, render_frame_id); 302 delegate_ = new Delegate(render_process_id, render_frame_id);
303 #else 303 #else
304 NOTIMPLEMENTED(); 304 NOTIMPLEMENTED();
305 #endif 305 #endif
306 } 306 }
307 307
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 377
378 void PepperOutputProtectionMessageFilter::OnEnableProtectionComplete( 378 void PepperOutputProtectionMessageFilter::OnEnableProtectionComplete(
379 ppapi::host::ReplyMessageContext reply_context, 379 ppapi::host::ReplyMessageContext reply_context,
380 int32_t result) { 380 int32_t result) {
381 reply_context.params.set_result(result); 381 reply_context.params.set_result(result);
382 SendReply(reply_context, 382 SendReply(reply_context,
383 PpapiPluginMsg_OutputProtection_EnableProtectionReply()); 383 PpapiPluginMsg_OutputProtection_EnableProtectionReply());
384 } 384 }
385 385
386 } // namespace chrome 386 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698