OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "media/ozone/media_ozone_platform.h" | |
6 | |
7 #include "base/debug/trace_event.h" | |
8 #include "base/logging.h" | |
9 #include "ui/ozone/platform_object.h" | |
10 #include "ui/ozone/platform_selection.h" | |
11 | |
12 namespace media { | |
13 | |
14 namespace { | |
15 | |
16 class MediaOzonePlatformStub : public MediaOzonePlatform { | |
17 public: | |
18 MediaOzonePlatformStub() {} | |
19 | |
20 virtual ~MediaOzonePlatformStub() {} | |
21 | |
22 private: | |
23 DISALLOW_COPY_AND_ASSIGN(MediaOzonePlatformStub); | |
24 }; | |
25 | |
26 } // namespace | |
27 | |
28 // the following are just convenient stubs and need to be removed once the | |
29 // internal platforms decide to actually implement their media specifics | |
xhwang
2014/06/09 23:53:34
nit: Punctuation, Spelling and Grammar: http://goo
vignatti (out of this project)
2014/06/10 14:50:29
Done.
| |
30 | |
31 MediaOzonePlatform* CreateMediaOzonePlatformCaca() { | |
32 return new MediaOzonePlatformStub; | |
33 } | |
34 | |
35 MediaOzonePlatform* CreateMediaOzonePlatformDri() { | |
36 return new MediaOzonePlatformStub; | |
37 } | |
38 | |
39 MediaOzonePlatform* CreateMediaOzonePlatformEgltest() { | |
40 return new MediaOzonePlatformStub; | |
41 } | |
42 | |
43 MediaOzonePlatform* CreateMediaOzonePlatformGbm() { | |
44 return new MediaOzonePlatformStub; | |
45 } | |
46 | |
47 MediaOzonePlatform* CreateMediaOzonePlatformTest() { | |
48 return new MediaOzonePlatformStub; | |
49 } | |
xhwang
2014/06/09 23:53:34
Are these declared by generate_constructor_list.py
vignatti (out of this project)
2014/06/10 14:50:29
Yes, these are used in this CL and declared by gen
| |
50 | |
51 MediaOzonePlatform::MediaOzonePlatform() { | |
52 CHECK(!instance_) << "There should only be a single MediaOzonePlatform."; | |
53 instance_ = this; | |
54 } | |
55 | |
56 MediaOzonePlatform::~MediaOzonePlatform() { | |
57 CHECK_EQ(instance_, this); | |
58 instance_ = NULL; | |
59 } | |
60 | |
61 // static | |
62 MediaOzonePlatform* MediaOzonePlatform::GetInstance() { | |
63 if (!instance_) | |
64 CreateInstance(); | |
65 return instance_; | |
66 } | |
67 | |
68 VideoDecodeAccelerator* MediaOzonePlatform::CreateVideoDecodeAccelerator( | |
69 const base::Callback<bool(void)>& make_context_current) { | |
70 NOTIMPLEMENTED(); | |
71 return NULL; | |
72 } | |
73 | |
74 // static | |
75 void MediaOzonePlatform::CreateInstance() { | |
76 if (!instance_) { | |
xhwang
2014/06/09 23:53:34
nit: We like to return early:
if (instance_)
re
vignatti (out of this project)
2014/06/10 14:50:29
Done.
| |
77 TRACE_EVENT1("ozone", | |
78 "MediaOzonePlatform::Initialize", | |
79 "platform", | |
80 ui::GetOzonePlatformName()); | |
81 scoped_ptr<MediaOzonePlatform> platform = | |
82 ui::PlatformObject<MediaOzonePlatform>::Create(); | |
xhwang
2014/06/09 23:53:34
Is it possible to use base/lazy_instance.h for |in
vignatti (out of this project)
2014/06/10 14:50:29
I think we could but we preferred the other style
spang
2014/06/10 15:24:23
No, lazy instance can NOT be used when you do not
| |
83 | |
84 // TODO(spang): Currently need to leak this object. | |
xhwang
2014/06/09 23:53:34
Is there a bug tracking this?
vignatti (out of this project)
2014/06/10 14:50:29
no, sorry.
spang
2014/06/10 15:37:40
crbug.com/380884
| |
85 CHECK_EQ(instance_, platform.release()); | |
86 } | |
87 } | |
88 | |
89 // static | |
90 MediaOzonePlatform* MediaOzonePlatform::instance_; | |
91 | |
92 } // namespace media | |
OLD | NEW |