diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-29 19:59:08 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-29 19:59:08 +0000 |
commit | b4cebf87816cde49f6d4991ffa254e5ead97703b (patch) | |
tree | fb12e4b464a43af846f30bbd0dbe9484150373b0 /chrome/browser/page_state.cc | |
parent | 45ce59f19161b517c04a4e3bcd0890b938382b06 (diff) | |
download | chromium_src-b4cebf87816cde49f6d4991ffa254e5ead97703b.zip chromium_src-b4cebf87816cde49f6d4991ffa254e5ead97703b.tar.gz chromium_src-b4cebf87816cde49f6d4991ffa254e5ead97703b.tar.bz2 |
Change the signature of JSONReader::Read() and related
methods to be more friendly to use with scoped_ptr. Change
all the callsites.
Review URL: http://codereview.chromium.org/16270
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/page_state.cc')
-rw-r--r-- | chrome/browser/page_state.cc | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/chrome/browser/page_state.cc b/chrome/browser/page_state.cc index f47a4cf..1d52ffb 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 { |