コード例 #1
0
ファイル: SensorProxy.cpp プロジェクト: ollie314/chromium
void SensorProxy::updateInternalReading() {
    DCHECK(isInitialized());
    int readAttempts = 0;
    const int kMaxReadAttemptsCount = 10;
    while (!tryReadFromBuffer()) {
        if (++readAttempts == kMaxReadAttemptsCount) {
            handleSensorError();
            return;
        }
    }
}
コード例 #2
0
ファイル: SensorProxy.cpp プロジェクト: ollie314/chromium
void SensorProxy::onSensorCreated(SensorInitParamsPtr params,
                                  SensorClientRequest clientRequest) {
    DCHECK_EQ(Initializing, m_state);
    if (!params) {
        handleSensorError(NotFoundError, "Sensor is not present on the platform.");
        return;
    }
    const size_t kReadBufferSize = sizeof(ReadingBuffer);

    DCHECK_EQ(0u, params->buffer_offset % kReadBufferSize);

    m_mode = params->mode;
    m_defaultConfig = std::move(params->default_configuration);
    if (!m_defaultConfig) {
        handleSensorError();
        return;
    }

    DCHECK(m_sensor.is_bound());
    m_clientBinding.Bind(std::move(clientRequest));

    m_sharedBufferHandle = std::move(params->memory);
    DCHECK(!m_sharedBuffer);
    m_sharedBuffer =
        m_sharedBufferHandle->MapAtOffset(kReadBufferSize, params->buffer_offset);

    if (!m_sharedBuffer) {
        handleSensorError();
        return;
    }

    auto errorCallback =
        WTF::bind(&SensorProxy::handleSensorError, wrapWeakPersistent(this),
                  UnknownError, String("Internal error"), String());
    m_sensor.set_connection_error_handler(
        convertToBaseCallback(std::move(errorCallback)));

    m_state = Initialized;
    for (Observer* observer : m_observers)
        observer->onSensorInitialized();
}
コード例 #3
0
ファイル: SensorProxy.cpp プロジェクト: ollie314/chromium
void SensorProxy::initialize() {
    if (m_state != Uninitialized)
        return;

    if (!m_provider->sensorProvider()) {
        handleSensorError();
        return;
    }

    m_state = Initializing;
    auto callback = convertToBaseCallback(
                        WTF::bind(&SensorProxy::onSensorCreated, wrapWeakPersistent(this)));
    m_provider->sensorProvider()->GetSensor(m_type, mojo::GetProxy(&m_sensor),
                                            callback);
}
コード例 #4
0
ファイル: SensorProxy.cpp プロジェクト: mirror/chromium
void SensorProxy::updateSensorReading() {
  DCHECK(isInitialized());
  DCHECK(m_readingFactory);
  int readAttempts = 0;
  const int kMaxReadAttemptsCount = 10;
  device::SensorReading readingData;
  while (!tryReadFromBuffer(readingData)) {
    if (++readAttempts == kMaxReadAttemptsCount) {
      handleSensorError();
      return;
    }
  }

  m_reading = m_readingFactory->createSensorReading(readingData);
}
コード例 #5
0
ファイル: SensorProxy.cpp プロジェクト: ollie314/chromium
void SensorProxy::RaiseError() {
    handleSensorError();
}