Chromium Code Reviews

Unified Diff: content/browser/renderer_host/media/media_stream_manager_unittest.cc

Issue 2065383003: Revert of Make default media device ID salts random by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: content/browser/renderer_host/media/media_stream_manager_unittest.cc
diff --git a/content/browser/renderer_host/media/media_stream_manager_unittest.cc b/content/browser/renderer_host/media/media_stream_manager_unittest.cc
index b7bc6b89135304f72903519f285a9bc26dc69c57..2f207197a2efb510ed5ac2273ce8b9ee8579c625 100644
--- a/content/browser/renderer_host/media/media_stream_manager_unittest.cc
+++ b/content/browser/renderer_host/media/media_stream_manager_unittest.cc
@@ -60,7 +60,13 @@
namespace {
-const char kMockSalt[] = "";
+std::string ReturnMockSalt() {
+ return std::string();
+}
+
+ResourceContext::SaltCallback GetMockSaltCallback() {
+ return base::Bind(&ReturnMockSalt);
+}
// This class mocks the audio manager and overrides some methods to ensure that
// we can run our tests on the buildbots.
@@ -310,28 +316,30 @@
const std::string unique_default_id(
media::AudioDeviceDescription::kDefaultDeviceId);
const std::string hashed_default_id =
- MediaStreamManager::GetHMACForMediaDeviceID(kMockSalt, security_origin,
- unique_default_id);
+ MediaStreamManager::GetHMACForMediaDeviceID(
+ GetMockSaltCallback(), security_origin, unique_default_id);
EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC(
- kMockSalt, security_origin, hashed_default_id, unique_default_id));
+ GetMockSaltCallback(), security_origin, hashed_default_id,
+ unique_default_id));
EXPECT_EQ(unique_default_id, hashed_default_id);
const std::string unique_communications_id(
media::AudioDeviceDescription::kCommunicationsDeviceId);
const std::string hashed_communications_id =
- MediaStreamManager::GetHMACForMediaDeviceID(kMockSalt, security_origin,
- unique_communications_id);
+ MediaStreamManager::GetHMACForMediaDeviceID(
+ GetMockSaltCallback(), security_origin, unique_communications_id);
EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC(
- kMockSalt, security_origin, hashed_communications_id,
+ GetMockSaltCallback(), security_origin, hashed_communications_id,
unique_communications_id));
EXPECT_EQ(unique_communications_id, hashed_communications_id);
const std::string unique_other_id("other-unique-id");
const std::string hashed_other_id =
- MediaStreamManager::GetHMACForMediaDeviceID(kMockSalt, security_origin,
- unique_other_id);
+ MediaStreamManager::GetHMACForMediaDeviceID(
+ GetMockSaltCallback(), security_origin, unique_other_id);
EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC(
- kMockSalt, security_origin, hashed_other_id, unique_other_id));
+ GetMockSaltCallback(), security_origin, hashed_other_id,
+ unique_other_id));
EXPECT_NE(unique_other_id, hashed_other_id);
EXPECT_EQ(hashed_other_id.size(), 64U);
for (const char& c : hashed_other_id)
@@ -352,7 +360,7 @@
EXPECT_CALL(requester,
MockDevicesEnumerated(render_frame_id, page_request_id, _, _));
std::string label = media_stream_manager_->EnumerateDevices(
- &requester, render_process_id, render_frame_id, kMockSalt,
+ &requester, render_process_id, render_frame_id, GetMockSaltCallback(),
page_request_id, MEDIA_DEVICE_AUDIO_OUTPUT, security_origin);
run_loop.Run();
// CancelRequest is necessary for enumeration requests.
@@ -381,7 +389,7 @@
MockDevicesEnumerated(render_frame_id, page_request_id, _, _));
EXPECT_CALL(requester, MockDevicesChanged(_)).Times(0);
std::string label = media_stream_manager_->EnumerateDevices(
- &requester, render_process_id, render_frame_id, kMockSalt,
+ &requester, render_process_id, render_frame_id, GetMockSaltCallback(),
page_request_id, MEDIA_DEVICE_AUDIO_CAPTURE, security_origin);
run_loop_enumeration.Run();
media_stream_manager_->CancelRequest(label);
@@ -412,7 +420,7 @@
EXPECT_CALL(requester,
MockDevicesEnumerated(render_frame_id, page_request_id, _, _));
std::string label = media_stream_manager_->EnumerateDevices(
- &requester, render_process_id, render_frame_id, kMockSalt,
+ &requester, render_process_id, render_frame_id, GetMockSaltCallback(),
page_request_id, MEDIA_DEVICE_AUDIO_CAPTURE, security_origin);
run_loop.Run();
media_stream_manager_->CancelRequest(label);
« no previous file with comments | « content/browser/renderer_host/media/media_stream_manager.cc ('k') | content/browser/resource_context_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine