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

Side by Side Diff: services/video_capture/video_capture_device_factory_impl.cc

Issue 2244773002: Video Capture Mojo (1.4c): Handle Subsequent Access (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@FillServicePart2
Patch Set: rockot's comments Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "media/capture/video/fake_video_capture_device.h" 9 #include "media/capture/video/fake_video_capture_device.h"
10 #include "services/video_capture/video_capture_device_factory_impl.h" 10 #include "services/video_capture/video_capture_device_factory_impl.h"
(...skipping 28 matching lines...) Expand all
39 return descriptor_.Equals(other); 39 return descriptor_.Equals(other);
40 } 40 }
41 41
42 bool VideoCaptureDeviceFactoryImpl::DeviceEntry::is_bound() const { 42 bool VideoCaptureDeviceFactoryImpl::DeviceEntry::is_bound() const {
43 return binding_->is_bound(); 43 return binding_->is_bound();
44 } 44 }
45 45
46 void VideoCaptureDeviceFactoryImpl::DeviceEntry::Bind( 46 void VideoCaptureDeviceFactoryImpl::DeviceEntry::Bind(
47 mojom::VideoCaptureDeviceProxyRequest request) { 47 mojom::VideoCaptureDeviceProxyRequest request) {
48 binding_->Bind(std::move(request)); 48 binding_->Bind(std::move(request));
49 binding_->set_connection_error_handler(base::Bind(
50 &VideoCaptureDeviceFactoryImpl::DeviceEntry::OnConnectionErrorOrClose,
51 base::Unretained(this)));
49 } 52 }
50 53
51 void VideoCaptureDeviceFactoryImpl::DeviceEntry::Unbind() { 54 void VideoCaptureDeviceFactoryImpl::DeviceEntry::Unbind() {
52 binding_->Unbind(); 55 binding_->Unbind();
56 device_proxy_->Stop();
57 }
58
59 void VideoCaptureDeviceFactoryImpl::DeviceEntry::OnConnectionErrorOrClose() {
60 Unbind();
53 } 61 }
54 62
55 VideoCaptureDeviceFactoryImpl::VideoCaptureDeviceFactoryImpl() = default; 63 VideoCaptureDeviceFactoryImpl::VideoCaptureDeviceFactoryImpl() = default;
56 64
57 VideoCaptureDeviceFactoryImpl::~VideoCaptureDeviceFactoryImpl() = default; 65 VideoCaptureDeviceFactoryImpl::~VideoCaptureDeviceFactoryImpl() = default;
58 66
59 void VideoCaptureDeviceFactoryImpl::AddDevice( 67 void VideoCaptureDeviceFactoryImpl::AddDevice(
60 mojom::VideoCaptureDeviceDescriptorPtr descriptor, 68 mojom::VideoCaptureDeviceDescriptorPtr descriptor,
61 std::unique_ptr<VideoCaptureDeviceProxyImpl> device) { 69 std::unique_ptr<VideoCaptureDeviceProxyImpl> device) {
62 devices_.emplace_back(std::move(descriptor), std::move(device)); 70 devices_.emplace_back(std::move(descriptor), std::move(device));
(...skipping 23 matching lines...) Expand all
86 entry.Unbind(); 94 entry.Unbind();
87 entry.Bind(std::move(proxy_request)); 95 entry.Bind(std::move(proxy_request));
88 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); 96 callback.Run(mojom::DeviceAccessResultCode::SUCCESS);
89 return; 97 return;
90 } 98 }
91 } 99 }
92 callback.Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND); 100 callback.Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND);
93 } 101 }
94 102
95 } // namespace video_capture 103 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/video_capture_device_factory_impl.h ('k') | services/video_capture/video_capture_device_proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698