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

Unified Diff: device/sensors/device_sensor_service.h

Issue 2730333002: Make DeviceSensorService implement MainLoop::DestructionObserver (Closed)
Patch Set: Make DeviceSensorService observes IOThread to shutdown in right time. 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
Index: device/sensors/device_sensor_service.h
diff --git a/device/sensors/device_sensor_service.h b/device/sensors/device_sensor_service.h
index 17ae9f82a00473fd800018b29ab2de1ab5e338ea..4a0798b56fd468605fee12bd2763eef884d4c789 100644
--- a/device/sensors/device_sensor_service.h
+++ b/device/sensors/device_sensor_service.h
@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/memory/shared_memory.h"
#include "base/memory/singleton.h"
+#include "base/message_loop/message_loop.h"
#include "base/threading/thread_checker.h"
#include "device/sensors/device_sensor_export.h"
#include "device/sensors/device_sensors_consts.h"
@@ -23,7 +24,8 @@ class DataFetcherSharedMemory;
// Owns the data fetcher for Device Motion and Orientation and keeps track of
// the number of consumers currently using the data. The data fetcher is stopped
// when there are no consumers.
-class DEVICE_SENSOR_EXPORT DeviceSensorService {
+class DEVICE_SENSOR_EXPORT DeviceSensorService
+ : public base::MessageLoop::DestructionObserver {
public:
// Returns the DeviceSensorService singleton.
static DeviceSensorService* GetInstance();
@@ -41,6 +43,10 @@ class DEVICE_SENSOR_EXPORT DeviceSensorService {
mojo::ScopedSharedBufferHandle GetSharedMemoryHandle(
ConsumerType consumer_type);
+ // base::MessageLoop::DestructionObserver, run in IO thread, only be called
+ // in non-Android platform.
+ void WillDestroyCurrentMessageLoop() override;
+
// Stop/join with the background polling thread in |provider_|.
void Shutdown();
@@ -52,7 +58,7 @@ class DEVICE_SENSOR_EXPORT DeviceSensorService {
friend struct base::DefaultSingletonTraits<DeviceSensorService>;
DeviceSensorService();
- virtual ~DeviceSensorService();
+ ~DeviceSensorService() override;
bool ChangeNumberConsumers(ConsumerType consumer_type, int delta);
int GetNumberConsumers(ConsumerType consumer_type) const;

Powered by Google App Engine
This is Rietveld 408576698