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

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

Issue 3149: Porting changes in chrome/{browser,common}, also enabling more unit tests.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 3 months 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (v->GetType() == Value::TYPE_STRING) { 70 if (v->GetType() == Value::TYPE_STRING) {
71 StringValue* sv = reinterpret_cast<StringValue*>(v); 71 StringValue* sv = reinterpret_cast<StringValue*>(v);
72 sv->GetAsString(value); 72 sv->GetAsString(value);
73 return true; 73 return true;
74 } 74 }
75 } 75 }
76 return false; 76 return false;
77 } 77 }
78 78
79 void PageState::SetInt64Property(const std::wstring& key, int64 value) { 79 void PageState::SetInt64Property(const std::wstring& key, int64 value) {
80 wchar_t buff[64]; 80 SetProperty(key, Int64ToWString(value));
81 _i64tow_s(value, buff, arraysize(buff), 10);
82 SetProperty(key, buff);
83 } 81 }
84 82
85 bool PageState::GetInt64Property(const std::wstring& key, int64* value) const { 83 bool PageState::GetInt64Property(const std::wstring& key, int64* value) const {
86 std::wstring v; 84 std::wstring v;
87 if (GetProperty(key, &v)) { 85 if (GetProperty(key, &v)) {
88 *value = _wtoi64(v.c_str()); 86 return StringToInt64(v, value);
89 return true;
90 } 87 }
91 return false; 88 return false;
92 } 89 }
93 90
94 void PageState::SetIntProperty(const std::wstring& key, int value) { 91 void PageState::SetIntProperty(const std::wstring& key, int value) {
95 wchar_t buff[64]; 92 SetProperty(key, IntToWString(value));
96 _itow_s(value, buff, arraysize(buff), 10);
97 SetProperty(key, buff);
98 } 93 }
99 94
100 bool PageState::GetIntProperty(const std::wstring& key, int* value) const { 95 bool PageState::GetIntProperty(const std::wstring& key, int* value) const {
101 std::wstring v; 96 std::wstring v;
102 if (GetProperty(key, &v)) { 97 if (GetProperty(key, &v)) {
103 *value = _wtoi(v.c_str()); 98 return StringToInt(v, value);
104 return true;
105 } 99 }
106 return false; 100 return false;
107 } 101 }
108 102
109 PageState* PageState::Copy() const { 103 PageState* PageState::Copy() const {
110 PageState* copy = new PageState(); 104 PageState* copy = new PageState();
111 if (state_.get()) 105 if (state_.get())
112 copy->state_.reset(static_cast<DictionaryValue*>(state_->DeepCopy())); 106 copy->state_.reset(static_cast<DictionaryValue*>(state_->DeepCopy()));
113 return copy; 107 return copy;
114 } 108 }
115 109
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698