Add JSON parsing support (issue #1188).

This commit is contained in:
Yu-Teh Shen
2015-04-17 22:19:30 +08:00
committed by Marshall Greenblatt
parent 373180fef2
commit d02f03a71a
12 changed files with 577 additions and 1 deletions

View File

@@ -363,6 +363,55 @@ void CefValueImpl::SetValueInternal(base::Value* value) {
}
}
CefValueController* CefValueImpl::GetValueController() const {
lock_.AssertAcquired();
if (binary_value_) {
return static_cast<CefBinaryValueImpl*>(binary_value_.get())->controller();
} else if (dictionary_value_) {
return static_cast<CefDictionaryValueImpl*>(dictionary_value_.get())->
controller();
} else if (list_value_) {
return static_cast<CefListValueImpl*>(list_value_.get())->controller();
}
return NULL;
}
void CefValueImpl::AcquireLock() {
lock_.Acquire();
CefValueController* controller = GetValueController();
if (controller)
controller->lock();
}
void CefValueImpl::ReleaseLock() {
CefValueController* controller = GetValueController();
if (controller) {
controller->AssertLockAcquired();
controller->unlock();
}
lock_.Release();
}
base::Value* CefValueImpl::GetValueUnsafe() const {
lock_.AssertAcquired();
if (binary_value_) {
return static_cast<CefBinaryValueImpl*>(binary_value_.get())->
GetValueUnsafe();
} else if (dictionary_value_) {
return static_cast<CefDictionaryValueImpl*>(dictionary_value_.get())->
GetValueUnsafe();
} else if (list_value_) {
return static_cast<CefListValueImpl*>(list_value_.get())->GetValueUnsafe();
}
return value_.get();
}
// CefBinaryValueImpl implementation.
@@ -441,6 +490,13 @@ bool CefBinaryValueImpl::IsEqualValue(const base::BinaryValue* that) {
return const_value().Equals(that);
}
base::BinaryValue* CefBinaryValueImpl::GetValueUnsafe() {
if (!VerifyAttached())
return NULL;
controller()->AssertLockAcquired();
return const_cast<base::BinaryValue*>(&const_value());
}
bool CefBinaryValueImpl::IsValid() {
return !detached();
}
@@ -572,6 +628,13 @@ bool CefDictionaryValueImpl::IsEqualValue(const base::DictionaryValue* that) {
return const_value().Equals(that);
}
base::DictionaryValue* CefDictionaryValueImpl::GetValueUnsafe() {
if (!VerifyAttached())
return NULL;
controller()->AssertLockAcquired();
return const_cast<base::DictionaryValue*>(&const_value());
}
bool CefDictionaryValueImpl::IsValid() {
return !detached();
}
@@ -979,6 +1042,13 @@ bool CefListValueImpl::IsEqualValue(const base::ListValue* that) {
return const_value().Equals(that);
}
base::ListValue* CefListValueImpl::GetValueUnsafe() {
if (!VerifyAttached())
return NULL;
controller()->AssertLockAcquired();
return const_cast<base::ListValue*>(&const_value());
}
bool CefListValueImpl::IsValid() {
return !detached();
}