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

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

Issue 8276023: IndexedDB: Wrong exception types thrown for invalid keys (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updated copyright years Created 9 years, 1 month 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 | « content/common/indexed_db_key.h ('k') | content/common/indexed_db_param_traits.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/common/indexed_db_key.h" 5 #include "content/common/indexed_db_key.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
9 9
10 using WebKit::WebIDBKey; 10 using WebKit::WebIDBKey;
11 11
12 IndexedDBKey::IndexedDBKey() 12 IndexedDBKey::IndexedDBKey()
13 : type_(WebIDBKey::InvalidType), 13 : type_(WebIDBKey::InvalidType),
14 date_(0), 14 date_(0),
15 number_(0) { 15 number_(0) {
16 } 16 }
17 17
18 IndexedDBKey::IndexedDBKey(const WebIDBKey& key) { 18 IndexedDBKey::IndexedDBKey(const WebIDBKey& key) {
19 Set(key); 19 Set(key);
20 } 20 }
21 21
22 IndexedDBKey::~IndexedDBKey() { 22 IndexedDBKey::~IndexedDBKey() {
23 } 23 }
24 24
25 void IndexedDBKey::SetNull() {
26 type_ = WebIDBKey::NullType;
27 }
28
29 void IndexedDBKey::SetInvalid() { 25 void IndexedDBKey::SetInvalid() {
30 type_ = WebIDBKey::InvalidType; 26 type_ = WebIDBKey::InvalidType;
31 } 27 }
32 28
33 void IndexedDBKey::SetString(const string16& string) { 29 void IndexedDBKey::SetString(const string16& string) {
34 type_ = WebIDBKey::StringType; 30 type_ = WebIDBKey::StringType;
35 string_ = string; 31 string_ = string;
36 } 32 }
37 33
38 void IndexedDBKey::SetDate(double date) { 34 void IndexedDBKey::SetDate(double date) {
39 type_ = WebIDBKey::DateType; 35 type_ = WebIDBKey::DateType;
40 date_ = date; 36 date_ = date;
41 } 37 }
42 38
43 void IndexedDBKey::SetNumber(double number) { 39 void IndexedDBKey::SetNumber(double number) {
44 type_ = WebIDBKey::NumberType; 40 type_ = WebIDBKey::NumberType;
45 number_ = number; 41 number_ = number;
46 } 42 }
47 43
48 void IndexedDBKey::Set(const WebIDBKey& key) { 44 void IndexedDBKey::Set(const WebIDBKey& key) {
49 type_ = key.type(); 45 type_ = key.type();
50 string_ = key.type() == WebIDBKey::StringType ? 46 string_ = key.type() == WebIDBKey::StringType ?
51 static_cast<string16>(key.string()) : string16(); 47 static_cast<string16>(key.string()) : string16();
52 number_ = key.type() == WebIDBKey::NumberType ? key.number() : 0; 48 number_ = key.type() == WebIDBKey::NumberType ? key.number() : 0;
53 date_ = key.type() == WebIDBKey::DateType ? key.date() : 0; 49 date_ = key.type() == WebIDBKey::DateType ? key.date() : 0;
54 } 50 }
55 51
56 IndexedDBKey::operator WebIDBKey() const { 52 IndexedDBKey::operator WebIDBKey() const {
57 switch (type_) { 53 switch (type_) {
58 case WebIDBKey::NullType:
59 return WebIDBKey::createNull();
60 case WebIDBKey::StringType: 54 case WebIDBKey::StringType:
61 return WebIDBKey::createString(string_); 55 return WebIDBKey::createString(string_);
62 case WebIDBKey::DateType: 56 case WebIDBKey::DateType:
63 return WebIDBKey::createDate(date_); 57 return WebIDBKey::createDate(date_);
64 case WebIDBKey::NumberType: 58 case WebIDBKey::NumberType:
65 return WebIDBKey::createNumber(number_); 59 return WebIDBKey::createNumber(number_);
66 case WebIDBKey::InvalidType: 60 case WebIDBKey::InvalidType:
61 default: // TODO(jsbell): Remove this case label once NullType is gone
67 return WebIDBKey::createInvalid(); 62 return WebIDBKey::createInvalid();
68 } 63 }
69 NOTREACHED(); 64 NOTREACHED();
70 return WebIDBKey::createInvalid(); 65 return WebIDBKey::createInvalid();
71 } 66 }
OLDNEW
« no previous file with comments | « content/common/indexed_db_key.h ('k') | content/common/indexed_db_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698