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

Side by Side Diff: content/renderer/media/video_capture_impl.cc

Issue 2755813002: Begin to wean child processes off reliance on a persistent service_manager::Connection to the brows… (Closed)
Patch Set: . Created 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Notes about usage of this object by VideoCaptureImplManager. 5 // Notes about usage of this object by VideoCaptureImplManager.
6 // 6 //
7 // VideoCaptureImplManager access this object by using a Unretained() 7 // VideoCaptureImplManager access this object by using a Unretained()
8 // binding and tasks on the IO thread. It is then important that 8 // binding and tasks on the IO thread. It is then important that
9 // VideoCaptureImpl never post task to itself. All operations must be 9 // VideoCaptureImpl never post task to itself. All operations must be
10 // synchronous. 10 // synchronous.
11 11
12 #include "content/renderer/media/video_capture_impl.h" 12 #include "content/renderer/media/video_capture_impl.h"
13 13
14 #include <stddef.h> 14 #include <stddef.h>
15 #include <utility> 15 #include <utility>
16 16
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/stl_util.h" 19 #include "base/stl_util.h"
20 #include "base/trace_event/trace_event.h" 20 #include "base/trace_event/trace_event.h"
21 #include "content/child/child_process.h" 21 #include "content/child/child_process.h"
22 #include "content/public/child/child_thread.h" 22 #include "content/public/child/child_thread.h"
23 #include "content/public/common/service_names.mojom.h"
23 #include "media/base/bind_to_current_loop.h" 24 #include "media/base/bind_to_current_loop.h"
24 #include "media/base/limits.h" 25 #include "media/base/limits.h"
25 #include "media/base/video_frame.h" 26 #include "media/base/video_frame.h"
26 #include "mojo/public/cpp/system/platform_handle.h" 27 #include "mojo/public/cpp/system/platform_handle.h"
27 #include "services/service_manager/public/cpp/interface_provider.h" 28 #include "services/service_manager/public/cpp/connector.h"
28 29
29 namespace content { 30 namespace content {
30 31
31 // A holder of a memory-backed buffer and accessors to it. 32 // A holder of a memory-backed buffer and accessors to it.
32 class VideoCaptureImpl::ClientBuffer 33 class VideoCaptureImpl::ClientBuffer
33 : public base::RefCountedThreadSafe<ClientBuffer> { 34 : public base::RefCountedThreadSafe<ClientBuffer> {
34 public: 35 public:
35 ClientBuffer(std::unique_ptr<base::SharedMemory> buffer, size_t buffer_size) 36 ClientBuffer(std::unique_ptr<base::SharedMemory> buffer, size_t buffer_size)
36 : buffer_(std::move(buffer)), buffer_size_(buffer_size) {} 37 : buffer_(std::move(buffer)), buffer_size_(buffer_size) {}
37 38
(...skipping 30 matching lines...) Expand all
68 : device_id_(session_id), 69 : device_id_(session_id),
69 session_id_(session_id), 70 session_id_(session_id),
70 video_capture_host_for_testing_(nullptr), 71 video_capture_host_for_testing_(nullptr),
71 observer_binding_(this), 72 observer_binding_(this),
72 state_(VIDEO_CAPTURE_STATE_STOPPED), 73 state_(VIDEO_CAPTURE_STATE_STOPPED),
73 weak_factory_(this) { 74 weak_factory_(this) {
74 io_thread_checker_.DetachFromThread(); 75 io_thread_checker_.DetachFromThread();
75 76
76 if (ChildThread::Get()) { // This will be null in unit tests. 77 if (ChildThread::Get()) { // This will be null in unit tests.
77 mojom::VideoCaptureHostPtr temp_video_capture_host; 78 mojom::VideoCaptureHostPtr temp_video_capture_host;
78 ChildThread::Get()->GetRemoteInterfaces()->GetInterface( 79 ChildThread::Get()->GetConnector()->BindInterface(
80 mojom::kBrowserServiceName,
79 mojo::MakeRequest(&temp_video_capture_host)); 81 mojo::MakeRequest(&temp_video_capture_host));
80 video_capture_host_info_ = temp_video_capture_host.PassInterface(); 82 video_capture_host_info_ = temp_video_capture_host.PassInterface();
81 } 83 }
82 } 84 }
83 85
84 VideoCaptureImpl::~VideoCaptureImpl() { 86 VideoCaptureImpl::~VideoCaptureImpl() {
85 DCHECK(io_thread_checker_.CalledOnValidThread()); 87 DCHECK(io_thread_checker_.CalledOnValidThread());
86 if ((state_ == VIDEO_CAPTURE_STATE_STARTING || 88 if ((state_ == VIDEO_CAPTURE_STATE_STARTING ||
87 state_ == VIDEO_CAPTURE_STATE_STARTED) && 89 state_ == VIDEO_CAPTURE_STATE_STARTED) &&
88 GetVideoCaptureHost()) 90 GetVideoCaptureHost())
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // destructor. |metadata| is still valid for read-access at this point. 439 // destructor. |metadata| is still valid for read-access at this point.
438 double consumer_resource_utilization = -1.0; 440 double consumer_resource_utilization = -1.0;
439 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, 441 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION,
440 &consumer_resource_utilization)) { 442 &consumer_resource_utilization)) {
441 consumer_resource_utilization = -1.0; 443 consumer_resource_utilization = -1.0;
442 } 444 }
443 callback_to_io_thread.Run(consumer_resource_utilization); 445 callback_to_io_thread.Run(consumer_resource_utilization);
444 } 446 }
445 447
446 } // namespace content 448 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gamepad_shared_memory_reader.cc ('k') | content/renderer/mojo/blink_interface_provider_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698