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 #ifndef CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ |
6 #define CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ | 6 #define CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/containers/scoped_ptr_hash_map.h" | |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
17 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
18 #include "content/common/media/cdm_messages.h" | 17 #include "content/common/media/cdm_messages.h" |
19 #include "content/common/media/cdm_messages_enums.h" | 18 #include "content/common/media/cdm_messages_enums.h" |
20 #include "content/public/browser/browser_message_filter.h" | 19 #include "content/public/browser/browser_message_filter.h" |
21 #include "content/public/common/permission_status.mojom.h" | 20 #include "content/public/common/permission_status.mojom.h" |
22 #include "ipc/ipc_message.h" | 21 #include "ipc/ipc_message.h" |
23 #include "media/base/browser_cdm.h" | |
24 #include "media/base/cdm_promise.h" | 22 #include "media/base/cdm_promise.h" |
25 #include "media/base/eme_constants.h" | 23 #include "media/base/eme_constants.h" |
26 #include "media/base/media_keys.h" | 24 #include "media/base/media_keys.h" |
27 #include "url/gurl.h" | 25 #include "url/gurl.h" |
28 | 26 |
29 struct CdmHostMsg_CreateSessionAndGenerateRequest_Params; | 27 struct CdmHostMsg_CreateSessionAndGenerateRequest_Params; |
30 | 28 |
31 namespace content { | 29 namespace content { |
32 | 30 |
33 // This class manages all CDM objects. It receives control operations from the | 31 // This class manages all CDM objects. It receives control operations from the |
(...skipping 11 matching lines...) Expand all Loading... |
45 // all messages are posted to the browser UI thread. | 43 // all messages are posted to the browser UI thread. |
46 BrowserCdmManager(int render_process_id, | 44 BrowserCdmManager(int render_process_id, |
47 const scoped_refptr<base::TaskRunner>& task_runner); | 45 const scoped_refptr<base::TaskRunner>& task_runner); |
48 | 46 |
49 // BrowserMessageFilter implementations. | 47 // BrowserMessageFilter implementations. |
50 void OnDestruct() const override; | 48 void OnDestruct() const override; |
51 base::TaskRunner* OverrideTaskRunnerForMessage( | 49 base::TaskRunner* OverrideTaskRunnerForMessage( |
52 const IPC::Message& message) override; | 50 const IPC::Message& message) override; |
53 bool OnMessageReceived(const IPC::Message& message) override; | 51 bool OnMessageReceived(const IPC::Message& message) override; |
54 | 52 |
55 media::BrowserCdm* GetCdm(int render_frame_id, int cdm_id) const; | 53 // Returns the CDM associated with |render_frame_id| and |cdm_id|. Returns |
| 54 // null if no such CDM exists. |
| 55 scoped_refptr<media::MediaKeys> GetCdm(int render_frame_id, int cdm_id) const; |
56 | 56 |
57 // Notifies that the render frame has been deleted so that all CDMs belongs | 57 // Notifies that the render frame has been deleted so that all CDMs belongs |
58 // to this render frame needs to be destroyed as well. This is needed because | 58 // to this render frame needs to be destroyed as well. This is needed because |
59 // in some cases (e.g. fast termination of the renderer), the message to | 59 // in some cases (e.g. fast termination of the renderer), the message to |
60 // destroy the CDM will not be received. | 60 // destroy the CDM will not be received. |
61 void RenderFrameDeleted(int render_frame_id); | 61 void RenderFrameDeleted(int render_frame_id); |
62 | 62 |
63 // Promise handlers. | 63 // Promise handlers. |
64 void ResolvePromise(int render_frame_id, int cdm_id, uint32_t promise_id); | 64 void ResolvePromise(int render_frame_id, int cdm_id, uint32_t promise_id); |
65 void ResolvePromiseWithSession(int render_frame_id, | 65 void ResolvePromiseWithSession(int render_frame_id, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 const int render_process_id_; | 190 const int render_process_id_; |
191 | 191 |
192 // TaskRunner to dispatch all CDM messages to. If it's NULL, all messages are | 192 // TaskRunner to dispatch all CDM messages to. If it's NULL, all messages are |
193 // dispatched to the browser UI thread. | 193 // dispatched to the browser UI thread. |
194 scoped_refptr<base::TaskRunner> task_runner_; | 194 scoped_refptr<base::TaskRunner> task_runner_; |
195 | 195 |
196 // The key in the following maps is a combination of |render_frame_id| and | 196 // The key in the following maps is a combination of |render_frame_id| and |
197 // |cdm_id|. | 197 // |cdm_id|. |
198 | 198 |
199 // Map of managed BrowserCdms. | 199 // Map of managed CDMs. |
200 typedef base::ScopedPtrHashMap<uint64, media::ScopedBrowserCdmPtr> CdmMap; | 200 typedef std::map<uint64, scoped_refptr<media::MediaKeys>> CdmMap; |
201 CdmMap cdm_map_; | 201 CdmMap cdm_map_; |
202 | 202 |
203 // Map of CDM's security origin. | 203 // Map of CDM's security origin. |
204 std::map<uint64, GURL> cdm_security_origin_map_; | 204 std::map<uint64, GURL> cdm_security_origin_map_; |
205 | 205 |
206 base::WeakPtrFactory<BrowserCdmManager> weak_ptr_factory_; | 206 base::WeakPtrFactory<BrowserCdmManager> weak_ptr_factory_; |
207 | 207 |
208 DISALLOW_COPY_AND_ASSIGN(BrowserCdmManager); | 208 DISALLOW_COPY_AND_ASSIGN(BrowserCdmManager); |
209 }; | 209 }; |
210 | 210 |
211 } // namespace content | 211 } // namespace content |
212 | 212 |
213 #endif // CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ | 213 #endif // CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ |
OLD | NEW |