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

Side by Side Diff: content/browser/plugin_service_impl.cc

Issue 1170623003: Revert "content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/plugin_service_impl.h" 5 #include "content/browser/plugin_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/location.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/message_loop/message_loop_proxy.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/single_thread_task_runner.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "content/browser/ppapi_plugin_process_host.h" 18 #include "content/browser/ppapi_plugin_process_host.h"
19 #include "content/browser/renderer_host/render_process_host_impl.h" 19 #include "content/browser/renderer_host/render_process_host_impl.h"
20 #include "content/browser/renderer_host/render_view_host_impl.h" 20 #include "content/browser/renderer_host/render_view_host_impl.h"
21 #include "content/common/content_switches_internal.h" 21 #include "content/common/content_switches_internal.h"
22 #include "content/common/pepper_plugin_list.h" 22 #include "content/common/pepper_plugin_list.h"
23 #include "content/common/plugin_list.h" 23 #include "content/common/plugin_list.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 VLOG(1) << "Watched path changed: " << path.value(); 118 VLOG(1) << "Watched path changed: " << path.value();
119 // Make the plugin list update itself 119 // Make the plugin list update itself
120 PluginList::Singleton()->RefreshPlugins(); 120 PluginList::Singleton()->RefreshPlugins();
121 BrowserThread::PostTask( 121 BrowserThread::PostTask(
122 BrowserThread::UI, FROM_HERE, 122 BrowserThread::UI, FROM_HERE,
123 base::Bind(&PluginService::PurgePluginListCache, 123 base::Bind(&PluginService::PurgePluginListCache,
124 static_cast<BrowserContext*>(NULL), false)); 124 static_cast<BrowserContext*>(NULL), false));
125 } 125 }
126 #endif 126 #endif
127 127
128 void ForwardCallback(base::SingleThreadTaskRunner* target_task_runner, 128 void ForwardCallback(base::MessageLoopProxy* target_loop,
129 const PluginService::GetPluginsCallback& callback, 129 const PluginService::GetPluginsCallback& callback,
130 const std::vector<WebPluginInfo>& plugins) { 130 const std::vector<WebPluginInfo>& plugins) {
131 target_task_runner->PostTask(FROM_HERE, base::Bind(callback, plugins)); 131 target_loop->PostTask(FROM_HERE, base::Bind(callback, plugins));
132 } 132 }
133 133
134 } // namespace 134 } // namespace
135 135
136 // static 136 // static
137 PluginService* PluginService::GetInstance() { 137 PluginService* PluginService::GetInstance() {
138 return PluginServiceImpl::GetInstance(); 138 return PluginServiceImpl::GetInstance();
139 } 139 }
140 140
141 void PluginService::PurgePluginListCache(BrowserContext* browser_context, 141 void PluginService::PurgePluginListCache(BrowserContext* browser_context,
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 // terrible, so look for that and strip it off if present. 582 // terrible, so look for that and strip it off if present.
583 const std::string kPluginExtension = ".plugin"; 583 const std::string kPluginExtension = ".plugin";
584 if (EndsWith(plugin_name, base::ASCIIToUTF16(kPluginExtension), true)) 584 if (EndsWith(plugin_name, base::ASCIIToUTF16(kPluginExtension), true))
585 plugin_name.erase(plugin_name.length() - kPluginExtension.length()); 585 plugin_name.erase(plugin_name.length() - kPluginExtension.length());
586 #endif // OS_MACOSX 586 #endif // OS_MACOSX
587 } 587 }
588 return plugin_name; 588 return plugin_name;
589 } 589 }
590 590
591 void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { 591 void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) {
592 scoped_refptr<base::SingleThreadTaskRunner> target_task_runner( 592 scoped_refptr<base::MessageLoopProxy> target_loop(
593 base::ThreadTaskRunnerHandle::Get()); 593 base::MessageLoop::current()->message_loop_proxy());
594 594
595 if (LoadPluginListInProcess()) { 595 if (LoadPluginListInProcess()) {
596 BrowserThread::GetBlockingPool() 596 BrowserThread::GetBlockingPool()->
597 ->PostSequencedWorkerTaskWithShutdownBehavior( 597 PostSequencedWorkerTaskWithShutdownBehavior(
598 plugin_list_token_, FROM_HERE, 598 plugin_list_token_,
599 FROM_HERE,
599 base::Bind(&PluginServiceImpl::GetPluginsInternal, 600 base::Bind(&PluginServiceImpl::GetPluginsInternal,
600 base::Unretained(this), target_task_runner, callback), 601 base::Unretained(this),
601 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 602 target_loop, callback),
603 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
602 return; 604 return;
603 } 605 }
604 #if defined(OS_POSIX) 606 #if defined(OS_POSIX)
605 BrowserThread::PostTask( 607 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
606 BrowserThread::IO, FROM_HERE,
607 base::Bind(&PluginServiceImpl::GetPluginsOnIOThread, 608 base::Bind(&PluginServiceImpl::GetPluginsOnIOThread,
608 base::Unretained(this), target_task_runner, callback)); 609 base::Unretained(this), target_loop, callback));
609 #else 610 #else
610 NOTREACHED(); 611 NOTREACHED();
611 #endif 612 #endif
612 } 613 }
613 614
614 void PluginServiceImpl::GetPluginsInternal( 615 void PluginServiceImpl::GetPluginsInternal(
615 base::SingleThreadTaskRunner* target_task_runner, 616 base::MessageLoopProxy* target_loop,
616 const PluginService::GetPluginsCallback& callback) { 617 const PluginService::GetPluginsCallback& callback) {
617 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( 618 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread(
618 plugin_list_token_)); 619 plugin_list_token_));
619 620
620 std::vector<WebPluginInfo> plugins; 621 std::vector<WebPluginInfo> plugins;
621 PluginList::Singleton()->GetPlugins(&plugins, NPAPIPluginsSupported()); 622 PluginList::Singleton()->GetPlugins(&plugins, NPAPIPluginsSupported());
622 623
623 target_task_runner->PostTask(FROM_HERE, base::Bind(callback, plugins)); 624 target_loop->PostTask(FROM_HERE,
625 base::Bind(callback, plugins));
624 } 626 }
625 627
626 #if defined(OS_POSIX) 628 #if defined(OS_POSIX)
627 void PluginServiceImpl::GetPluginsOnIOThread( 629 void PluginServiceImpl::GetPluginsOnIOThread(
628 base::SingleThreadTaskRunner* target_task_runner, 630 base::MessageLoopProxy* target_loop,
629 const GetPluginsCallback& callback) { 631 const GetPluginsCallback& callback) {
630 DCHECK_CURRENTLY_ON(BrowserThread::IO); 632 DCHECK_CURRENTLY_ON(BrowserThread::IO);
631 633
632 // If we switch back to loading plugins in process, then we need to make 634 // If we switch back to loading plugins in process, then we need to make
633 // sure g_thread_init() gets called since plugins may call glib at load. 635 // sure g_thread_init() gets called since plugins may call glib at load.
634 636
635 if (!plugin_loader_.get()) 637 if (!plugin_loader_.get())
636 plugin_loader_ = new PluginLoaderPosix; 638 plugin_loader_ = new PluginLoaderPosix;
637 639
638 plugin_loader_->GetPlugins(base::Bind( 640 plugin_loader_->GetPlugins(
639 &ForwardCallback, make_scoped_refptr(target_task_runner), callback)); 641 base::Bind(&ForwardCallback, make_scoped_refptr(target_loop), callback));
640 } 642 }
641 #endif 643 #endif
642 644
643 #if defined(OS_WIN) 645 #if defined(OS_WIN)
644 void PluginServiceImpl::OnKeyChanged(base::win::RegKey* key) { 646 void PluginServiceImpl::OnKeyChanged(base::win::RegKey* key) {
645 key->StartWatching(base::Bind(&PluginServiceImpl::OnKeyChanged, 647 key->StartWatching(base::Bind(&PluginServiceImpl::OnKeyChanged,
646 base::Unretained(this), 648 base::Unretained(this),
647 base::Unretained(key))); 649 base::Unretained(key)));
648 650
649 PluginList::Singleton()->RefreshPlugins(); 651 PluginList::Singleton()->RefreshPlugins();
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 #endif 872 #endif
871 873
872 bool PluginServiceImpl::PpapiDevChannelSupported( 874 bool PluginServiceImpl::PpapiDevChannelSupported(
873 BrowserContext* browser_context, 875 BrowserContext* browser_context,
874 const GURL& document_url) { 876 const GURL& document_url) {
875 return content::GetContentClient()->browser()-> 877 return content::GetContentClient()->browser()->
876 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); 878 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url);
877 } 879 }
878 880
879 } // namespace content 881 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/plugin_service_impl.h ('k') | content/browser/plugin_service_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698