| 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 "content/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 WebKit::initialize(webkit_platform_support_.get()); | 66 WebKit::initialize(webkit_platform_support_.get()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 PpapiThread::~PpapiThread() { | 69 PpapiThread::~PpapiThread() { |
| 70 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL); | 70 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL); |
| 71 if (plugin_entry_points_.shutdown_module) | 71 if (plugin_entry_points_.shutdown_module) |
| 72 plugin_entry_points_.shutdown_module(); | 72 plugin_entry_points_.shutdown_module(); |
| 73 WebKit::shutdown(); | 73 WebKit::shutdown(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool PpapiThread::Send(IPC::Message* msg) { |
| 77 // Allow access from multiple threads. |
| 78 if (MessageLoop::current() == message_loop()) |
| 79 return ChildThread::Send(msg); |
| 80 |
| 81 return sync_message_filter()->Send(msg); |
| 82 } |
| 83 |
| 76 // The "regular" ChildThread implements this function and does some standard | 84 // The "regular" ChildThread implements this function and does some standard |
| 77 // dispatching, then uses the message router. We don't actually need any of | 85 // dispatching, then uses the message router. We don't actually need any of |
| 78 // this so this function just overrides that one. | 86 // this so this function just overrides that one. |
| 79 // | 87 // |
| 80 // Note that this function is called only for messages from the channel to the | 88 // Note that this function is called only for messages from the channel to the |
| 81 // browser process. Messages from the renderer process are sent via a different | 89 // browser process. Messages from the renderer process are sent via a different |
| 82 // channel that ends up at Dispatcher::OnMessageReceived. | 90 // channel that ends up at Dispatcher::OnMessageReceived. |
| 83 bool PpapiThread::OnMessageReceived(const IPC::Message& msg) { | 91 bool PpapiThread::OnMessageReceived(const IPC::Message& msg) { |
| 84 IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) | 92 IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) |
| 85 IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnMsgLoadPlugin) | 93 IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnMsgLoadPlugin) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 #endif | 155 #endif |
| 148 | 156 |
| 149 return BrokerGetFileHandleForProcess(handle, channel.peer_pid(), | 157 return BrokerGetFileHandleForProcess(handle, channel.peer_pid(), |
| 150 should_close_source); | 158 should_close_source); |
| 151 } | 159 } |
| 152 | 160 |
| 153 std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { | 161 std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { |
| 154 return &globally_seen_instance_ids_; | 162 return &globally_seen_instance_ids_; |
| 155 } | 163 } |
| 156 | 164 |
| 157 bool PpapiThread::SendToBrowser(IPC::Message* msg) { | |
| 158 if (MessageLoop::current() == message_loop()) | |
| 159 return ChildThread::Send(msg); | |
| 160 | |
| 161 return sync_message_filter()->Send(msg); | |
| 162 } | |
| 163 | |
| 164 IPC::Sender* PpapiThread::GetBrowserSender() { | 165 IPC::Sender* PpapiThread::GetBrowserSender() { |
| 165 return this; | 166 return this; |
| 166 } | 167 } |
| 167 | 168 |
| 168 std::string PpapiThread::GetUILanguage() { | 169 std::string PpapiThread::GetUILanguage() { |
| 169 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 170 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 170 return command_line->GetSwitchValueASCII(switches::kLang); | 171 return command_line->GetSwitchValueASCII(switches::kLang); |
| 171 } | 172 } |
| 172 | 173 |
| 173 void PpapiThread::PreCacheFont(const void* logfontw) { | 174 void PpapiThread::PreCacheFont(const void* logfontw) { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 420 |
| 420 // plugin() is NULL when in-process. Which is fine, because this is | 421 // plugin() is NULL when in-process. Which is fine, because this is |
| 421 // just a hook for setting the process name. | 422 // just a hook for setting the process name. |
| 422 if (GetContentClient()->plugin()) { | 423 if (GetContentClient()->plugin()) { |
| 423 GetContentClient()->plugin()->PluginProcessStarted( | 424 GetContentClient()->plugin()->PluginProcessStarted( |
| 424 path.BaseName().RemoveExtension().LossyDisplayName()); | 425 path.BaseName().RemoveExtension().LossyDisplayName()); |
| 425 } | 426 } |
| 426 } | 427 } |
| 427 | 428 |
| 428 } // namespace content | 429 } // namespace content |
| OLD | NEW |