OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cdm/browser_cdm_manager.h" | 5 #include "content/browser/media/cdm/browser_cdm_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // This may overwrite an existing entry of |render_process_id| if the | 74 // This may overwrite an existing entry of |render_process_id| if the |
75 // previous process crashed and didn't cleanup its child frames. For example, | 75 // previous process crashed and didn't cleanup its child frames. For example, |
76 // see FrameTreeBrowserTest.FrameTreeAfterCrash test. | 76 // see FrameTreeBrowserTest.FrameTreeAfterCrash test. |
77 g_browser_cdm_manager_map.Get()[render_process_id] = this; | 77 g_browser_cdm_manager_map.Get()[render_process_id] = this; |
78 } | 78 } |
79 | 79 |
80 BrowserCdmManager::~BrowserCdmManager() { | 80 BrowserCdmManager::~BrowserCdmManager() { |
81 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 81 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
82 DCHECK(g_browser_cdm_manager_map.Get().count(render_process_id_)); | 82 DCHECK(g_browser_cdm_manager_map.Get().count(render_process_id_)); |
83 | 83 |
84 g_browser_cdm_manager_map.Get().erase(render_process_id_); | 84 // If an entry of |render_process_id| was overwritten, we shouldn't remove |
| 85 // the entry. For example, see FrameTreeBrowserTest.FrameTreeAfterCrash test, |
| 86 // and http://crbug.com/430251. |
| 87 if (g_browser_cdm_manager_map.Get()[render_process_id_] == this) |
| 88 g_browser_cdm_manager_map.Get().erase(render_process_id_); |
85 } | 89 } |
86 | 90 |
87 // Makes sure BrowserCdmManager is always deleted on the Browser UI thread. | 91 // Makes sure BrowserCdmManager is always deleted on the Browser UI thread. |
88 void BrowserCdmManager::OnDestruct() const { | 92 void BrowserCdmManager::OnDestruct() const { |
89 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 93 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
90 delete this; | 94 delete this; |
91 } else { | 95 } else { |
92 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); | 96 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); |
93 } | 97 } |
94 } | 98 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 DLOG(WARNING) << "No CDM found for: " << render_frame_id << ", " << cdm_id; | 389 DLOG(WARNING) << "No CDM found for: " << render_frame_id << ", " << cdm_id; |
386 SendSessionError(render_frame_id, cdm_id, session_id); | 390 SendSessionError(render_frame_id, cdm_id, session_id); |
387 return; | 391 return; |
388 } | 392 } |
389 | 393 |
390 // This could fail, in which case a SessionError will be fired. | 394 // This could fail, in which case a SessionError will be fired. |
391 cdm->CreateSession(session_id, content_type, &init_data[0], init_data.size()); | 395 cdm->CreateSession(session_id, content_type, &init_data[0], init_data.size()); |
392 } | 396 } |
393 | 397 |
394 } // namespace content | 398 } // namespace content |
OLD | NEW |