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

Unified Diff: media/video/capture/fake_video_capture_device.cc

Issue 88283002: Reland review 34393006: Refactor MediaStreamManager to not output real device id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make sure devices are not enumerated unless there is a valid security origin. Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: media/video/capture/fake_video_capture_device.cc
diff --git a/media/video/capture/fake_video_capture_device.cc b/media/video/capture/fake_video_capture_device.cc
index ef44d86488497ef9d7d452f38bc2a8521d6c0863..40a84bd4aeda8753ca6fb854cc5bba71db0861b9 100644
--- a/media/video/capture/fake_video_capture_device.cc
+++ b/media/video/capture/fake_video_capture_device.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "media/audio/fake_audio_input_stream.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -22,14 +23,16 @@ static const int kFakeCaptureCapabilityChangePeriod = 30;
enum { kNumberOfFakeDevices = 2 };
bool FakeVideoCaptureDevice::fail_next_create_ = false;
+base::subtle::Atomic32 FakeVideoCaptureDevice::number_of_devices_ =
+ kNumberOfFakeDevices;
void FakeVideoCaptureDevice::GetDeviceNames(Names* const device_names) {
// Empty the name list.
device_names->erase(device_names->begin(), device_names->end());
- for (int n = 0; n < kNumberOfFakeDevices; n++) {
- Name name(base::StringPrintf("fake_device_%d", n),
- base::StringPrintf("/dev/video%d", n));
+ for (int32 n = 0; n < number_of_devices_; n++) {
tommi (sloooow) - chröme 2013/11/27 22:09:43 for atomic values you need to fetch/load their val
perkj_chrome 2013/11/28 09:46:43 Done.
+ Name name("fake_device_" + base::IntToString(n),
+ "/dev/video" + base::IntToString(n));
device_names->push_back(name);
}
}
@@ -51,8 +54,8 @@ VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) {
fail_next_create_ = false;
return NULL;
}
- for (int n = 0; n < kNumberOfFakeDevices; ++n) {
- std::string possible_id = base::StringPrintf("/dev/video%d", n);
+ for (int32 n = 0; n < number_of_devices_; ++n) {
tommi (sloooow) - chröme 2013/11/27 22:09:43 atomic load
perkj_chrome 2013/11/28 09:46:43 Done.
+ std::string possible_id = "/dev/video" + base::IntToString(n);
if (device_name.id().compare(possible_id) == 0) {
return new FakeVideoCaptureDevice();
}
@@ -64,6 +67,10 @@ void FakeVideoCaptureDevice::SetFailNextCreate() {
fail_next_create_ = true;
}
+void FakeVideoCaptureDevice::SetNumberOfFakeDevices(size_t number_of_devices) {
+ number_of_devices_ = number_of_devices;
tommi (sloooow) - chröme 2013/11/27 22:09:43 you need to use atomic operations on the Atomic32
perkj_chrome 2013/11/28 09:46:43 Done.
+}
+
FakeVideoCaptureDevice::FakeVideoCaptureDevice()
: state_(kIdle),
capture_thread_("CaptureThread"),

Powered by Google App Engine
This is Rietveld 408576698