diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-17 22:07:23 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-17 22:07:23 +0000 |
commit | c48c61ba5360114271bf6cb1412a2c3b413a7da9 (patch) | |
tree | 6becab431f2050ddc07eb80d6885571753f19294 /chrome/profile_import | |
parent | 3fa131ed261627dbf01646ff4d5a1194492aaaac (diff) | |
download | chromium_src-c48c61ba5360114271bf6cb1412a2c3b413a7da9.zip chromium_src-c48c61ba5360114271bf6cb1412a2c3b413a7da9.tar.gz chromium_src-c48c61ba5360114271bf6cb1412a2c3b413a7da9.tar.bz2 |
Add Profile Import Process Type.
This is currently only used on OS X.
We need a separate process to do profile import for 3 reasons:
1)In Firefox we load external libraries which we have no control over.
2)Conceptually it's safer to run parsing code OOP.
3)quoth chrome/browser/importer/nss_decryptor_mac.mm :
"""
On OS X the nss3 libraries are compiled with depedencies
on one another, referenced using dyld's @executable_path directive.
To make a long story short in order to get the libraries to load, dyld's
fallback path needs to be set to the directory containing the libraries.
To do so, the process this function runs in must have the
DYLD_FALLBACK_LIBRARY_PATH set on startup to said directory.
"""
BUG=14458
TEST=None Possible
Review URL: http://codereview.chromium.org/193131
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/profile_import')
-rw-r--r-- | chrome/profile_import/profile_import_main.cc | 30 | ||||
-rw-r--r-- | chrome/profile_import/profile_import_thread.cc | 19 | ||||
-rw-r--r-- | chrome/profile_import/profile_import_thread.h | 29 |
3 files changed, 78 insertions, 0 deletions
diff --git a/chrome/profile_import/profile_import_main.cc b/chrome/profile_import/profile_import_main.cc new file mode 100644 index 0000000..11b1aed --- /dev/null +++ b/chrome/profile_import/profile_import_main.cc @@ -0,0 +1,30 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "base/message_loop.h" +#include "base/string_util.h" +#include "base/system_monitor.h" +#include "chrome/common/child_process.h" +#include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/logging_chrome.h" +#include "chrome/common/main_function_params.h" +#include "chrome/profile_import/profile_import_thread.h" + +// Mainline routine for running as the profile import process. +int ProfileImportMain(const MainFunctionParams& parameters) { + // The main message loop of the profile import process. + MessageLoop main_message_loop; + std::wstring app_name = chrome::kBrowserAppName; + PlatformThread::SetName(WideToASCII( + app_name + L"_ProfileImportMain").c_str()); + + ChildProcess profile_import_process; + profile_import_process.set_main_thread(new ProfileImportThread()); + + MessageLoop::current()->Run(); + + return 0; +} diff --git a/chrome/profile_import/profile_import_thread.cc b/chrome/profile_import/profile_import_thread.cc new file mode 100644 index 0000000..6a0211f7 --- /dev/null +++ b/chrome/profile_import/profile_import_thread.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/profile_import/profile_import_thread.h" + +#include "chrome/common/child_process.h" + +ProfileImportThread::ProfileImportThread() { + ChildProcess::current()->AddRefProcess(); +} + +ProfileImportThread::~ProfileImportThread() { +} + +void ProfileImportThread::OnControlMessageReceived(const IPC::Message& msg) { + ChildProcess::current()->ReleaseProcess(); + NOTIMPLEMENTED(); +} diff --git a/chrome/profile_import/profile_import_thread.h b/chrome/profile_import/profile_import_thread.h new file mode 100644 index 0000000..ea2c4b8 --- /dev/null +++ b/chrome/profile_import/profile_import_thread.h @@ -0,0 +1,29 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_PROFILE_IMPORT_PROFILE_IMPORT_THREAD_H_ +#define CHROME_PROFILE_IMPORT_PROFILE_IMPORT_THREAD_H_ + +#include "chrome/common/child_thread.h" + +// This class represents the background thread where the profile import task +// runs. +class ProfileImportThread : public ChildThread { + public: + ProfileImportThread(); + virtual ~ProfileImportThread(); + + // Returns the one profile import thread. + static ProfileImportThread* current() { + return static_cast<ProfileImportThread*>(ChildThread::current()); + } + + private: + // IPC messages + virtual void OnControlMessageReceived(const IPC::Message& msg); + + DISALLOW_COPY_AND_ASSIGN(ProfileImportThread); +}; + +#endif // CHROME_PROFILE_IMPORT_PROFILE_IMPORT_THREAD_H_ |