// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "data_fetcher_shared_memory.h"

#include "base/logging.h"
#include "data_fetcher_impl_android.h"

namespace content {

DataFetcherSharedMemory::~DataFetcherSharedMemory() {
  if (started_)
    StopFetchingDeviceMotionData();
}

bool DataFetcherSharedMemory::NeedsPolling() {
  return false;
}

bool DataFetcherSharedMemory::FetchDeviceMotionDataIntoBuffer() {
  NOTREACHED();
  return false;
}

bool DataFetcherSharedMemory::StartFetchingDeviceMotionData(
    DeviceMotionHardwareBuffer* buffer) {
  DCHECK(buffer);
  device_motion_buffer_ = buffer;
  started_ = DataFetcherImplAndroid::GetInstance()->
      StartFetchingDeviceMotionData(buffer);
  return started_;
}

void DataFetcherSharedMemory::StopFetchingDeviceMotionData() {
  DataFetcherImplAndroid::GetInstance()->StopFetchingDeviceMotionData();
  started_ = false;
}

}  // namespace content

// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "data_fetcher_shared_memory.h"

#include "base/logging.h"
#include "data_fetcher_impl_android.h"

namespace content {

DataFetcherSharedMemory::~DataFetcherSharedMemory() {
  if (started_)
    StopFetchingDeviceMotionData();
}

bool DataFetcherSharedMemory::NeedsPolling() {
  return false;
}

bool DataFetcherSharedMemory::FetchDeviceMotionDataIntoBuffer() {
  NOTREACHED();
  return false;
}

bool DataFetcherSharedMemory::StartFetchingDeviceMotionData(
    DeviceMotionHardwareBuffer* buffer) {
  DCHECK(buffer);
  device_motion_buffer_ = buffer;
  return DataFetcherImplAndroid::GetInstance()->
      StartFetchingDeviceMotionData(buffer);
  started_ = true;
}

void DataFetcherSharedMemory::StopFetchingDeviceMotionData() {
  DataFetcherImplAndroid::GetInstance()->StopFetchingDeviceMotionData();
  started_ = false;
}

}  // namespace content

--- 
+++ 
@@ -27,9 +27,9 @@
     DeviceMotionHardwareBuffer* buffer) {
   DCHECK(buffer);
   device_motion_buffer_ = buffer;
-  return DataFetcherImplAndroid::GetInstance()->
+  started_ = DataFetcherImplAndroid::GetInstance()->
       StartFetchingDeviceMotionData(buffer);
-  started_ = true;
+  return started_;
 }
 
 void DataFetcherSharedMemory::StopFetchingDeviceMotionData() {
Fix |started_| variable for Device Motion Android data fetcher.

Ensure proper stopping of sensors upon fetcher destruction.

BUG=

Review URL: https://chromiumcodereview.appspot.com/22336011

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@216522 0039d316-1c4b-4281-b951-d872f2087c98
