| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/plugin/plugin_thread.h" | 5 #include "chrome/plugin/plugin_thread.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 base::KillProcess(base::GetCurrentProcessHandle(), 0, /* wait= */ false); | 96 base::KillProcess(base::GetCurrentProcessHandle(), 0, /* wait= */ false); |
| 97 | 97 |
| 98 // Call this last because it deletes the ResourceDispatcher, which is used | 98 // Call this last because it deletes the ResourceDispatcher, which is used |
| 99 // in some of the above cleanup. | 99 // in some of the above cleanup. |
| 100 // See http://code.google.com/p/chromium/issues/detail?id=8980 | 100 // See http://code.google.com/p/chromium/issues/detail?id=8980 |
| 101 ChildThread::CleanUp(); | 101 ChildThread::CleanUp(); |
| 102 lazy_tls.Pointer()->Set(NULL); | 102 lazy_tls.Pointer()->Set(NULL); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void PluginThread::OnCreateChannel( | 105 void PluginThread::OnCreateChannel( |
| 106 #if defined(OS_POSIX) | |
| 107 base::FileDescriptor socket, | |
| 108 #endif | |
| 109 int process_id, | 106 int process_id, |
| 110 bool off_the_record) { | 107 bool off_the_record) { |
| 111 int fd = -1; | 108 scoped_refptr<PluginChannel> channel = |
| 109 PluginChannel::GetPluginChannel(process_id, owner_loop()); |
| 110 IPC::ChannelHandle channel_handle; |
| 111 if (channel.get()) { |
| 112 channel_handle.name = channel->channel_name(); |
| 112 #if defined(OS_POSIX) | 113 #if defined(OS_POSIX) |
| 113 fd = socket.fd; | 114 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so that |
| 115 // it gets closed after it has been sent. |
| 116 int renderer_fd = channel->DisownRendererFd(); |
| 117 channel_handle.socket = base::FileDescriptor(renderer_fd, true); |
| 114 #endif | 118 #endif |
| 115 std::string channel_name; | |
| 116 scoped_refptr<PluginChannel> channel = | |
| 117 PluginChannel::GetPluginChannel(process_id, owner_loop(), fd); | |
| 118 if (channel.get()) { | |
| 119 channel_name = channel->channel_name(); | |
| 120 channel->set_off_the_record(off_the_record); | 119 channel->set_off_the_record(off_the_record); |
| 121 } | 120 } |
| 122 | 121 |
| 123 Send(new PluginProcessHostMsg_ChannelCreated(channel_name)); | 122 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); |
| 124 } | 123 } |
| 125 | 124 |
| 126 void PluginThread::OnPluginMessage(const std::vector<unsigned char> &data) { | 125 void PluginThread::OnPluginMessage(const std::vector<unsigned char> &data) { |
| 127 // We Add/Release ref here to ensure that something will trigger the | 126 // We Add/Release ref here to ensure that something will trigger the |
| 128 // shutdown mechanism for processes started in the absence of renderer's | 127 // shutdown mechanism for processes started in the absence of renderer's |
| 129 // opening a plugin channel. | 128 // opening a plugin channel. |
| 130 ChildProcess::current()->AddRefProcess(); | 129 ChildProcess::current()->AddRefProcess(); |
| 131 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(plugin_path_); | 130 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(plugin_path_); |
| 132 if (chrome_plugin) { | 131 if (chrome_plugin) { |
| 133 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); | 132 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 197 } |
| 199 | 198 |
| 200 if (!result || net_error != net::OK) | 199 if (!result || net_error != net::OK) |
| 201 return false; | 200 return false; |
| 202 | 201 |
| 203 *proxy_list = proxy_result; | 202 *proxy_list = proxy_result; |
| 204 return true; | 203 return true; |
| 205 } | 204 } |
| 206 | 205 |
| 207 } // namespace webkit_glue | 206 } // namespace webkit_glue |
| OLD | NEW |