Commit 939825aa authored by binjin's avatar binjin Committed by Commit bot

Fix occasional crash in remote commands code

The RemoteCommandsService depends on a reference to CloudPolicyClient, but
it doesn't get deleted before CloudPolicyClient is gone. This leads to dangling
pointer and will probably crash the browser.

This CL also remove code attempts to workaround this issue in crrev.com/330082

BUG=480982

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

Cr-Commit-Position: refs/heads/master@{#330497}
parent 26ad2f0f
...@@ -49,6 +49,7 @@ void CloudPolicyCore::Disconnect() { ...@@ -49,6 +49,7 @@ void CloudPolicyCore::Disconnect() {
FOR_EACH_OBSERVER(Observer, observers_, OnCoreDisconnecting(this)); FOR_EACH_OBSERVER(Observer, observers_, OnCoreDisconnecting(this));
refresh_delay_.reset(); refresh_delay_.reset();
refresh_scheduler_.reset(); refresh_scheduler_.reset();
remote_commands_service_.reset();
service_.reset(); service_.reset();
client_.reset(); client_.reset();
} }
......
...@@ -22,6 +22,7 @@ RemoteCommandsService::RemoteCommandsService( ...@@ -22,6 +22,7 @@ RemoteCommandsService::RemoteCommandsService(
scoped_ptr<RemoteCommandsFactory> factory, scoped_ptr<RemoteCommandsFactory> factory,
CloudPolicyClient* client) CloudPolicyClient* client)
: factory_(factory.Pass()), client_(client), weak_factory_(this) { : factory_(factory.Pass()), client_(client), weak_factory_(this) {
DCHECK(client_);
queue_.AddObserver(this); queue_.AddObserver(this);
} }
...@@ -30,7 +31,7 @@ RemoteCommandsService::~RemoteCommandsService() { ...@@ -30,7 +31,7 @@ RemoteCommandsService::~RemoteCommandsService() {
} }
bool RemoteCommandsService::FetchRemoteCommands() { bool RemoteCommandsService::FetchRemoteCommands() {
if (!client_ || !client_->is_registered()) if (!client_->is_registered())
return false; return false;
if (command_fetch_in_progress_) { if (command_fetch_in_progress_) {
......
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