Commit 8a16e9b9 authored by rsimha@chromium.org's avatar rsimha@chromium.org

Revert 221580 "Make AppShimHostManager a RefCountedThreadSafe."

Reason for revert: Use-after-free heap errors caught by asan.
See bug 286483.

> Make AppShimHostManager a RefCountedThreadSafe.
> 
> This prevents a crash when Chrome shuts down immediately and 
> AppShimHostManager is destructed before InitOnFileThread is run.
> Note this means AppShimHostManager can stay around longer than
> BrowserProcessPlatformPart during initialization.
> 
> Review URL: https://chromiumcodereview.appspot.com/20065004

BUG=286483,242941
TBR=jackhou@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221793 0039d316-1c4b-4281-b951-d872f2087c98
parent e460a4dc
......@@ -6,25 +6,23 @@
#define CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MANAGER_MAC_H_
#include "apps/app_shim/extension_app_shim_handler_mac.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "ipc/ipc_channel_factory.h"
// The AppShimHostManager receives connections from app shims on a UNIX
// socket (|factory_|) and creates a helper object to manage the connection.
class AppShimHostManager
: public IPC::ChannelFactory::Delegate,
public base::RefCountedThreadSafe<AppShimHostManager> {
public base::SupportsWeakPtr<AppShimHostManager> {
public:
AppShimHostManager();
virtual ~AppShimHostManager();
apps::ExtensionAppShimHandler* extension_app_shim_handler() {
return &extension_app_shim_handler_;
}
private:
friend class base::RefCountedThreadSafe<AppShimHostManager>;
virtual ~AppShimHostManager();
// IPC::ChannelFactory::Delegate implementation.
virtual void OnClientConnected(const IPC::ChannelHandle& handle) OVERRIDE;
virtual void OnListenError() OVERRIDE;
......
......@@ -31,7 +31,8 @@ AppShimHostManager::AppShimHostManager() {
apps::AppShimHandler::SetDefaultHandler(&extension_app_shim_handler_);
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&AppShimHostManager::InitOnFileThread, this));
base::Bind(&AppShimHostManager::InitOnFileThread,
base::Unretained(this)));
}
AppShimHostManager::~AppShimHostManager() {
......@@ -51,7 +52,8 @@ void AppShimHostManager::InitOnFileThread() {
factory_.reset(new IPC::ChannelFactory(socket_path, this));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&AppShimHostManager::ListenOnIOThread, this));
base::Bind(&AppShimHostManager::ListenOnIOThread,
base::Unretained(this)));
}
void AppShimHostManager::ListenOnIOThread() {
......
......@@ -5,11 +5,12 @@
#ifndef CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_MAC_H_
#define CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_MAC_H_
#include "apps/app_shim/app_shim_host_manager_mac.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/browser_process_platform_part_base.h"
class AppShimHostManager;
namespace apps {
class ExtensionAppShimHandler;
}
......@@ -28,7 +29,7 @@ class BrowserProcessPlatformPart : public BrowserProcessPlatformPartBase {
private:
// Hosts the IPC channel factory that App Shims connect to on Mac.
scoped_refptr<AppShimHostManager> app_shim_host_manager_;
scoped_ptr<AppShimHostManager> app_shim_host_manager_;
DISALLOW_COPY_AND_ASSIGN(BrowserProcessPlatformPart);
};
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/browser_process_platform_part_mac.h"
#include "apps/app_shim/app_shim_host_manager_mac.h"
#include "chrome/browser/chrome_browser_application_mac.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
......@@ -14,7 +15,7 @@ BrowserProcessPlatformPart::~BrowserProcessPlatformPart() {
}
void BrowserProcessPlatformPart::StartTearDown() {
app_shim_host_manager_ = NULL;
app_shim_host_manager_.reset();
}
void BrowserProcessPlatformPart::AttemptExit() {
......@@ -25,7 +26,7 @@ void BrowserProcessPlatformPart::AttemptExit() {
}
void BrowserProcessPlatformPart::PreMainMessageLoopRun() {
app_shim_host_manager_ = new AppShimHostManager;
app_shim_host_manager_.reset(new AppShimHostManager);
AppListService::InitAll(NULL);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment