Skip to content

Commit

Permalink
Revert "Introduce ArcServiceManager::OnShutdown()."
Browse files Browse the repository at this point in the history
This reverts commit 772f3e5.

This is for the fixing of crash issue.
Please see details on the linked bug.

BUG=676725
TEST=Ran trybots.

Review-Url: https://codereview.chromium.org/2619203004
Cr-Commit-Position: refs/heads/master@{#442625}
  • Loading branch information
hidehiko authored and Commit bot committed Jan 10, 2017
1 parent fe74fda commit 4106ae0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
10 changes: 4 additions & 6 deletions chrome/browser/chromeos/extensions/file_manager/event_router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,8 @@ EventRouter::EventRouter(Profile* profile)

EventRouter::~EventRouter() = default;

void EventRouter::OnArcShutdown() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
arc::ArcServiceManager::Get()->RemoveObserver(this);
}

void EventRouter::OnIntentFiltersUpdated() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BroadcastEvent(profile_,
extensions::events::FILE_MANAGER_PRIVATE_ON_APPS_UPDATED,
file_manager_private::OnAppsUpdated::kEventName,
Expand All @@ -417,6 +412,9 @@ void EventRouter::OnIntentFiltersUpdated() {
void EventRouter::Shutdown() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);

if (arc::ArcServiceManager::IsInitialized())
arc::ArcServiceManager::Get()->RemoveObserver(this);

chromeos::system::TimezoneSettings::GetInstance()->RemoveObserver(this);

DLOG_IF(WARNING, !file_watchers_.empty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class EventRouter : public KeyedService,
~EventRouter() override;

// arc::ArcServiceManager::Observer overrides.
void OnArcShutdown() override;
void OnIntentFiltersUpdated() override;

// KeyedService overrides.
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/chromeos/note_taking_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ void NoteTakingHelper::LaunchAppForNewNote(Profile* profile,
static_cast<int>(LaunchResult::MAX));
}

void NoteTakingHelper::OnArcShutdown() {}

void NoteTakingHelper::OnIntentFiltersUpdated() {
if (android_enabled_)
UpdateAndroidApps();
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/chromeos/note_taking_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ class NoteTakingHelper : public arc::ArcServiceManager::Observer,
void LaunchAppForNewNote(Profile* profile, const base::FilePath& path);

// arc::ArcServiceManager::Observer:
void OnArcShutdown() override;
void OnIntentFiltersUpdated() override;

// arc::ArcSessionManager::Observer:
Expand Down
13 changes: 8 additions & 5 deletions components/arc/arc_service_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ ArcServiceManager* ArcServiceManager::Get() {
return g_arc_service_manager;
}

// static
bool ArcServiceManager::IsInitialized() {
if (!g_arc_service_manager)
return false;
DCHECK(g_arc_service_manager->thread_checker_.CalledOnValidThread());
return true;
}

ArcBridgeService* ArcServiceManager::arc_bridge_service() {
DCHECK(thread_checker_.CalledOnValidThread());
return arc_bridge_service_.get();
Expand All @@ -92,11 +100,6 @@ void ArcServiceManager::RemoveObserver(Observer* observer) {

void ArcServiceManager::Shutdown() {
DCHECK(thread_checker_.CalledOnValidThread());

// Before actual shutdown, notify observers for clean up.
for (auto& observer : observer_list_)
observer.OnArcShutdown();

icon_loader_ = nullptr;
activity_resolver_ = nullptr;
services_.clear();
Expand Down
11 changes: 6 additions & 5 deletions components/arc/arc_service_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ class ArcServiceManager {
public:
class Observer {
public:
// Called when ArcServiceManager is being shut down. Observer
// implementation should clean up ARC related stuff here. One of the
// typical use cases is calling ArcServiceManager::RemoveObserver().
virtual void OnArcShutdown() = 0;

// Called when intent filters are added or removed.
virtual void OnIntentFiltersUpdated() = 0;

Expand All @@ -55,6 +50,12 @@ class ArcServiceManager {
// called on the thread that this class was created on.
static ArcServiceManager* Get();

// Returns if the ARC Service Manager instance exists.
// DO NOT CALL THIS. This function is a dirty workaround for properly shutting
// down chrome/browser/chromeos/extensions/file_manager/event_router.cc, and
// will likely be removed in the future.
static bool IsInitialized();

void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);

Expand Down

0 comments on commit 4106ae0

Please sign in to comment.