Skip to content

Commit

Permalink
Move some files from chrome/browser/nacl_host to components/nacl
Browse files Browse the repository at this point in the history
These files have no dependencies on chrome/ so they can be safely moved
to the components/ directory. This is only the first batch, more will come
in a future CL.

This is part of an effort to componentize NaCl code.

BUG=244791

Review URL: https://codereview.chromium.org/34963003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232295 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
alexis.menard@intel.com committed Nov 1, 2013
1 parent 96439d0 commit ef42ee8
Show file tree
Hide file tree
Showing 21 changed files with 109 additions and 79 deletions.
1 change: 1 addition & 0 deletions chrome/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include_rules = [
"+components/autofill/core/common",
"+components/breakpad",
"+components/browser_context_keyed_service",
"+components/nacl/browser",
"+components/nacl/common",
"+components/navigation_interception",
"+components/navigation_metrics",
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/browsing_data/browsing_data_remover.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/nacl_host/nacl_browser.h"
#include "chrome/browser/nacl_host/pnacl_host.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/net/predictor.h"
Expand All @@ -49,6 +48,7 @@
#include "chrome/common/url_constants.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/nacl/browser/nacl_browser.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/dom_storage_context.h"
#include "content/public/browser/download_manager.h"
Expand Down Expand Up @@ -910,7 +910,7 @@ void BrowsingDataRemover::ClearedNaClCacheOnIOThread() {
void BrowsingDataRemover::ClearNaClCacheOnIOThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));

NaClBrowser::GetInstance()->ClearValidationCache(
nacl::NaClBrowser::GetInstance()->ClearValidationCache(
base::Bind(&BrowsingDataRemover::ClearedNaClCacheOnIOThread,
base::Unretained(this)));
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
#include "chrome/browser/metrics/tracking_synchronizer.h"
#include "chrome/browser/metrics/variations/variations_http_header_provider.h"
#include "chrome/browser/metrics/variations/variations_service.h"
#include "chrome/browser/nacl_host/nacl_browser.h"
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
#include "chrome/browser/nacl_host/nacl_process_host.h"
#include "chrome/browser/net/chrome_net_log.h"
Expand Down Expand Up @@ -116,6 +115,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/profiling.h"
#include "chrome/installer/util/google_update_settings.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/startup_metric_utils/startup_metric_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h"
Expand Down Expand Up @@ -1289,7 +1289,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#if !defined(DISABLE_NACL)
NaClBrowserDelegateImpl* delegate = new NaClBrowserDelegateImpl(
extensions::ExtensionSystem::Get(profile_)->info_map());
NaClBrowser::SetDelegate(delegate);
nacl::NaClBrowser::SetDelegate(delegate);
#endif

// TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include "chrome/browser/guestview/webview/webview_guest.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
#include "chrome/browser/nacl_host/nacl_browser.h"
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
#include "chrome/browser/nacl_host/nacl_host_message_filter.h"
#include "chrome/browser/nacl_host/nacl_process_host.h"
Expand Down Expand Up @@ -110,6 +109,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chromeos/chromeos_constants.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/common/nacl_process_type.h"
#include "components/translate/common/translate_switches.h"
#include "components/user_prefs/pref_registry_syncable.h"
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/nacl_host/nacl_broker_host_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "base/path_service.h"
#include "ipc/ipc_switches.h"
#include "chrome/browser/nacl_host/nacl_broker_service_win.h"
#include "chrome/browser/nacl_host/nacl_browser.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/common/nacl_cmd_line.h"
#include "components/nacl/common/nacl_messages.h"
#include "components/nacl/common/nacl_process_type.h"
Expand Down Expand Up @@ -53,7 +53,7 @@ bool NaClBrokerHost::Init() {

// Create the path to the nacl broker/loader executable.
base::FilePath nacl_path;
if (!NaClBrowser::GetInstance()->GetNaCl64ExePath(&nacl_path))
if (!nacl::NaClBrowser::GetInstance()->GetNaCl64ExePath(&nacl_path))
return false;

CommandLine* cmd_line = new CommandLine(nacl_path);
Expand All @@ -62,7 +62,7 @@ bool NaClBrokerHost::Init() {
cmd_line->AppendSwitchASCII(switches::kProcessType,
switches::kNaClBrokerProcess);
cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id);
if (NaClBrowser::GetDelegate()->DialogsAreSuppressed())
if (nacl::NaClBrowser::GetDelegate()->DialogsAreSuppressed())
cmd_line->AppendSwitch(switches::kNoErrorDialogs);

process_->Launch(new NaClBrokerSandboxedProcessLauncherDelegate, cmd_line);
Expand Down
14 changes: 7 additions & 7 deletions chrome/browser/nacl_host/nacl_file_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "base/platform_file.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/nacl_host/nacl_browser.h"
#include "chrome/browser/nacl_host/nacl_host_message_filter.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/common/nacl_browser_delegate.h"
#include "components/nacl/common/nacl_host_messages.h"
#include "components/nacl/common/pnacl_types.h"
Expand Down Expand Up @@ -45,7 +45,7 @@ void TryInstallPnacl(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// TODO(jvoung): Figure out a way to get progress events and
// call progress_callback.
NaClBrowser::GetDelegate()->TryInstallPnacl(done_callback);
nacl::NaClBrowser::GetDelegate()->TryInstallPnacl(done_callback);
}

void DoEnsurePnaclInstalled(
Expand All @@ -54,7 +54,7 @@ void DoEnsurePnaclInstalled(
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
// If already installed, return reply w/ success immediately.
base::FilePath pnacl_dir;
if (NaClBrowser::GetDelegate()->GetPnaclDirectory(&pnacl_dir)
if (nacl::NaClBrowser::GetDelegate()->GetPnaclDirectory(&pnacl_dir)
&& !pnacl_dir.empty()
&& base::PathExists(pnacl_dir)) {
done_callback.Run(true);
Expand Down Expand Up @@ -93,7 +93,7 @@ void DoOpenPnaclFile(

// PNaCl must be installed.
base::FilePath pnacl_dir;
if (!NaClBrowser::GetDelegate()->GetPnaclDirectory(&pnacl_dir) ||
if (!nacl::NaClBrowser::GetDelegate()->GetPnaclDirectory(&pnacl_dir) ||
!base::PathExists(pnacl_dir)) {
NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
Expand Down Expand Up @@ -134,7 +134,7 @@ void DoRegisterOpenedNaClExecutableFile(
// IO thread owns the NaClBrowser singleton.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));

NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
nacl::NaClBrowser* nacl_browser = nacl::NaClBrowser::GetInstance();
uint64 file_token_lo = 0;
uint64 file_token_hi = 0;
nacl_browser->PutFilePath(file_path, &file_token_lo, &file_token_hi);
Expand All @@ -159,7 +159,7 @@ void DoOpenNaClExecutableOnThreadPool(
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());

base::FilePath file_path;
if (!NaClBrowser::GetDelegate()->MapUrlToLocalFilePath(
if (!nacl::NaClBrowser::GetDelegate()->MapUrlToLocalFilePath(
file_url, true /* use_blocking_api */, &file_path)) {
NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
Expand Down Expand Up @@ -234,7 +234,7 @@ bool PnaclCanOpenFile(const std::string& filename,

// PNaCl must be installed.
base::FilePath pnacl_dir;
if (!NaClBrowser::GetDelegate()->GetPnaclDirectory(&pnacl_dir) ||
if (!nacl::NaClBrowser::GetDelegate()->GetPnaclDirectory(&pnacl_dir) ||
pnacl_dir.empty())
return false;

Expand Down
13 changes: 8 additions & 5 deletions chrome/browser/nacl_host/nacl_file_host_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "base/run_loop.h"
#include "base/test/scoped_path_override.h"
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/nacl_host/nacl_browser.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/common/nacl_browser_delegate.h"
#include "components/nacl/common/pnacl_types.h"
#include "content/public/browser/browser_thread.h"
Expand Down Expand Up @@ -100,11 +100,12 @@ class NaClFileHostTest : public testing::Test {

virtual void SetUp() OVERRIDE {
nacl_browser_delegate_ = new TestNaClBrowserDelegate;
NaClBrowser::SetDelegate(nacl_browser_delegate_);
nacl::NaClBrowser::SetDelegate(nacl_browser_delegate_);
}

virtual void TearDown() OVERRIDE {
NaClBrowser::SetDelegate(NULL); // This deletes nacl_browser_delegate_
// This deletes nacl_browser_delegate_.
nacl::NaClBrowser::SetDelegate(NULL);
}

TestNaClBrowserDelegate* nacl_browser_delegate() {
Expand Down Expand Up @@ -172,7 +173,8 @@ TEST_F(NaClFileHostTest, TestFilenamesWithPnaclPath) {
base::FilePath kTestPnaclPath = scoped_tmp_dir.path();

nacl_browser_delegate()->SetPnaclDirectory(kTestPnaclPath);
ASSERT_TRUE(NaClBrowser::GetDelegate()->GetPnaclDirectory(&kTestPnaclPath));
ASSERT_TRUE(nacl::NaClBrowser::GetDelegate()->GetPnaclDirectory(
&kTestPnaclPath));

// Check allowed strings, and check that the expected prefix is added.
base::FilePath out_path;
Expand Down Expand Up @@ -228,7 +230,8 @@ TEST_F(NaClFileHostTest, TestEnsureInstalledAlreadyInstalled) {

base::FilePath kTestPnaclPath = scoped_tmp_dir.path();
nacl_browser_delegate()->SetPnaclDirectory(kTestPnaclPath);
ASSERT_TRUE(NaClBrowser::GetDelegate()->GetPnaclDirectory(&kTestPnaclPath));
ASSERT_TRUE(nacl::NaClBrowser::GetDelegate()->GetPnaclDirectory(
&kTestPnaclPath));

EnsurePnaclInstalled(
base::Bind(&NaClFileHostTest::CallbackInstall, base::Unretained(this)),
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/nacl_host/nacl_host_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include "chrome/browser/nacl_host/nacl_host_message_filter.h"

#include "chrome/browser/nacl_host/nacl_browser.h"
#include "chrome/browser/nacl_host/nacl_file_host.h"
#include "chrome/browser/nacl_host/nacl_process_host.h"
#include "chrome/browser/nacl_host/pnacl_host.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/common/nacl_host_messages.h"
#include "ipc/ipc_platform_file.h"
#include "net/url_request/url_request_context.h"
Expand Down Expand Up @@ -82,7 +82,7 @@ void NaClHostMessageFilter::OnLaunchNaCl(
// We're calling MapUrlToLocalFilePath with the non-blocking API
// because we're running in the I/O thread. Ideally we'd use the other path,
// which would cover more cases.
NaClBrowser::GetDelegate()->MapUrlToLocalFilePath(
nacl::NaClBrowser::GetDelegate()->MapUrlToLocalFilePath(
manifest_url, false /* use_blocking_api */, &manifest_path);
host->Launch(this, reply_msg, manifest_path);
}
Expand Down Expand Up @@ -183,8 +183,8 @@ void NaClHostMessageFilter::OnTranslationFinished(int instance, bool success) {

void NaClHostMessageFilter::OnNaClErrorStatus(int render_view_id,
int error_id) {
NaClBrowser::GetDelegate()->ShowNaClInfobar(render_process_id_,
render_view_id, error_id);
nacl::NaClBrowser::GetDelegate()->ShowNaClInfobar(render_process_id_,
render_view_id, error_id);
}

void NaClHostMessageFilter::OnOpenNaClExecutable(int render_view_id,
Expand Down
Loading

0 comments on commit ef42ee8

Please sign in to comment.