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

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

Issue 42158: Get rid of the gears in renderer process code. This allows me to do some cle... (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
« no previous file with comments | « no previous file | chrome/browser/renderer_host/browser_render_process_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/chrome_plugin_host.h" 5 #include "chrome/browser/chrome_plugin_host.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 PluginProcessHost *host = service->FindPluginProcess(plugin->filename()); 675 PluginProcessHost *host = service->FindPluginProcess(plugin->filename());
676 return host ? true : false; 676 return host ? true : false;
677 } 677 }
678 678
679 CPProcessType STDCALL CPB_GetProcessType(CPID id) { 679 CPProcessType STDCALL CPB_GetProcessType(CPID id) {
680 CHECK(ChromePluginLib::IsPluginThread()); 680 CHECK(ChromePluginLib::IsPluginThread());
681 return CP_PROCESS_BROWSER; 681 return CP_PROCESS_BROWSER;
682 } 682 }
683 683
684 CPError STDCALL CPB_SendMessage(CPID id, const void *data, uint32 data_len) { 684 CPError STDCALL CPB_SendMessage(CPID id, const void *data, uint32 data_len) {
685 if (CommandLine::ForCurrentProcess()->HasSwitch( 685 CHECK(ChromePluginLib::IsPluginThread());
686 switches::kGearsInRenderer)) { 686 ChromePluginLib* plugin = ChromePluginLib::FromCPID(id);
687 ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); 687 CHECK(plugin);
688 CHECK(plugin);
689 688
690 const unsigned char* data_ptr = static_cast<const unsigned char*>(data); 689 PluginService* service = PluginService::GetInstance();
691 std::vector<uint8> v(data_ptr, data_ptr + data_len); 690 if (!service)
692 for (RenderProcessHost::iterator it = RenderProcessHost::begin();
693 it != RenderProcessHost::end(); ++it) {
694 it->second->Send(new ViewMsg_PluginMessage(plugin->filename(), v));
695 }
696
697 return CPERR_SUCCESS;
698 } else {
699 CHECK(ChromePluginLib::IsPluginThread());
700 ChromePluginLib* plugin = ChromePluginLib::FromCPID(id);
701 CHECK(plugin);
702
703 PluginService* service = PluginService::GetInstance();
704 if (!service)
705 return CPERR_FAILURE; 691 return CPERR_FAILURE;
706 PluginProcessHost *host = 692 PluginProcessHost *host =
707 service->FindOrStartPluginProcess(plugin->filename(), std::string()); 693 service->FindOrStartPluginProcess(plugin->filename(), std::string());
Matt Perry 2009/03/13 00:38:15 indent this too please
708 if (!host) 694 if (!host)
709 return CPERR_FAILURE; 695 return CPERR_FAILURE;
710 696
711 const unsigned char* data_ptr = static_cast<const unsigned char*>(data); 697 const unsigned char* data_ptr = static_cast<const unsigned char*>(data);
712 std::vector<uint8> v(data_ptr, data_ptr + data_len); 698 std::vector<uint8> v(data_ptr, data_ptr + data_len);
713 #if defined(OS_WIN) 699 #if defined(OS_WIN)
714 if (!host->Send(new PluginProcessMsg_PluginMessage(v))) 700 if (!host->Send(new PluginProcessMsg_PluginMessage(v)))
715 return CPERR_FAILURE; 701 return CPERR_FAILURE;
716 #else 702 #else
717 // TODO(port): Implement PluginProcessMsg. 703 // TODO(port): Implement PluginProcessMsg.
718 NOTIMPLEMENTED(); 704 NOTIMPLEMENTED();
719 #endif 705 #endif
720 706
721 return CPERR_SUCCESS; 707 return CPERR_SUCCESS;
722 }
723 } 708 }
724 709
725 CPError STDCALL CPB_SendSyncMessage(CPID id, const void *data, uint32 data_len, 710 CPError STDCALL CPB_SendSyncMessage(CPID id, const void *data, uint32 data_len,
726 void **retval, uint32 *retval_len) { 711 void **retval, uint32 *retval_len) {
727 NOTREACHED() << "Sync messages should not be sent from the browser process."; 712 NOTREACHED() << "Sync messages should not be sent from the browser process.";
728 713
729 return CPERR_FAILURE; 714 return CPERR_FAILURE;
730 } 715 }
731 716
732 CPError STDCALL CPB_PluginThreadAsyncCall(CPID id, 717 CPError STDCALL CPB_PluginThreadAsyncCall(CPID id,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 void CPHandleCommand(int command, CPCommandInterface* data, 796 void CPHandleCommand(int command, CPCommandInterface* data,
812 CPBrowsingContext context) { 797 CPBrowsingContext context) {
813 // Sadly if we try and pass context through, we seem to break cl's little 798 // Sadly if we try and pass context through, we seem to break cl's little
814 // brain trying to compile the Tuple3 ctor. This cast works. 799 // brain trying to compile the Tuple3 ctor. This cast works.
815 int32 context_as_int32 = static_cast<int32>(context); 800 int32 context_as_int32 = static_cast<int32>(context);
816 // Plugins can only be accessed on the IO thread. 801 // Plugins can only be accessed on the IO thread.
817 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 802 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
818 NewRunnableFunction(PluginCommandHandler::HandleCommand, 803 NewRunnableFunction(PluginCommandHandler::HandleCommand,
819 command, data, context_as_int32)); 804 command, data, context_as_int32));
820 } 805 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/renderer_host/browser_render_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698