| OLD | NEW |
| 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 | 4 |
| 5 #include "content/browser/media/capture/desktop_capture_device.h" | 5 #include "content/browser/media/capture/desktop_capture_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 gfx::NativeViewId window_id) { | 194 gfx::NativeViewId window_id) { |
| 195 DCHECK(task_runner_->BelongsToCurrentThread()); | 195 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 196 DCHECK(window_id); | 196 DCHECK(window_id); |
| 197 desktop_capturer_->SetExcludedWindow(window_id); | 197 desktop_capturer_->SetExcludedWindow(window_id); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void DesktopCaptureDevice::Core::OnCaptureResult( | 200 void DesktopCaptureDevice::Core::OnCaptureResult( |
| 201 webrtc::DesktopCapturer::Result result, | 201 webrtc::DesktopCapturer::Result result, |
| 202 std::unique_ptr<webrtc::DesktopFrame> frame) { | 202 std::unique_ptr<webrtc::DesktopFrame> frame) { |
| 203 DCHECK(task_runner_->BelongsToCurrentThread()); | 203 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 204 DCHECK(client_); |
| 204 DCHECK(capture_in_progress_); | 205 DCHECK(capture_in_progress_); |
| 205 capture_in_progress_ = false; | 206 capture_in_progress_ = false; |
| 206 | 207 |
| 207 bool success = result == webrtc::DesktopCapturer::Result::SUCCESS; | 208 bool success = result == webrtc::DesktopCapturer::Result::SUCCESS; |
| 208 | 209 |
| 209 if (!first_capture_returned_) { | 210 if (!first_capture_returned_) { |
| 210 first_capture_returned_ = true; | 211 first_capture_returned_ = true; |
| 211 if (capturer_type_ == DesktopMediaID::TYPE_SCREEN) { | 212 if (capturer_type_ == DesktopMediaID::TYPE_SCREEN) { |
| 212 IncrementDesktopCaptureCounter(success ? FIRST_SCREEN_CAPTURE_SUCCEEDED | 213 IncrementDesktopCaptureCounter(success ? FIRST_SCREEN_CAPTURE_SUCCEEDED |
| 213 : FIRST_SCREEN_CAPTURE_FAILED); | 214 : FIRST_SCREEN_CAPTURE_FAILED); |
| 214 } else { | 215 } else { |
| 215 IncrementDesktopCaptureCounter(success ? FIRST_WINDOW_CAPTURE_SUCCEEDED | 216 IncrementDesktopCaptureCounter(success ? FIRST_WINDOW_CAPTURE_SUCCEEDED |
| 216 : FIRST_WINDOW_CAPTURE_FAILED); | 217 : FIRST_WINDOW_CAPTURE_FAILED); |
| 217 } | 218 } |
| 218 } | 219 } |
| 219 | 220 |
| 220 if (!success) { | 221 if (!success) { |
| 221 if (result == webrtc::DesktopCapturer::Result::ERROR_PERMANENT) | 222 if (result == webrtc::DesktopCapturer::Result::ERROR_PERMANENT) |
| 222 client_->OnError(FROM_HERE, "The desktop capturer has failed."); | 223 client_->OnError(FROM_HERE, "The desktop capturer has failed."); |
| 223 return; | 224 return; |
| 224 } | 225 } |
| 225 DCHECK(frame); | 226 DCHECK(frame); |
| 226 | 227 |
| 227 if (!client_) | |
| 228 return; | |
| 229 | |
| 230 base::TimeDelta capture_time( | 228 base::TimeDelta capture_time( |
| 231 base::TimeDelta::FromMilliseconds(frame->capture_time_ms())); | 229 base::TimeDelta::FromMilliseconds(frame->capture_time_ms())); |
| 232 | 230 |
| 233 // The two UMA_ blocks must be put in its own scope since it creates a static | 231 // The two UMA_ blocks must be put in its own scope since it creates a static |
| 234 // variable which expected constant histogram name. | 232 // variable which expected constant histogram name. |
| 235 if (capturer_type_ == DesktopMediaID::TYPE_SCREEN) { | 233 if (capturer_type_ == DesktopMediaID::TYPE_SCREEN) { |
| 236 UMA_HISTOGRAM_TIMES(kUmaScreenCaptureTime, capture_time); | 234 UMA_HISTOGRAM_TIMES(kUmaScreenCaptureTime, capture_time); |
| 237 } else { | 235 } else { |
| 238 UMA_HISTOGRAM_TIMES(kUmaWindowCaptureTime, capture_time); | 236 UMA_HISTOGRAM_TIMES(kUmaWindowCaptureTime, capture_time); |
| 239 } | 237 } |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 #else | 460 #else |
| 463 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; | 461 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; |
| 464 #endif | 462 #endif |
| 465 | 463 |
| 466 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); | 464 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); |
| 467 | 465 |
| 468 core_.reset(new Core(thread_.task_runner(), std::move(capturer), type)); | 466 core_.reset(new Core(thread_.task_runner(), std::move(capturer), type)); |
| 469 } | 467 } |
| 470 | 468 |
| 471 } // namespace content | 469 } // namespace content |
| OLD | NEW |