| OLD | NEW |
| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 void PageState::InitWithBytes(const std::string& bytes) { | 40 void PageState::InitWithBytes(const std::string& bytes) { |
| 41 // Reset our state. We create a new empty one just in case | 41 // Reset our state. We create a new empty one just in case |
| 42 // deserialization fails | 42 // deserialization fails |
| 43 state_.reset(new DictionaryValue); | 43 state_.reset(new DictionaryValue); |
| 44 | 44 |
| 45 JSONStringValueSerializer serializer(bytes); | 45 JSONStringValueSerializer serializer(bytes); |
| 46 scoped_ptr<Value> root(serializer.Deserialize(NULL)); | 46 scoped_ptr<Value> root(serializer.Deserialize(NULL, NULL)); |
| 47 | 47 |
| 48 if (!root.get()) { | 48 if (!root.get()) { |
| 49 NOTREACHED(); | 49 NOTREACHED(); |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 | 52 |
| 53 if (root->GetType() == Value::TYPE_DICTIONARY) | 53 if (root->GetType() == Value::TYPE_DICTIONARY) |
| 54 state_.reset(static_cast<DictionaryValue*>(root.release())); | 54 state_.reset(static_cast<DictionaryValue*>(root.release())); |
| 55 } | 55 } |
| 56 | 56 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 return false; | 103 return false; |
| 104 } | 104 } |
| 105 | 105 |
| 106 PageState* PageState::Copy() const { | 106 PageState* PageState::Copy() const { |
| 107 PageState* copy = new PageState(); | 107 PageState* copy = new PageState(); |
| 108 if (state_.get()) | 108 if (state_.get()) |
| 109 copy->state_.reset(static_cast<DictionaryValue*>(state_->DeepCopy())); | 109 copy->state_.reset(static_cast<DictionaryValue*>(state_->DeepCopy())); |
| 110 return copy; | 110 return copy; |
| 111 } | 111 } |
| OLD | NEW |