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

Side by Side Diff: WebCore/storage/IDBKey.cpp

Issue 5800002: Merge 73697 - 2010-12-10 Hans Wennborg <hans@chromium.org>... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/597/
Patch Set: Created 10 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
« no previous file with comments | « WebCore/storage/IDBKey.h ('k') | WebKit/chromium/ChangeLog » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 #include "SQLiteStatement.h" 31 #include "SQLiteStatement.h"
32 #include "SerializedScriptValue.h" 32 #include "SerializedScriptValue.h"
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 IDBKey::IDBKey() 36 IDBKey::IDBKey()
37 : m_type(NullType) 37 : m_type(NullType)
38 { 38 {
39 } 39 }
40 40
41 IDBKey::IDBKey(int32_t number) 41 IDBKey::IDBKey(double number)
42 : m_type(NumberType) 42 : m_type(NumberType)
43 , m_number(number) 43 , m_number(number)
44 { 44 {
45 } 45 }
46 46
47 IDBKey::IDBKey(const String& string) 47 IDBKey::IDBKey(const String& string)
48 : m_type(StringType) 48 : m_type(StringType)
49 , m_string(string.crossThreadString()) 49 , m_string(string.crossThreadString())
50 { 50 {
51 } 51 }
52 52
53 IDBKey::~IDBKey() 53 IDBKey::~IDBKey()
54 { 54 {
55 } 55 }
56 56
57 PassRefPtr<IDBKey> IDBKey::fromQuery(SQLiteStatement& query, int baseColumn) 57 PassRefPtr<IDBKey> IDBKey::fromQuery(SQLiteStatement& query, int baseColumn)
58 { 58 {
59 if (!query.isColumnNull(baseColumn)) 59 if (!query.isColumnNull(baseColumn))
60 return IDBKey::create(query.getColumnText(baseColumn)); 60 return IDBKey::create(query.getColumnText(baseColumn));
61 61
62 if (!query.isColumnNull(baseColumn + 1)) { 62 if (!query.isColumnNull(baseColumn + 1)) {
63 ASSERT_NOT_REACHED(); // FIXME: Implement date. 63 ASSERT_NOT_REACHED(); // FIXME: Implement date.
64 return IDBKey::create(); 64 return IDBKey::create();
65 } 65 }
66 66
67 if (!query.isColumnNull(baseColumn + 2)) 67 if (!query.isColumnNull(baseColumn + 2))
68 return IDBKey::create(query.getColumnInt(baseColumn + 2)); 68 return IDBKey::create(query.getColumnDouble(baseColumn + 2));
69 69
70 return IDBKey::create(); // Null. 70 return IDBKey::create(); // Null.
71 } 71 }
72 72
73 bool IDBKey::isEqual(IDBKey* other) 73 bool IDBKey::isEqual(IDBKey* other)
74 { 74 {
75 if (!other || other->m_type != m_type) 75 if (!other || other->m_type != m_type)
76 return false; 76 return false;
77 77
78 switch (m_type) { 78 switch (m_type) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 141
142 // Returns the number of items bound. 142 // Returns the number of items bound.
143 int IDBKey::bind(SQLiteStatement& query, int column) const 143 int IDBKey::bind(SQLiteStatement& query, int column) const
144 { 144 {
145 switch (m_type) { 145 switch (m_type) {
146 case IDBKey::StringType: 146 case IDBKey::StringType:
147 query.bindText(column, m_string); 147 query.bindText(column, m_string);
148 return 1; 148 return 1;
149 case IDBKey::NumberType: 149 case IDBKey::NumberType:
150 query.bindInt(column, m_number); 150 query.bindDouble(column, m_number);
151 return 1; 151 return 1;
152 case IDBKey::NullType: 152 case IDBKey::NullType:
153 return 0; 153 return 0;
154 } 154 }
155 155
156 ASSERT_NOT_REACHED(); 156 ASSERT_NOT_REACHED();
157 return 0; 157 return 0;
158 } 158 }
159 159
160 void IDBKey::bindWithNulls(SQLiteStatement& query, int baseColumn) const 160 void IDBKey::bindWithNulls(SQLiteStatement& query, int baseColumn) const
161 { 161 {
162 switch (m_type) { 162 switch (m_type) {
163 case IDBKey::StringType: 163 case IDBKey::StringType:
164 query.bindText(baseColumn + 0, m_string); 164 query.bindText(baseColumn + 0, m_string);
165 query.bindNull(baseColumn + 1); 165 query.bindNull(baseColumn + 1);
166 query.bindNull(baseColumn + 2); 166 query.bindNull(baseColumn + 2);
167 break; 167 break;
168 case IDBKey::NumberType: 168 case IDBKey::NumberType:
169 query.bindNull(baseColumn + 0); 169 query.bindNull(baseColumn + 0);
170 query.bindNull(baseColumn + 1); 170 query.bindNull(baseColumn + 1);
171 query.bindInt(baseColumn + 2, m_number); 171 query.bindDouble(baseColumn + 2, m_number);
172 break; 172 break;
173 case IDBKey::NullType: 173 case IDBKey::NullType:
174 query.bindNull(baseColumn + 0); 174 query.bindNull(baseColumn + 0);
175 query.bindNull(baseColumn + 1); 175 query.bindNull(baseColumn + 1);
176 query.bindNull(baseColumn + 2); 176 query.bindNull(baseColumn + 2);
177 break; 177 break;
178 default: 178 default:
179 ASSERT_NOT_REACHED(); 179 ASSERT_NOT_REACHED();
180 } 180 }
181 } 181 }
182 182
183 } // namespace WebCore 183 } // namespace WebCore
184 184
185 #endif 185 #endif
OLDNEW
« no previous file with comments | « WebCore/storage/IDBKey.h ('k') | WebKit/chromium/ChangeLog » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698