OLD | NEW |
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 "content/browser/media/capture/aura_window_capture_machine.h" | 5 #include "content/browser/media/capture/aura_window_capture_machine.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
11 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
12 #include "cc/output/copy_output_request.h" | 13 #include "cc/output/copy_output_request.h" |
13 #include "cc/output/copy_output_result.h" | 14 #include "cc/output/copy_output_result.h" |
14 #include "content/browser/compositor/image_transport_factory.h" | 15 #include "content/browser/compositor/image_transport_factory.h" |
15 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" | 16 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" |
16 #include "content/common/gpu/client/gl_helper.h" | 17 #include "content/common/gpu/client/gl_helper.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 if (oracle_proxy_->ObserveEventAndDecideCapture( | 183 if (oracle_proxy_->ObserveEventAndDecideCapture( |
183 event, gfx::Rect(), start_time, &frame, &capture_frame_cb)) { | 184 event, gfx::Rect(), start_time, &frame, &capture_frame_cb)) { |
184 scoped_ptr<cc::CopyOutputRequest> request = | 185 scoped_ptr<cc::CopyOutputRequest> request = |
185 cc::CopyOutputRequest::CreateRequest( | 186 cc::CopyOutputRequest::CreateRequest( |
186 base::Bind(&AuraWindowCaptureMachine::DidCopyOutput, | 187 base::Bind(&AuraWindowCaptureMachine::DidCopyOutput, |
187 weak_factory_.GetWeakPtr(), | 188 weak_factory_.GetWeakPtr(), |
188 frame, start_time, capture_frame_cb)); | 189 frame, start_time, capture_frame_cb)); |
189 gfx::Rect window_rect = gfx::Rect(desktop_window_->bounds().width(), | 190 gfx::Rect window_rect = gfx::Rect(desktop_window_->bounds().width(), |
190 desktop_window_->bounds().height()); | 191 desktop_window_->bounds().height()); |
191 request->set_area(window_rect); | 192 request->set_area(window_rect); |
192 desktop_window_->layer()->RequestCopyOfOutput(request.Pass()); | 193 desktop_window_->layer()->RequestCopyOfOutput(std::move(request)); |
193 } | 194 } |
194 } | 195 } |
195 | 196 |
196 void AuraWindowCaptureMachine::DidCopyOutput( | 197 void AuraWindowCaptureMachine::DidCopyOutput( |
197 scoped_refptr<media::VideoFrame> video_frame, | 198 scoped_refptr<media::VideoFrame> video_frame, |
198 base::TimeTicks start_time, | 199 base::TimeTicks start_time, |
199 const CaptureFrameCallback& capture_frame_cb, | 200 const CaptureFrameCallback& capture_frame_cb, |
200 scoped_ptr<cc::CopyOutputResult> result) { | 201 scoped_ptr<cc::CopyOutputResult> result) { |
201 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 202 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
202 | 203 |
203 static bool first_call = true; | 204 static bool first_call = true; |
204 | 205 |
205 bool succeeded = ProcessCopyOutputResponse( | 206 bool succeeded = ProcessCopyOutputResponse( |
206 video_frame, start_time, capture_frame_cb, result.Pass()); | 207 video_frame, start_time, capture_frame_cb, std::move(result)); |
207 | 208 |
208 base::TimeDelta capture_time = base::TimeTicks::Now() - start_time; | 209 base::TimeDelta capture_time = base::TimeTicks::Now() - start_time; |
209 | 210 |
210 // The two UMA_ blocks must be put in its own scope since it creates a static | 211 // The two UMA_ blocks must be put in its own scope since it creates a static |
211 // variable which expected constant histogram name. | 212 // variable which expected constant histogram name. |
212 if (screen_capture_) { | 213 if (screen_capture_) { |
213 UMA_HISTOGRAM_TIMES(kUmaScreenCaptureTime, capture_time); | 214 UMA_HISTOGRAM_TIMES(kUmaScreenCaptureTime, capture_time); |
214 } else { | 215 } else { |
215 UMA_HISTOGRAM_TIMES(kUmaWindowCaptureTime, capture_time); | 216 UMA_HISTOGRAM_TIMES(kUmaWindowCaptureTime, capture_time); |
216 } | 217 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // TODO(miu): The CopyOutputRequest should be made earlier, at WillCommit(). | 360 // TODO(miu): The CopyOutputRequest should be made earlier, at WillCommit(). |
360 // http://crbug.com/492839 | 361 // http://crbug.com/492839 |
361 BrowserThread::PostTask( | 362 BrowserThread::PostTask( |
362 BrowserThread::UI, | 363 BrowserThread::UI, |
363 FROM_HERE, | 364 FROM_HERE, |
364 base::Bind(&AuraWindowCaptureMachine::Capture, weak_factory_.GetWeakPtr(), | 365 base::Bind(&AuraWindowCaptureMachine::Capture, weak_factory_.GetWeakPtr(), |
365 true)); | 366 true)); |
366 } | 367 } |
367 | 368 |
368 } // namespace content | 369 } // namespace content |
OLD | NEW |