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

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

Issue 6672057: Move all the message files in chrome that belong in content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/common/indexed_db_key.h"
6
7 #include "base/logging.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
9
10 using WebKit::WebIDBKey;
11
12 IndexedDBKey::IndexedDBKey()
13 : type_(WebIDBKey::InvalidType),
14 date_(0),
15 number_(0) {
16 }
17
18 IndexedDBKey::IndexedDBKey(const WebIDBKey& key) {
19 Set(key);
20 }
21
22 IndexedDBKey::~IndexedDBKey() {
23 }
24
25 void IndexedDBKey::SetNull() {
26 type_ = WebIDBKey::NullType;
27 }
28
29 void IndexedDBKey::SetInvalid() {
30 type_ = WebIDBKey::InvalidType;
31 }
32
33 void IndexedDBKey::SetString(const string16& string) {
34 type_ = WebIDBKey::StringType;
35 string_ = string;
36 }
37
38 void IndexedDBKey::SetDate(double date) {
39 type_ = WebIDBKey::DateType;
40 date_ = date;
41 }
42
43 void IndexedDBKey::SetNumber(double number) {
44 type_ = WebIDBKey::NumberType;
45 number_ = number;
46 }
47
48 void IndexedDBKey::Set(const WebIDBKey& key) {
49 type_ = key.type();
50 string_ = key.type() == WebIDBKey::StringType ?
51 static_cast<string16>(key.string()) : string16();
52 number_ = key.type() == WebIDBKey::NumberType ? key.number() : 0;
53 date_ = key.type() == WebIDBKey::DateType ? key.date() : 0;
54 }
55
56 IndexedDBKey::operator WebIDBKey() const {
57 switch (type_) {
58 case WebIDBKey::NullType:
59 return WebIDBKey::createNull();
60 case WebIDBKey::StringType:
61 return WebIDBKey::createString(string_);
62 case WebIDBKey::DateType:
63 return WebIDBKey::createDate(date_);
64 case WebIDBKey::NumberType:
65 return WebIDBKey::createNumber(number_);
66 case WebIDBKey::InvalidType:
67 return WebIDBKey::createInvalid();
68 }
69 NOTREACHED();
70 return WebIDBKey::createInvalid();
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698