| OLD | NEW |
| 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 "content/browser/media/capture/image_capture_impl.h" | 5 #include "content/browser/media/capture/image_capture_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "content/browser/browser_main_loop.h" | 10 #include "content/browser/browser_main_loop.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 void RunFailedSetOptionsCallback( | 46 void RunFailedSetOptionsCallback( |
| 47 const ImageCaptureImpl::SetOptionsCallback& cb) { | 47 const ImageCaptureImpl::SetOptionsCallback& cb) { |
| 48 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 48 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 49 cb.Run(false); | 49 cb.Run(false); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void RunTakePhotoCallbackOnUIThread( | 52 void RunTakePhotoCallbackOnUIThread( |
| 53 const ImageCaptureImpl::TakePhotoCallback& callback, | 53 const ImageCaptureImpl::TakePhotoCallback& callback, |
| 54 const std::string& mime_type, | 54 media::mojom::BlobPtr blob) { |
| 55 const std::vector<uint8_t>& data) { | |
| 56 // TODO(mcasas): Use a mojo typemapping instead of const_cast to avoid copying | |
| 57 // |data|, https://crbug.com/630040. | |
| 58 BrowserThread::PostTask( | 55 BrowserThread::PostTask( |
| 59 BrowserThread::UI, FROM_HERE, | 56 BrowserThread::UI, FROM_HERE, |
| 60 base::Bind(callback, mime_type, | 57 base::Bind(callback, base::Passed(std::move(blob)))); |
| 61 base::Passed(const_cast<std::vector<uint8_t>*>(&data)))); | |
| 62 } | 58 } |
| 63 | 59 |
| 64 void RunFailedTakePhotoCallback(const ImageCaptureImpl::TakePhotoCallback& cb) { | 60 void RunFailedTakePhotoCallback(const ImageCaptureImpl::TakePhotoCallback& cb) { |
| 65 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 61 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 66 cb.Run("", std::vector<uint8_t>()); | 62 cb.Run(media::mojom::Blob::New()); |
| 67 } | 63 } |
| 68 | 64 |
| 69 void GetCapabilitiesOnIOThread( | 65 void GetCapabilitiesOnIOThread( |
| 70 const std::string& source_id, | 66 const std::string& source_id, |
| 71 MediaStreamManager* media_stream_manager, | 67 MediaStreamManager* media_stream_manager, |
| 72 media::ScopedResultCallback<ImageCaptureImpl::GetCapabilitiesCallback> | 68 media::ScopedResultCallback<ImageCaptureImpl::GetCapabilitiesCallback> |
| 73 callback) { | 69 callback) { |
| 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 70 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 75 | 71 |
| 76 const int session_id = | 72 const int session_id = |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 base::Bind(&TakePhotoOnIOThread, source_id, | 166 base::Bind(&TakePhotoOnIOThread, source_id, |
| 171 BrowserMainLoop::GetInstance()->media_stream_manager(), | 167 BrowserMainLoop::GetInstance()->media_stream_manager(), |
| 172 base::Passed(&scoped_callback))); | 168 base::Passed(&scoped_callback))); |
| 173 } | 169 } |
| 174 | 170 |
| 175 ImageCaptureImpl::ImageCaptureImpl( | 171 ImageCaptureImpl::ImageCaptureImpl( |
| 176 mojo::InterfaceRequest<media::mojom::ImageCapture> request) | 172 mojo::InterfaceRequest<media::mojom::ImageCapture> request) |
| 177 : binding_(this, std::move(request)) {} | 173 : binding_(this, std::move(request)) {} |
| 178 | 174 |
| 179 } // namespace content | 175 } // namespace content |
| OLD | NEW |