OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/proxy/plugin_globals.h" | 5 #include "ppapi/proxy/plugin_globals.h" |
6 | 6 |
7 #include "base/task_runner.h" | 7 #include "base/task_runner.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "ipc/ipc_sender.h" | 10 #include "ipc/ipc_sender.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 IPC::Sender* underlying_sender_; | 44 IPC::Sender* underlying_sender_; |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(BrowserSender); | 46 DISALLOW_COPY_AND_ASSIGN(BrowserSender); |
47 }; | 47 }; |
48 | 48 |
49 PluginGlobals* PluginGlobals::plugin_globals_ = NULL; | 49 PluginGlobals* PluginGlobals::plugin_globals_ = NULL; |
50 | 50 |
51 PluginGlobals::PluginGlobals() | 51 PluginGlobals::PluginGlobals() |
52 : ppapi::PpapiGlobals(), | 52 : ppapi::PpapiGlobals(), |
53 plugin_proxy_delegate_(NULL), | 53 plugin_proxy_delegate_(NULL), |
54 callback_tracker_(new CallbackTracker) { | 54 callback_tracker_(new CallbackTracker), |
| 55 plugin_has_been_active_(true) { |
55 DCHECK(!plugin_globals_); | 56 DCHECK(!plugin_globals_); |
56 plugin_globals_ = this; | 57 plugin_globals_ = this; |
57 | 58 |
58 // ResourceTracker asserts that we have the lock when we add new resources, | 59 // ResourceTracker asserts that we have the lock when we add new resources, |
59 // so we lock when creating the MessageLoopResource even though there is no | 60 // so we lock when creating the MessageLoopResource even though there is no |
60 // chance of race conditions. | 61 // chance of race conditions. |
61 ProxyAutoLock lock; | 62 ProxyAutoLock lock; |
62 loop_for_main_thread_ = | 63 loop_for_main_thread_ = |
63 new MessageLoopResource(MessageLoopResource::ForMainThread()); | 64 new MessageLoopResource(MessageLoopResource::ForMainThread()); |
64 } | 65 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 base::TaskRunner* PluginGlobals::GetFileTaskRunner() { | 154 base::TaskRunner* PluginGlobals::GetFileTaskRunner() { |
154 if (!file_thread_.get()) { | 155 if (!file_thread_.get()) { |
155 file_thread_.reset(new base::Thread("Plugin::File")); | 156 file_thread_.reset(new base::Thread("Plugin::File")); |
156 base::Thread::Options options; | 157 base::Thread::Options options; |
157 options.message_loop_type = base::MessageLoop::TYPE_IO; | 158 options.message_loop_type = base::MessageLoop::TYPE_IO; |
158 file_thread_->StartWithOptions(options); | 159 file_thread_->StartWithOptions(options); |
159 } | 160 } |
160 return file_thread_->message_loop_proxy(); | 161 return file_thread_->message_loop_proxy(); |
161 } | 162 } |
162 | 163 |
| 164 void PluginGlobals::MarkPluginIsActive() { |
| 165 plugin_has_been_active_ = true; |
| 166 } |
| 167 |
163 IPC::Sender* PluginGlobals::GetBrowserSender() { | 168 IPC::Sender* PluginGlobals::GetBrowserSender() { |
164 if (!browser_sender_.get()) { | 169 if (!browser_sender_.get()) { |
165 browser_sender_.reset( | 170 browser_sender_.reset( |
166 new BrowserSender(plugin_proxy_delegate_->GetBrowserSender())); | 171 new BrowserSender(plugin_proxy_delegate_->GetBrowserSender())); |
167 } | 172 } |
168 | 173 |
169 return browser_sender_.get(); | 174 return browser_sender_.get(); |
170 } | 175 } |
171 | 176 |
172 std::string PluginGlobals::GetUILanguage() { | 177 std::string PluginGlobals::GetUILanguage() { |
(...skipping 16 matching lines...) Expand all Loading... |
189 MessageLoopResource* PluginGlobals::loop_for_main_thread() { | 194 MessageLoopResource* PluginGlobals::loop_for_main_thread() { |
190 return loop_for_main_thread_.get(); | 195 return loop_for_main_thread_.get(); |
191 } | 196 } |
192 | 197 |
193 bool PluginGlobals::IsPluginGlobals() const { | 198 bool PluginGlobals::IsPluginGlobals() const { |
194 return true; | 199 return true; |
195 } | 200 } |
196 | 201 |
197 } // namespace proxy | 202 } // namespace proxy |
198 } // namespace ppapi | 203 } // namespace ppapi |
OLD | NEW |