blob: 27e66a2b4b5d0816b75ce062799b3e4d2083ae90 [file] [log] [blame]
// 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 "ppapi/shared_impl/socket_option_data.h"
namespace ppapi {
SocketOptionData::SocketOptionData() : type_(TYPE_INVALID), value_(0) {}
SocketOptionData::~SocketOptionData() {}
SocketOptionData::Type SocketOptionData::GetType() const { return type_; }
bool SocketOptionData::GetBool(bool* out_value) const {
if (!out_value || type_ != TYPE_BOOL)
return false;
*out_value = value_ != 0;
return true;
}
bool SocketOptionData::GetInt32(int32_t* out_value) const {
if (!out_value || type_ != TYPE_INT32)
return false;
*out_value = value_;
return true;
}
void SocketOptionData::SetBool(bool value) {
type_ = TYPE_BOOL;
value_ = value ? 1 : 0;
}
void SocketOptionData::SetInt32(int32_t value) {
type_ = TYPE_INT32;
value_ = value;
}
} // namespace ppapi