| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/indexed_db_key.h" | 5 #include "content/common/indexed_db/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/platform/WebString.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 10 | 10 |
| 11 using WebKit::WebIDBKey; | 11 using WebKit::WebIDBKey; |
| 12 | 12 |
| 13 IndexedDBKey::IndexedDBKey() | 13 IndexedDBKey::IndexedDBKey() |
| 14 : type_(WebIDBKey::InvalidType), | 14 : type_(WebIDBKey::NullType), |
| 15 date_(0), | 15 date_(0), |
| 16 number_(0) { | 16 number_(0) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 IndexedDBKey::IndexedDBKey(const WebIDBKey& key) { | 19 IndexedDBKey::IndexedDBKey(const WebIDBKey& key) { |
| 20 Set(key); | 20 Set(key); |
| 21 } | 21 } |
| 22 | 22 |
| 23 IndexedDBKey::~IndexedDBKey() { | 23 IndexedDBKey::~IndexedDBKey() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 void IndexedDBKey::SetInvalid() { | 26 void IndexedDBKey::SetInvalid() { |
| 27 type_ = WebIDBKey::InvalidType; | 27 type_ = WebIDBKey::InvalidType; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void IndexedDBKey::SetNull() { |
| 31 type_ = WebIDBKey::NullType; |
| 32 } |
| 33 |
| 30 void IndexedDBKey::SetArray(const std::vector<IndexedDBKey>& array) { | 34 void IndexedDBKey::SetArray(const std::vector<IndexedDBKey>& array) { |
| 31 type_ = WebIDBKey::ArrayType; | 35 type_ = WebIDBKey::ArrayType; |
| 32 array_ = array; | 36 array_ = array; |
| 33 } | 37 } |
| 34 | 38 |
| 35 void IndexedDBKey::SetString(const string16& string) { | 39 void IndexedDBKey::SetString(const string16& string) { |
| 36 type_ = WebIDBKey::StringType; | 40 type_ = WebIDBKey::StringType; |
| 37 string_ = string; | 41 string_ = string; |
| 38 } | 42 } |
| 39 | 43 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 65 switch (type_) { | 69 switch (type_) { |
| 66 case WebIDBKey::ArrayType: | 70 case WebIDBKey::ArrayType: |
| 67 return WebIDBKey::createArray(array_); | 71 return WebIDBKey::createArray(array_); |
| 68 case WebIDBKey::StringType: | 72 case WebIDBKey::StringType: |
| 69 return WebIDBKey::createString(string_); | 73 return WebIDBKey::createString(string_); |
| 70 case WebIDBKey::DateType: | 74 case WebIDBKey::DateType: |
| 71 return WebIDBKey::createDate(date_); | 75 return WebIDBKey::createDate(date_); |
| 72 case WebIDBKey::NumberType: | 76 case WebIDBKey::NumberType: |
| 73 return WebIDBKey::createNumber(number_); | 77 return WebIDBKey::createNumber(number_); |
| 74 case WebIDBKey::InvalidType: | 78 case WebIDBKey::InvalidType: |
| 75 default: | |
| 76 // TODO(jsbell): Remove "default" label once WebKit bug 76487 has rolled. | |
| 77 // http://crbug.com/110956 | |
| 78 return WebIDBKey::createInvalid(); | 79 return WebIDBKey::createInvalid(); |
| 80 case WebIDBKey::NullType: |
| 81 return WebIDBKey::createNull(); |
| 79 } | 82 } |
| 80 NOTREACHED(); | 83 NOTREACHED(); |
| 81 return WebIDBKey::createInvalid(); | 84 return WebIDBKey::createInvalid(); |
| 82 } | 85 } |
| OLD | NEW |