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

Side by Side Diff: chrome/common/indexed_db_key.cc

Issue 5695002: IndexedDB: Numeric keys are floating point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/common/indexed_db_key.h" 5 #include "chrome/common/indexed_db_key.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 8 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
9 9
10 using WebKit::WebIDBKey; 10 using WebKit::WebIDBKey;
(...skipping 16 matching lines...) Expand all
27 27
28 void IndexedDBKey::SetInvalid() { 28 void IndexedDBKey::SetInvalid() {
29 type_ = WebIDBKey::InvalidType; 29 type_ = WebIDBKey::InvalidType;
30 } 30 }
31 31
32 void IndexedDBKey::Set(const string16& string) { 32 void IndexedDBKey::Set(const string16& string) {
33 type_ = WebIDBKey::StringType; 33 type_ = WebIDBKey::StringType;
34 string_ = string; 34 string_ = string;
35 } 35 }
36 36
37 void IndexedDBKey::Set(int32_t number) { 37 void IndexedDBKey::Set(double number) {
38 type_ = WebIDBKey::NumberType; 38 type_ = WebIDBKey::NumberType;
39 number_ = number; 39 number_ = number;
40 } 40 }
41 41
42 void IndexedDBKey::Set(const WebIDBKey& key) { 42 void IndexedDBKey::Set(const WebIDBKey& key) {
43 type_ = key.type(); 43 type_ = key.type();
44 string_ = key.type() == WebIDBKey::StringType ? 44 string_ = key.type() == WebIDBKey::StringType ?
45 static_cast<string16>(key.string()) : string16(); 45 static_cast<string16>(key.string()) : string16();
46 number_ = key.type() == WebIDBKey::NumberType ? key.number() : 0; 46 number_ = key.type() == WebIDBKey::NumberType ? key.number() : 0;
47 } 47 }
48 48
49 IndexedDBKey::operator WebIDBKey() const { 49 IndexedDBKey::operator WebIDBKey() const {
50 switch (type_) { 50 switch (type_) {
51 case WebIDBKey::NullType: 51 case WebIDBKey::NullType:
52 return WebIDBKey::createNull(); 52 return WebIDBKey::createNull();
53 case WebIDBKey::StringType: 53 case WebIDBKey::StringType:
54 return WebIDBKey(string_); 54 return WebIDBKey(string_);
55 case WebIDBKey::NumberType: 55 case WebIDBKey::NumberType:
56 return WebIDBKey(number_); 56 return WebIDBKey(number_);
57 case WebIDBKey::InvalidType: 57 case WebIDBKey::InvalidType:
58 return WebIDBKey::createInvalid(); 58 return WebIDBKey::createInvalid();
59 } 59 }
60 NOTREACHED(); 60 NOTREACHED();
61 return WebIDBKey::createInvalid(); 61 return WebIDBKey::createInvalid();
62 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698