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

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

Issue 2606323002: Add null check for MediaDevicesManager in MDDH destructor. (Closed)
Patch Set: Add comment Created 3 years, 11 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
« no previous file with comments | « no previous file | content/browser/renderer_host/media/media_stream_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/renderer_host/media/media_devices_dispatcher_host.h" 5 #include "content/browser/renderer_host/media/media_devices_dispatcher_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 device_id_salt_(device_id_salt), 88 device_id_salt_(device_id_salt),
89 group_id_salt_(ResourceContext::CreateRandomMediaDeviceIDSalt()), 89 group_id_salt_(ResourceContext::CreateRandomMediaDeviceIDSalt()),
90 media_stream_manager_(media_stream_manager), 90 media_stream_manager_(media_stream_manager),
91 permission_checker_(base::MakeUnique<MediaDevicesPermissionChecker>()), 91 permission_checker_(base::MakeUnique<MediaDevicesPermissionChecker>()),
92 weak_factory_(this) { 92 weak_factory_(this) {
93 DCHECK_CURRENTLY_ON(BrowserThread::IO); 93 DCHECK_CURRENTLY_ON(BrowserThread::IO);
94 } 94 }
95 95
96 MediaDevicesDispatcherHost::~MediaDevicesDispatcherHost() { 96 MediaDevicesDispatcherHost::~MediaDevicesDispatcherHost() {
97 DCHECK_CURRENTLY_ON(BrowserThread::IO); 97 DCHECK_CURRENTLY_ON(BrowserThread::IO);
98 // It may happen that media_devices_manager() is destroyed before MDDH on some
99 // shutdown scenarios.
100 if (!media_stream_manager_->media_devices_manager())
101 return;
102
98 for (size_t i = 0; i < NUM_MEDIA_DEVICE_TYPES; ++i) { 103 for (size_t i = 0; i < NUM_MEDIA_DEVICE_TYPES; ++i) {
99 if (!device_change_subscriptions_[i].empty()) { 104 if (!device_change_subscriptions_[i].empty()) {
100 media_stream_manager_->media_devices_manager() 105 media_stream_manager_->media_devices_manager()
101 ->UnsubscribeDeviceChangeNotifications( 106 ->UnsubscribeDeviceChangeNotifications(
102 static_cast<MediaDeviceType>(i), this); 107 static_cast<MediaDeviceType>(i), this);
103 } 108 }
104 } 109 }
105 } 110 }
106 111
107 void MediaDevicesDispatcherHost::EnumerateDevices( 112 void MediaDevicesDispatcherHost::EnumerateDevices(
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 for (const auto& device_info : enumeration[i]) { 292 for (const auto& device_info : enumeration[i]) {
288 result[i].push_back(TranslateDeviceInfo(has_permissions[i], 293 result[i].push_back(TranslateDeviceInfo(has_permissions[i],
289 device_id_salt_, group_id_salt_, 294 device_id_salt_, group_id_salt_,
290 security_origin, device_info)); 295 security_origin, device_info));
291 } 296 }
292 } 297 }
293 client_callback.Run(result); 298 client_callback.Run(result);
294 } 299 }
295 300
296 } // namespace content 301 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/media_stream_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698