OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/media/android/cdm/media_drm_storage_factory.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/memory/ptr_util.h" | |
9 #include "chrome/browser/profiles/profile.h" | |
10 #include "components/cdm/browser/media_drm_storage_impl.h" | |
11 #include "components/prefs/pref_service.h" | |
12 #include "content/public/browser/browser_context.h" | |
13 #include "content/public/browser/browser_thread.h" | |
14 #include "content/public/browser/render_frame_host.h" | |
15 #include "content/public/browser/web_contents.h" | |
16 #include "mojo/public/cpp/bindings/strong_binding.h" | |
17 | |
18 namespace chrome { | |
19 | |
20 void CreateMediaDrmStorage(content::RenderFrameHost* render_frame_host, | |
21 media::mojom::MediaDrmStorageRequest request) { | |
22 DVLOG(2) << __func__; | |
23 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
24 DCHECK(render_frame_host); | |
25 | |
26 content::WebContents* web_contents = | |
27 content::WebContents::FromRenderFrameHost(render_frame_host); | |
28 if (!web_contents) | |
dcheng
2017/03/29 01:17:22
I'm curious how many of these early returns are ac
xhwang
2017/03/29 20:47:25
Well, I have the same question. But I'd rather cod
| |
29 return; | |
30 | |
31 content::BrowserContext* browser_context = web_contents->GetBrowserContext(); | |
dcheng
2017/03/29 01:17:22
Similarly, it doesn't seem like this should /ever/
xhwang
2017/03/29 20:47:25
Similarly, it's not clear to me whether this could
| |
32 if (!browser_context) | |
33 return; | |
34 | |
35 Profile* profile = Profile::FromBrowserContext(browser_context); | |
36 if (!profile) | |
37 return; | |
38 | |
39 PrefService* pref_service = profile->GetPrefs(); | |
liberato (no reviews please)
2017/03/28 16:42:43
how does lifetime for |pref_service| work? for in
xhwang
2017/03/29 20:47:25
I don't really know. But I am following how PrefSe
| |
40 if (!pref_service) | |
41 return; | |
yucliu1
2017/03/27 19:06:41
Are we able to launch the page if these early retu
xhwang
2017/03/27 20:28:46
All of these should never happen in practice :)
I
xhwang
2017/03/29 20:47:25
Done.
| |
42 | |
43 mojo::MakeStrongBinding( | |
44 base::MakeUnique<cdm::MediaDrmStorageImpl>(pref_service), | |
45 std::move(request)); | |
dcheng
2017/03/29 01:17:22
Nit: #include <utility>
xhwang
2017/03/29 20:47:25
Done.
| |
46 } | |
47 | |
48 } // namespace chrome | |
OLD | NEW |