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

Side by Side Diff: chrome/browser/page_state.cc

Issue 13169: Add error messages to JSONReader and friends. This required a bit of refactor... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/page_state.h" 8 #include "chrome/browser/page_state.h"
9 #include "chrome/common/json_value_serializer.h" 9 #include "chrome/common/json_value_serializer.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 void PageState::InitWithBytes(const std::string& bytes) { 37 void PageState::InitWithBytes(const std::string& bytes) {
38 // Reset our state. We create a new empty one just in case 38 // Reset our state. We create a new empty one just in case
39 // deserialization fails 39 // deserialization fails
40 state_.reset(new DictionaryValue); 40 state_.reset(new DictionaryValue);
41 41
42 JSONStringValueSerializer serializer(bytes); 42 JSONStringValueSerializer serializer(bytes);
43 Value* root = NULL; 43 Value* root = NULL;
44 44
45 if (!serializer.Deserialize(&root)) 45 if (!serializer.Deserialize(&root, NULL))
46 NOTREACHED(); 46 NOTREACHED();
47 47
48 if (root != NULL && root->GetType() == Value::TYPE_DICTIONARY) { 48 if (root != NULL && root->GetType() == Value::TYPE_DICTIONARY) {
49 state_.reset(static_cast<DictionaryValue*>(root)); 49 state_.reset(static_cast<DictionaryValue*>(root));
50 } else if (root) { 50 } else if (root) {
51 delete root; 51 delete root;
52 } 52 }
53 } 53 }
54 54
55 void PageState::GetByteRepresentation(std::string* out) const { 55 void PageState::GetByteRepresentation(std::string* out) const {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return false; 100 return false;
101 } 101 }
102 102
103 PageState* PageState::Copy() const { 103 PageState* PageState::Copy() const {
104 PageState* copy = new PageState(); 104 PageState* copy = new PageState();
105 if (state_.get()) 105 if (state_.get())
106 copy->state_.reset(static_cast<DictionaryValue*>(state_->DeepCopy())); 106 copy->state_.reset(static_cast<DictionaryValue*>(state_->DeepCopy()));
107 return copy; 107 return copy;
108 } 108 }
109 109
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698