Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(779)

Side by Side Diff: chrome/browser/plugin_process_host.cc

Issue 42054: Stop using renderer specific host ids in ResourceDispatcher. This allows it ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/plugin_process_host.h" 7 #include "chrome/browser/plugin_process_host.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 #endif // defined(OS_WIN) 365 #endif // defined(OS_WIN)
366 366
367 PluginProcessHost::PluginProcessHost(MessageLoop* main_message_loop) 367 PluginProcessHost::PluginProcessHost(MessageLoop* main_message_loop)
368 : ChildProcessHost(PLUGIN_PROCESS, main_message_loop), 368 : ChildProcessHost(PLUGIN_PROCESS, main_message_loop),
369 ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)) { 369 ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)) {
370 } 370 }
371 371
372 PluginProcessHost::~PluginProcessHost() { 372 PluginProcessHost::~PluginProcessHost() {
373 // Cancel all requests for plugin process. 373 // Cancel all requests for plugin process.
374 PluginService::GetInstance()->resource_dispatcher_host()-> 374 PluginService::GetInstance()->resource_dispatcher_host()->
375 CancelRequestsForProcess(-1); 375 CancelRequestsForProcess(pid());
376 376
377 #if defined(OS_WIN) 377 #if defined(OS_WIN)
378 // We erase HWNDs from the plugin_parent_windows_set_ when we receive a 378 // We erase HWNDs from the plugin_parent_windows_set_ when we receive a
379 // notification that the window is being destroyed. If we don't receive this 379 // notification that the window is being destroyed. If we don't receive this
380 // notification and the PluginProcessHost instance is being destroyed, it 380 // notification and the PluginProcessHost instance is being destroyed, it
381 // means that the plugin process crashed. We paint a sad face in this case in 381 // means that the plugin process crashed. We paint a sad face in this case in
382 // the renderer process. To ensure that the sad face shows up, and we don't 382 // the renderer process. To ensure that the sad face shows up, and we don't
383 // leak HWNDs, we should destroy existing plugin parent windows. 383 // leak HWNDs, we should destroy existing plugin parent windows.
384 std::set<HWND>::iterator window_index; 384 std::set<HWND>::iterator window_index;
385 for (window_index = plugin_parent_windows_set_.begin(); 385 for (window_index = plugin_parent_windows_set_.begin();
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 int request_id, 611 int request_id,
612 const ViewHostMsg_Resource_Request& request) { 612 const ViewHostMsg_Resource_Request& request) {
613 URLRequestContext* context = CPBrowsingContextManager::Instance()-> 613 URLRequestContext* context = CPBrowsingContextManager::Instance()->
614 ToURLRequestContext(request.request_context); 614 ToURLRequestContext(request.request_context);
615 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. 615 // TODO(mpcomplete): remove fallback case when Gears support is prevalent.
616 if (!context) 616 if (!context)
617 context = Profile::GetDefaultRequestContext(); 617 context = Profile::GetDefaultRequestContext();
618 618
619 PluginService::GetInstance()->resource_dispatcher_host()-> 619 PluginService::GetInstance()->resource_dispatcher_host()->
620 BeginRequest(this, ChildProcessInfo::PLUGIN_PROCESS, handle(), 620 BeginRequest(this, ChildProcessInfo::PLUGIN_PROCESS, handle(),
621 -1, MSG_ROUTING_CONTROL, request_id, 621 pid(), MSG_ROUTING_CONTROL, request_id,
622 request, context, NULL); 622 request, context, NULL);
623 } 623 }
624 624
625 void PluginProcessHost::OnCancelRequest(int request_id) { 625 void PluginProcessHost::OnCancelRequest(int request_id) {
626 PluginService::GetInstance()->resource_dispatcher_host()-> 626 PluginService::GetInstance()->resource_dispatcher_host()->
627 CancelRequest(-1, request_id, true); 627 CancelRequest(pid(), request_id, true);
628 } 628 }
629 629
630 void PluginProcessHost::OnDataReceivedACK(int request_id) { 630 void PluginProcessHost::OnDataReceivedACK(int request_id) {
631 PluginService::GetInstance()->resource_dispatcher_host()-> 631 PluginService::GetInstance()->resource_dispatcher_host()->
632 OnDataReceivedACK(-1, request_id); 632 OnDataReceivedACK(pid(), request_id);
633 } 633 }
634 634
635 void PluginProcessHost::OnUploadProgressACK(int request_id) { 635 void PluginProcessHost::OnUploadProgressACK(int request_id) {
636 PluginService::GetInstance()->resource_dispatcher_host()-> 636 PluginService::GetInstance()->resource_dispatcher_host()->
637 OnUploadProgressACK(-1, request_id); 637 OnUploadProgressACK(pid(), request_id);
638 } 638 }
639 639
640 void PluginProcessHost::OnSyncLoad( 640 void PluginProcessHost::OnSyncLoad(
641 int request_id, 641 int request_id,
642 const ViewHostMsg_Resource_Request& request, 642 const ViewHostMsg_Resource_Request& request,
643 IPC::Message* sync_result) { 643 IPC::Message* sync_result) {
644 URLRequestContext* context = CPBrowsingContextManager::Instance()-> 644 URLRequestContext* context = CPBrowsingContextManager::Instance()->
645 ToURLRequestContext(request.request_context); 645 ToURLRequestContext(request.request_context);
646 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. 646 // TODO(mpcomplete): remove fallback case when Gears support is prevalent.
647 if (!context) 647 if (!context)
648 context = Profile::GetDefaultRequestContext(); 648 context = Profile::GetDefaultRequestContext();
649 649
650 PluginService::GetInstance()->resource_dispatcher_host()-> 650 PluginService::GetInstance()->resource_dispatcher_host()->
651 BeginRequest(this, ChildProcessInfo::PLUGIN_PROCESS, handle(), 651 BeginRequest(this, ChildProcessInfo::PLUGIN_PROCESS, handle(),
652 -1, MSG_ROUTING_CONTROL, request_id, 652 pid(), MSG_ROUTING_CONTROL, request_id,
653 request, context, sync_result); 653 request, context, sync_result);
654 } 654 }
655 655
656 void PluginProcessHost::OnGetCookies(uint32 request_context, 656 void PluginProcessHost::OnGetCookies(uint32 request_context,
657 const GURL& url, 657 const GURL& url,
658 std::string* cookies) { 658 std::string* cookies) {
659 URLRequestContext* context = CPBrowsingContextManager::Instance()-> 659 URLRequestContext* context = CPBrowsingContextManager::Instance()->
660 ToURLRequestContext(request_context); 660 ToURLRequestContext(request_context);
661 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. 661 // TODO(mpcomplete): remove fallback case when Gears support is prevalent.
662 if (!context) 662 if (!context)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 696
697 void PluginProcessHost::RequestPluginChannel( 697 void PluginProcessHost::RequestPluginChannel(
698 ResourceMessageFilter* renderer_message_filter, 698 ResourceMessageFilter* renderer_message_filter,
699 const std::string& mime_type, IPC::Message* reply_msg) { 699 const std::string& mime_type, IPC::Message* reply_msg) {
700 #if defined(OS_WIN) 700 #if defined(OS_WIN)
701 // We can't send any sync messages from the browser because it might lead to 701 // We can't send any sync messages from the browser because it might lead to
702 // a hang. However this async messages must be answered right away by the 702 // a hang. However this async messages must be answered right away by the
703 // plugin process (i.e. unblocks a Send() call like a sync message) otherwise 703 // plugin process (i.e. unblocks a Send() call like a sync message) otherwise
704 // a deadlock can occur if the plugin creation request from the renderer is 704 // a deadlock can occur if the plugin creation request from the renderer is
705 // a result of a sync message by the plugin process. 705 // a result of a sync message by the plugin process.
706 706 PluginProcessMsg_CreateChannel* msg = new PluginProcessMsg_CreateChannel();
707 // The plugin process expects to receive a handle to the renderer requesting
708 // the channel. The handle has to be valid in the plugin process.
709 HANDLE renderer_handle = NULL;
710 BOOL result = DuplicateHandle(GetCurrentProcess(),
711 renderer_message_filter->renderer_handle(),
712 handle(), &renderer_handle, 0, FALSE,
713 DUPLICATE_SAME_ACCESS);
714 DCHECK(result);
715
716 PluginProcessMsg_CreateChannel* msg =
717 new PluginProcessMsg_CreateChannel(
718 renderer_message_filter->render_process_host_id(), renderer_handle);
719 msg->set_unblock(true); 707 msg->set_unblock(true);
720 if (Send(msg)) { 708 if (Send(msg)) {
721 sent_requests_.push_back(ChannelRequest(renderer_message_filter, mime_type, 709 sent_requests_.push(ChannelRequest(
722 reply_msg)); 710 renderer_message_filter, mime_type, reply_msg));
723 } else { 711 } else {
724 ReplyToRenderer(renderer_message_filter, std::wstring(), FilePath(), 712 ReplyToRenderer(renderer_message_filter, std::wstring(), FilePath(),
725 reply_msg); 713 reply_msg);
726 } 714 }
727 #else 715 #else
728 // TODO(port): Figure out what the plugin process is expecting in this case. 716 // TODO(port): Figure out what the plugin process is expecting in this case.
729 NOTIMPLEMENTED(); 717 NOTIMPLEMENTED();
730 #endif 718 #endif
731 } 719 }
732 720
733 void PluginProcessHost::OnChannelCreated(int process_id, 721 void PluginProcessHost::OnChannelCreated(const std::wstring& channel_name) {
734 const std::wstring& channel_name) { 722 ReplyToRenderer(sent_requests_.front().renderer_message_filter_.get(),
735 for (size_t i = 0; i < sent_requests_.size(); ++i) { 723 channel_name,
736 if (sent_requests_[i].renderer_message_filter_->render_process_host_id() 724 info_.path,
737 == process_id) { 725 sent_requests_.front().reply_msg);
738 ReplyToRenderer(sent_requests_[i].renderer_message_filter_.get(), 726 sent_requests_.pop();
739 channel_name,
740 info_.path,
741 sent_requests_[i].reply_msg);
742
743 sent_requests_.erase(sent_requests_.begin() + i);
744 return;
745 }
746 }
747
748 NOTREACHED();
749 } 727 }
750 728
751 void PluginProcessHost::OnDownloadUrl(const std::string& url, 729 void PluginProcessHost::OnDownloadUrl(const std::string& url,
752 int source_pid, 730 int source_pid,
753 gfx::NativeWindow caller_window) { 731 gfx::NativeWindow caller_window) {
754 PluginDownloadUrlHelper* download_url_helper = 732 PluginDownloadUrlHelper* download_url_helper =
755 new PluginDownloadUrlHelper(url, source_pid, caller_window); 733 new PluginDownloadUrlHelper(url, source_pid, caller_window);
756 download_url_helper->InitiateDownload(); 734 download_url_helper->InitiateDownload();
757 } 735 }
758 736
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 774 }
797 775
798 void PluginProcessHost::Shutdown() { 776 void PluginProcessHost::Shutdown() {
799 #if defined(OS_WIN) 777 #if defined(OS_WIN)
800 Send(new PluginProcessMsg_BrowserShutdown); 778 Send(new PluginProcessMsg_BrowserShutdown);
801 #else 779 #else
802 // TODO(port): Port plugin_messages_internal.h. 780 // TODO(port): Port plugin_messages_internal.h.
803 NOTIMPLEMENTED(); 781 NOTIMPLEMENTED();
804 #endif 782 #endif
805 } 783 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_process_host.h ('k') | chrome/browser/renderer_host/async_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698