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

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host.cc

Issue 2396463002: Remove dangerous CHECK. Add unit test. (Closed)
Patch Set: Use bad_message. Add another unit test. Created 4 years, 2 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 #include "content/browser/renderer_host/media/audio_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_renderer_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 DCHECK_CURRENTLY_ON(BrowserThread::IO); 488 DCHECK_CURRENTLY_ON(BrowserThread::IO);
489 DVLOG(1) << "AudioRendererHost@" << this << "::OnCreateStream" 489 DVLOG(1) << "AudioRendererHost@" << this << "::OnCreateStream"
490 << "(stream_id=" << stream_id << ")"; 490 << "(stream_id=" << stream_id << ")";
491 491
492 // Determine whether to use the device_unique_id from an authorization, or an 492 // Determine whether to use the device_unique_id from an authorization, or an
493 // empty string (i.e., when no previous authorization was requested, assume 493 // empty string (i.e., when no previous authorization was requested, assume
494 // default device). 494 // default device).
495 std::string device_unique_id; 495 std::string device_unique_id;
496 const auto& auth_data = authorizations_.find(stream_id); 496 const auto& auth_data = authorizations_.find(stream_id);
497 if (auth_data != authorizations_.end()) { 497 if (auth_data != authorizations_.end()) {
498 CHECK(auth_data->second.first); 498 if (!auth_data->second.first) {
499 // The authorization for this stream is still pending, so it's an error
500 // to create it now.
501 content::bad_message::ReceivedBadMessage(
502 this, bad_message::ARH_CREATED_WITHOUT_AUTHORIZATION);
Guido Urdaneta 2016/10/04 13:05:45 nit: I think ARH_CREATED_STREAM_WITHOUT_AUTHORIZAT
Max Morin 2016/10/04 13:28:36 Done.
503 return;
504 }
499 device_unique_id.swap(auth_data->second.second); 505 device_unique_id.swap(auth_data->second.second);
500 authorizations_.erase(auth_data); 506 authorizations_.erase(auth_data);
501 } 507 }
502 508
503 // Fail early if either of two sanity-checks fail: 509 // Fail early if either of two sanity-checks fail:
504 // 1. There should not yet exist an AudioEntry for the given |stream_id| 510 // 1. There should not yet exist an AudioEntry for the given |stream_id|
505 // since the renderer may not create two streams with the same ID. 511 // since the renderer may not create two streams with the same ID.
506 // 2. An out-of-range render frame ID was provided. Renderers must *always* 512 // 2. An out-of-range render frame ID was provided. Renderers must *always*
507 // specify a valid render frame ID for each audio output they create, as 513 // specify a valid render frame ID for each audio output they create, as
508 // several browser-level features depend on this (e.g., OOM manager, UI 514 // several browser-level features depend on this (e.g., OOM manager, UI
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 std::string() /* matched_device_id */)); 856 std::string() /* matched_device_id */));
851 } 857 }
852 858
853 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { 859 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) {
854 DCHECK_CURRENTLY_ON(BrowserThread::IO); 860 DCHECK_CURRENTLY_ON(BrowserThread::IO);
855 const auto& i = authorizations_.find(stream_id); 861 const auto& i = authorizations_.find(stream_id);
856 return i != authorizations_.end(); 862 return i != authorizations_.end();
857 } 863 }
858 864
859 } // namespace content 865 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bad_message.h ('k') | content/browser/renderer_host/media/audio_renderer_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698