| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/webplugin_delegate_stub.h" | 5 #include "chrome/plugin/webplugin_delegate_stub.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "chrome/common/child_process_logging.h" | 10 #include "chrome/common/child_process_logging.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 instance_id_(instance_id), | 52 instance_id_(instance_id), |
| 53 channel_(channel), | 53 channel_(channel), |
| 54 delegate_(NULL), | 54 delegate_(NULL), |
| 55 webplugin_(NULL), | 55 webplugin_(NULL), |
| 56 in_destructor_(false) { | 56 in_destructor_(false) { |
| 57 DCHECK(channel); | 57 DCHECK(channel); |
| 58 } | 58 } |
| 59 | 59 |
| 60 WebPluginDelegateStub::~WebPluginDelegateStub() { | 60 WebPluginDelegateStub::~WebPluginDelegateStub() { |
| 61 in_destructor_ = true; | 61 in_destructor_ = true; |
| 62 child_process_logging::ScopedActiveURLSetter url_setter(page_url_); | 62 child_process_logging::SetActiveURL(page_url_); |
| 63 | 63 |
| 64 if (channel_->in_send()) { | 64 if (channel_->in_send()) { |
| 65 // The delegate or an npobject is in the callstack, so don't delete it | 65 // The delegate or an npobject is in the callstack, so don't delete it |
| 66 // right away. | 66 // right away. |
| 67 MessageLoop::current()->PostNonNestableTask(FROM_HERE, | 67 MessageLoop::current()->PostNonNestableTask(FROM_HERE, |
| 68 new FinishDestructionTask(delegate_, webplugin_)); | 68 new FinishDestructionTask(delegate_, webplugin_)); |
| 69 } else { | 69 } else { |
| 70 // Safe to delete right away. | 70 // Safe to delete right away. |
| 71 if (delegate_) | 71 if (delegate_) |
| 72 delegate_->PluginDestroyed(); | 72 delegate_->PluginDestroyed(); |
| 73 | 73 |
| 74 delete webplugin_; | 74 delete webplugin_; |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { | 78 void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { |
| 79 child_process_logging::ScopedActiveURLSetter url_setter(page_url_); | 79 child_process_logging::SetActiveURL(page_url_); |
| 80 | 80 |
| 81 // A plugin can execute a script to delete itself in any of its NPP methods. | 81 // A plugin can execute a script to delete itself in any of its NPP methods. |
| 82 // Hold an extra reference to ourself so that if this does occur and we're | 82 // Hold an extra reference to ourself so that if this does occur and we're |
| 83 // handling a sync message, we don't crash when attempting to send a reply. | 83 // handling a sync message, we don't crash when attempting to send a reply. |
| 84 // The exception to this is when we're already in the destructor. | 84 // The exception to this is when we're already in the destructor. |
| 85 if (!in_destructor_) | 85 if (!in_destructor_) |
| 86 AddRef(); | 86 AddRef(); |
| 87 | 87 |
| 88 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg) | 88 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg) |
| 89 IPC_MESSAGE_HANDLER(PluginMsg_Init, OnInit) | 89 IPC_MESSAGE_HANDLER(PluginMsg_Init, OnInit) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 Release(); | 121 Release(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 bool WebPluginDelegateStub::Send(IPC::Message* msg) { | 124 bool WebPluginDelegateStub::Send(IPC::Message* msg) { |
| 125 return channel_->Send(msg); | 125 return channel_->Send(msg); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, | 128 void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, |
| 129 bool* result) { | 129 bool* result) { |
| 130 page_url_ = params.page_url; | 130 page_url_ = params.page_url; |
| 131 child_process_logging::ScopedActiveURLSetter url_setter(page_url_); | 131 child_process_logging::SetActiveURL(page_url_); |
| 132 | 132 |
| 133 *result = false; | 133 *result = false; |
| 134 if (params.arg_names.size() != params.arg_values.size()) { | 134 if (params.arg_names.size() != params.arg_values.size()) { |
| 135 NOTREACHED(); | 135 NOTREACHED(); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 | 138 |
| 139 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 139 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 140 FilePath path = FilePath::FromWStringHack( | 140 FilePath path = FilePath::FromWStringHack( |
| 141 command_line.GetSwitchValue(switches::kPluginPath)); | 141 command_line.GetSwitchValue(switches::kPluginPath)); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 366 |
| 367 void WebPluginDelegateStub::OnHandleURLRequestReply( | 367 void WebPluginDelegateStub::OnHandleURLRequestReply( |
| 368 const PluginMsg_URLRequestReply_Params& params) { | 368 const PluginMsg_URLRequestReply_Params& params) { |
| 369 WebPluginResourceClient* resource_client = | 369 WebPluginResourceClient* resource_client = |
| 370 delegate_->CreateResourceClient(params.resource_id, params.url, | 370 delegate_->CreateResourceClient(params.resource_id, params.url, |
| 371 params.notify_needed, | 371 params.notify_needed, |
| 372 params.notify_data, | 372 params.notify_data, |
| 373 params.stream); | 373 params.stream); |
| 374 webplugin_->OnResourceCreated(params.resource_id, resource_client); | 374 webplugin_->OnResourceCreated(params.resource_id, resource_client); |
| 375 } | 375 } |
| OLD | NEW |