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

Unified Diff: chrome/browser/page_state.cc

Issue 16270: Change the signature of JSONReader::Read() and related methods to be more (Closed)
Patch Set: fixens Created 12 years 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: chrome/browser/page_state.cc
diff --git a/chrome/browser/page_state.cc b/chrome/browser/page_state.cc
index f47a4cf1098d7f5219189ce8a9402a2ec0be18eb..1d52ffbb44e0ec862d3b92e4e9efca935f926e35 100644
--- a/chrome/browser/page_state.cc
+++ b/chrome/browser/page_state.cc
@@ -40,16 +40,15 @@ void PageState::InitWithBytes(const std::string& bytes) {
state_.reset(new DictionaryValue);
JSONStringValueSerializer serializer(bytes);
- Value* root = NULL;
+ scoped_ptr<Value> root(serializer.Deserialize(NULL));
- if (!serializer.Deserialize(&root, NULL))
+ if (!root.get()) {
NOTREACHED();
-
- if (root != NULL && root->GetType() == Value::TYPE_DICTIONARY) {
- state_.reset(static_cast<DictionaryValue*>(root));
- } else if (root) {
- delete root;
+ return;
}
+
+ if (root->GetType() == Value::TYPE_DICTIONARY)
+ state_.reset(static_cast<DictionaryValue*>(root.release()));
}
void PageState::GetByteRepresentation(std::string* out) const {

Powered by Google App Engine
This is Rietveld 408576698