Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Unified Diff: device/sensors/device_sensor_service.cc

Issue 2730333002: Make DeviceSensorService implement MainLoop::DestructionObserver (Closed)
Patch Set: code rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/sensors/device_sensor_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/sensors/device_sensor_service.cc
diff --git a/device/sensors/device_sensor_service.cc b/device/sensors/device_sensor_service.cc
index 12ffa6bb5c07cbb2f2b7495a57735d8ba4328899..44693185eb8d09435f504d4e18d0d7bd6d30628a 100644
--- a/device/sensors/device_sensor_service.cc
+++ b/device/sensors/device_sensor_service.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
+#include "base/trace_event/trace_event.h"
#include "device/sensors/data_fetcher_shared_memory.h"
namespace device {
@@ -16,7 +17,9 @@ DeviceSensorService::DeviceSensorService()
num_motion_readers_(0),
num_orientation_readers_(0),
num_orientation_absolute_readers_(0),
- is_shutdown_(false) {}
+ is_shutdown_(false) {
+ base::MessageLoop::current()->AddDestructionObserver(this);
+}
DeviceSensorService::~DeviceSensorService() {}
@@ -95,6 +98,12 @@ mojo::ScopedSharedBufferHandle DeviceSensorService::GetSharedMemoryHandle(
return data_fetcher_->GetSharedMemoryHandle(consumer_type);
}
+void DeviceSensorService::WillDestroyCurrentMessageLoop() {
+ base::MessageLoop::current()->RemoveDestructionObserver(this);
+ TRACE_EVENT0("shutdown", "DeviceSensorService::Subsystem:SensorService");
+ Shutdown();
+}
+
void DeviceSensorService::Shutdown() {
if (data_fetcher_) {
data_fetcher_->Shutdown();
« no previous file with comments | « device/sensors/device_sensor_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698