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

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

Issue 14142: Start using the proxy resolve IPC for plugins.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | « chrome/browser/plugin_process_host.h ('k') | chrome/browser/resource_message_filter.h » ('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/plugin_process_host.h" 5 #include "chrome/browser/plugin_process_host.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/common/debug_flags.h" 30 #include "chrome/common/debug_flags.h"
31 #include "chrome/common/ipc_logging.h" 31 #include "chrome/common/ipc_logging.h"
32 #include "chrome/common/logging_chrome.h" 32 #include "chrome/common/logging_chrome.h"
33 #include "chrome/common/notification_service.h" 33 #include "chrome/common/notification_service.h"
34 #include "chrome/common/plugin_messages.h" 34 #include "chrome/common/plugin_messages.h"
35 #include "chrome/common/process_watcher.h" 35 #include "chrome/common/process_watcher.h"
36 #include "chrome/common/render_messages.h" 36 #include "chrome/common/render_messages.h"
37 #include "chrome/common/win_util.h" 37 #include "chrome/common/win_util.h"
38 #include "net/base/cookie_monster.h" 38 #include "net/base/cookie_monster.h"
39 #include "net/base/io_buffer.h" 39 #include "net/base/io_buffer.h"
40 #include "net/proxy/proxy_service.h"
41 #include "net/url_request/url_request.h" 40 #include "net/url_request/url_request.h"
42 #include "sandbox/src/sandbox.h" 41 #include "sandbox/src/sandbox.h"
43 #include "webkit/glue/plugins/plugin_constants_win.h" 42 #include "webkit/glue/plugins/plugin_constants_win.h"
44 43
45 static const char kDefaultPluginFinderURL[] = 44 static const char kDefaultPluginFinderURL[] =
46 "http://dl.google.com/chrome/plugins/plugins2.xml"; 45 "http://dl.google.com/chrome/plugins/plugins2.xml";
47 46
48 // The NotificationTask is used to notify about plugin process connection/ 47 // The NotificationTask is used to notify about plugin process connection/
49 // disconnection. It is needed because the notifications in the 48 // disconnection. It is needed because the notifications in the
50 // NotificationService must happen in the main thread. 49 // NotificationService must happen in the main thread.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 download_file_data.dwData = success; 292 download_file_data.dwData = success;
294 293
295 if (::IsWindow(download_file_caller_window_)) { 294 if (::IsWindow(download_file_caller_window_)) {
296 ::SendMessage(download_file_caller_window_, WM_COPYDATA, NULL, 295 ::SendMessage(download_file_caller_window_, WM_COPYDATA, NULL,
297 reinterpret_cast<LPARAM>(&download_file_data)); 296 reinterpret_cast<LPARAM>(&download_file_data));
298 } 297 }
299 // Don't access any members after this. 298 // Don't access any members after this.
300 delete this; 299 delete this;
301 } 300 }
302 301
303 // The following class is a helper to handle ProxyResolve IPC requests.
304 // It is responsible for initiating an asynchronous proxy resolve request,
305 // and will send out the IPC response on completion then delete itself.
306 // Should the PluginProcessHost be destroyed while a proxy resolve request
307 // is in progress, the request will not be canceled. However once it completes
308 // it will see that it has been revoked and delete itself.
309 // TODO(eroman): This could leak if ProxyService is deleted while request is
310 // outstanding.
311 class PluginResolveProxyHelper : RevocableStore::Revocable {
312 public:
313 // Create a helper that writes its response through |plugin_host|.
314 PluginResolveProxyHelper(PluginProcessHost* plugin_host)
315 : RevocableStore::Revocable(&plugin_host->revocable_store_),
316 plugin_host_(plugin_host),
317 reply_msg_(NULL),
318 ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
319 this, &PluginResolveProxyHelper::OnProxyResolveCompleted)) {
320 }
321
322 // Completion callback for ProxyService.
323 void OnProxyResolveCompleted(int result) {
324 if (!revoked()) {
325 PluginProcessHostMsg_ResolveProxy::WriteReplyParams(
326 reply_msg_, result, proxy_info_.GetAnnotatedProxyList());
327 plugin_host_->Send(reply_msg_);
328 }
329
330 delete this;
331 };
332
333 // Resolve the proxy for |url| using |proxy_service|. Write the response
334 // to |reply_msg|.
335 void Start(net::ProxyService* proxy_service,
336 const GURL& url,
337 IPC::Message* reply_msg) {
338 reply_msg_ = reply_msg;
339 int rv = proxy_service->ResolveProxy(
340 url, &proxy_info_, &callback_, NULL);
341 if (rv != net::ERR_IO_PENDING)
342 OnProxyResolveCompleted(rv);
343 }
344
345 private:
346 // |plugin_host_| is only valid if !this->revoked().
347 PluginProcessHost* plugin_host_;
348 IPC::Message* reply_msg_;
349 net::CompletionCallbackImpl<PluginResolveProxyHelper> callback_;
350 net::ProxyInfo proxy_info_;
351 };
352
353
354 // Sends the reply to the create window message on the IO thread. 302 // Sends the reply to the create window message on the IO thread.
355 class SendReplyTask : public Task { 303 class SendReplyTask : public Task {
356 public: 304 public:
357 SendReplyTask(FilePath plugin_path, IPC::Message* reply_msg) 305 SendReplyTask(FilePath plugin_path, IPC::Message* reply_msg)
358 : plugin_path_(plugin_path), reply_msg_(reply_msg) { } 306 : plugin_path_(plugin_path), reply_msg_(reply_msg) { }
359 307
360 virtual void Run() { 308 virtual void Run() {
361 PluginProcessHost* plugin = 309 PluginProcessHost* plugin =
362 PluginService::GetInstance()->FindPluginProcess(plugin_path_); 310 PluginService::GetInstance()->FindPluginProcess(plugin_path_);
363 if (!plugin) 311 if (!plugin)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 376
429 private: 377 private:
430 HWND window_; 378 HWND window_;
431 }; 379 };
432 380
433 381
434 PluginProcessHost::PluginProcessHost(PluginService* plugin_service) 382 PluginProcessHost::PluginProcessHost(PluginService* plugin_service)
435 : process_(NULL), 383 : process_(NULL),
436 opening_channel_(false), 384 opening_channel_(false),
437 resource_dispatcher_host_(plugin_service->resource_dispatcher_host()), 385 resource_dispatcher_host_(plugin_service->resource_dispatcher_host()),
386 ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)),
438 plugin_service_(plugin_service) { 387 plugin_service_(plugin_service) {
439 DCHECK(resource_dispatcher_host_); 388 DCHECK(resource_dispatcher_host_);
440 } 389 }
441 390
442 PluginProcessHost::~PluginProcessHost() { 391 PluginProcessHost::~PluginProcessHost() {
443 if (process_.handle()) { 392 if (process_.handle()) {
444 watcher_.StopWatching(); 393 watcher_.StopWatching();
445 ProcessWatcher::EnsureProcessTerminated(process_.handle()); 394 ProcessWatcher::EnsureProcessTerminated(process_.handle());
446 } 395 }
447 } 396 }
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 if (!context) 756 if (!context)
808 context = Profile::GetDefaultRequestContext(); 757 context = Profile::GetDefaultRequestContext();
809 758
810 // Note: We don't have a policy_url check because plugins bypass the 759 // Note: We don't have a policy_url check because plugins bypass the
811 // third-party cookie blocking. 760 // third-party cookie blocking.
812 *cookies = context->cookie_store()->GetCookies(url); 761 *cookies = context->cookie_store()->GetCookies(url);
813 } 762 }
814 763
815 void PluginProcessHost::OnResolveProxy(const GURL& url, 764 void PluginProcessHost::OnResolveProxy(const GURL& url,
816 IPC::Message* reply_msg) { 765 IPC::Message* reply_msg) {
817 // Use the default profile's proxy service. 766 resolve_proxy_msg_helper_.Start(url, reply_msg);
818 net::ProxyService* proxy_service = 767 }
819 Profile::GetDefaultRequestContext()->proxy_service();
820 768
821 // Kick off a proxy resolve request; writes the response to |reply_msg| 769 void PluginProcessHost::OnResolveProxyCompleted(IPC::Message* reply_msg,
822 // on completion. The helper's storage will be deleted on completion. 770 int result,
823 (new PluginResolveProxyHelper(this))->Start(proxy_service, url, reply_msg); 771 const std::string& proxy_list) {
772 PluginProcessHostMsg_ResolveProxy::WriteReplyParams(
773 reply_msg, result, proxy_list);
774 Send(reply_msg);
824 } 775 }
825 776
826 void PluginProcessHost::ReplyToRenderer( 777 void PluginProcessHost::ReplyToRenderer(
827 ResourceMessageFilter* renderer_message_filter, 778 ResourceMessageFilter* renderer_message_filter,
828 const std::wstring& channel, const FilePath& plugin_path, 779 const std::wstring& channel, const FilePath& plugin_path,
829 IPC::Message* reply_msg) { 780 IPC::Message* reply_msg) {
830 ViewHostMsg_OpenChannelToPlugin::WriteReplyParams(reply_msg, channel, 781 ViewHostMsg_OpenChannelToPlugin::WriteReplyParams(reply_msg, channel,
831 plugin_path); 782 plugin_path);
832 renderer_message_filter->Send(reply_msg); 783 renderer_message_filter->Send(reply_msg);
833 } 784 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 void PluginProcessHost::OnDestroyWindow(HWND window) { 886 void PluginProcessHost::OnDestroyWindow(HWND window) {
936 plugin_service_->main_message_loop()->PostTask(FROM_HERE, 887 plugin_service_->main_message_loop()->PostTask(FROM_HERE,
937 new DestroyWindowTask(window)); 888 new DestroyWindowTask(window));
938 } 889 }
939 890
940 void PluginProcessHost::Shutdown() { 891 void PluginProcessHost::Shutdown() {
941 892
942 Send(new PluginProcessMsg_BrowserShutdown); 893 Send(new PluginProcessMsg_BrowserShutdown);
943 } 894 }
944 895
OLDNEW
« no previous file with comments | « chrome/browser/plugin_process_host.h ('k') | chrome/browser/resource_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698