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

Unified Diff: content/browser/device_orientation/data_fetcher_impl_win.cc

Issue 18572014: Implement Android shared memory data fetcher for Device Motion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renderer-sync-12June-tryASYNC-2-bis-tryRebase-6
Patch Set: fixed comments, added proper singleton implementation and shutdown. Created 7 years, 5 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: content/browser/device_orientation/data_fetcher_impl_win.cc
diff --git a/content/browser/device_orientation/data_fetcher_impl_win.cc b/content/browser/device_orientation/data_fetcher_impl_win.cc
index d08ed446ad623f4c8e577cc7fd97fdf01f14f559..6debc99904c4c5c37eb8e62a4f6da8f77315c0b1 100644
--- a/content/browser/device_orientation/data_fetcher_impl_win.cc
+++ b/content/browser/device_orientation/data_fetcher_impl_win.cc
@@ -101,25 +101,34 @@ class DataFetcherImplWin::SensorEventSink : public ISensorEvents,
DISALLOW_COPY_AND_ASSIGN(SensorEventSink);
};
+DataFetcherImplWin* DataFetcherImplWin::instance() {
+ CR_DEFINE_STATIC_LOCAL(DataFetcherImplWin, s_data_fetcher, ());
+ return &s_data_fetcher;
+}
+
// Create a DataFetcherImplWin object and return NULL if no valid sensor found.
// static
DataFetcher* DataFetcherImplWin::Create() {
- scoped_ptr<DataFetcherImplWin> fetcher(new DataFetcherImplWin);
+ DataFetcherImplWin* fetcher = DataFetcherImplWin::instance();
if (fetcher->Initialize())
- return fetcher.release();
+ return fetcher;
LOG(ERROR) << "DataFetcherImplWin::Initialize failed!";
return NULL;
}
DataFetcherImplWin::~DataFetcherImplWin() {
- if (sensor_)
- sensor_->SetEventSink(NULL);
+ Stop();
}
DataFetcherImplWin::DataFetcherImplWin() {
}
+void DataFetcherImplWin::Stop() {
+ if (sensor_)
+ sensor_->SetEventSink(NULL);
+}
+
void DataFetcherImplWin::OnOrientationData(Orientation* orientation) {
// This method is called on Windows sensor thread.
base::AutoLock autolock(next_orientation_lock_);

Powered by Google App Engine
This is Rietveld 408576698