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/browser/renderer_host/resource_message_filter.h" | 5 #include "chrome/browser/renderer_host/resource_message_filter.h" |
6 | 6 |
7 #include "app/clipboard/clipboard.h" | 7 #include "app/clipboard/clipboard.h" |
8 #include "app/gfx/native_widget_types.h" | 8 #include "app/gfx/native_widget_types.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 543 |
544 void ResourceMessageFilter::OnGetPlugins(bool refresh, | 544 void ResourceMessageFilter::OnGetPlugins(bool refresh, |
545 IPC::Message* reply_msg) { | 545 IPC::Message* reply_msg) { |
546 // Schedule plugin loading on the file thread. | 546 // Schedule plugin loading on the file thread. |
547 // Note: it's possible that the only reference to this object is the task. If | 547 // Note: it's possible that the only reference to this object is the task. If |
548 // If the task executes on the file thread, and before it returns, the task it | 548 // If the task executes on the file thread, and before it returns, the task it |
549 // posts to the IO thread runs, then this object will get destructed on the | 549 // posts to the IO thread runs, then this object will get destructed on the |
550 // file thread. We need this object to be destructed on the IO thread, so do | 550 // file thread. We need this object to be destructed on the IO thread, so do |
551 // the refcounting manually. | 551 // the refcounting manually. |
552 AddRef(); | 552 AddRef(); |
553 ChromeThread::GetMessageLoop(ChromeThread::FILE)->PostTask(FROM_HERE, | 553 ChromeThread::PostTask( |
| 554 ChromeThread::FILE, FROM_HERE, |
554 NewRunnableFunction(&ResourceMessageFilter::OnGetPluginsOnFileThread, | 555 NewRunnableFunction(&ResourceMessageFilter::OnGetPluginsOnFileThread, |
555 this, refresh, reply_msg)); | 556 this, refresh, reply_msg)); |
556 } | 557 } |
557 | 558 |
558 void ResourceMessageFilter::OnGetPluginsOnFileThread( | 559 void ResourceMessageFilter::OnGetPluginsOnFileThread( |
559 ResourceMessageFilter* filter, | 560 ResourceMessageFilter* filter, |
560 bool refresh, | 561 bool refresh, |
561 IPC::Message* reply_msg) { | 562 IPC::Message* reply_msg) { |
562 std::vector<WebPluginInfo> plugins; | 563 std::vector<WebPluginInfo> plugins; |
563 NPAPI::PluginList::Singleton()->GetPlugins(refresh, &plugins); | 564 NPAPI::PluginList::Singleton()->GetPlugins(refresh, &plugins); |
564 | |
565 ViewHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins); | 565 ViewHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins); |
566 // Note, we want to get to the IO thread now, but the file thread outlives it | 566 ChromeThread::PostTask( |
567 // so we can't post a task to it directly as it might be in the middle of | 567 ChromeThread::IO, FROM_HERE, |
568 // destruction. So hop through the main thread, where the destruction of the | |
569 // IO thread happens and hence no race conditions exist. | |
570 filter->ui_loop()->PostTask(FROM_HERE, | |
571 NewRunnableFunction(&ResourceMessageFilter::OnNotifyPluginsLoaded, | |
572 filter, reply_msg)); | |
573 } | |
574 | |
575 void ResourceMessageFilter::OnNotifyPluginsLoaded(ResourceMessageFilter* filter, | |
576 IPC::Message* reply_msg) { | |
577 ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask(FROM_HERE, | |
578 NewRunnableMethod(filter, &ResourceMessageFilter::OnPluginsLoaded, | 568 NewRunnableMethod(filter, &ResourceMessageFilter::OnPluginsLoaded, |
579 reply_msg)); | 569 reply_msg)); |
580 } | 570 } |
581 | 571 |
582 void ResourceMessageFilter::OnPluginsLoaded(IPC::Message* reply_msg) { | 572 void ResourceMessageFilter::OnPluginsLoaded(IPC::Message* reply_msg) { |
583 Send(reply_msg); | 573 Send(reply_msg); |
584 Release(); | 574 Release(); |
585 } | 575 } |
586 | 576 |
587 void ResourceMessageFilter::OnGetPluginPath(const GURL& url, | 577 void ResourceMessageFilter::OnGetPluginPath(const GURL& url, |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 *signed_public_key = keygen_handler->GenKeyAndSignChallenge(); | 1112 *signed_public_key = keygen_handler->GenKeyAndSignChallenge(); |
1123 } | 1113 } |
1124 | 1114 |
1125 #if defined(USE_TCMALLOC) | 1115 #if defined(USE_TCMALLOC) |
1126 void ResourceMessageFilter::OnRendererTcmalloc(base::ProcessId pid, | 1116 void ResourceMessageFilter::OnRendererTcmalloc(base::ProcessId pid, |
1127 const std::string& output) { | 1117 const std::string& output) { |
1128 ui_loop()->PostTask(FROM_HERE, | 1118 ui_loop()->PostTask(FROM_HERE, |
1129 NewRunnableFunction(AboutTcmallocRendererCallback, pid, output)); | 1119 NewRunnableFunction(AboutTcmallocRendererCallback, pid, output)); |
1130 } | 1120 } |
1131 #endif | 1121 #endif |
OLD | NEW |