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

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

Issue 8980002: Move indexeddb code to its own directory inside of content/{browser,common,renderer} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase onto ToT Created 9 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
« no previous file with comments | « content/common/indexed_db_key.h ('k') | content/common/indexed_db_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/common/indexed_db_key.h"
6
7 #include "base/logging.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"
10
11 using WebKit::WebIDBKey;
12
13 IndexedDBKey::IndexedDBKey()
14 : type_(WebIDBKey::InvalidType),
15 date_(0),
16 number_(0) {
17 }
18
19 IndexedDBKey::IndexedDBKey(const WebIDBKey& key) {
20 Set(key);
21 }
22
23 IndexedDBKey::~IndexedDBKey() {
24 }
25
26 void IndexedDBKey::SetInvalid() {
27 type_ = WebIDBKey::InvalidType;
28 }
29
30 void IndexedDBKey::SetArray(const std::vector<IndexedDBKey>& array) {
31 type_ = WebIDBKey::ArrayType;
32 array_ = array;
33 }
34
35 void IndexedDBKey::SetString(const string16& string) {
36 type_ = WebIDBKey::StringType;
37 string_ = string;
38 }
39
40 void IndexedDBKey::SetDate(double date) {
41 type_ = WebIDBKey::DateType;
42 date_ = date;
43 }
44
45 void IndexedDBKey::SetNumber(double number) {
46 type_ = WebIDBKey::NumberType;
47 number_ = number;
48 }
49
50 void IndexedDBKey::Set(const WebIDBKey& key) {
51 type_ = key.type();
52 array_.clear();
53 if (key.type() == WebIDBKey::ArrayType) {
54 for (size_t i = 0; i < key.array().size(); ++i) {
55 array_.push_back(IndexedDBKey(key.array()[i]));
56 }
57 }
58 string_ = key.type() == WebIDBKey::StringType ?
59 static_cast<string16>(key.string()) : string16();
60 number_ = key.type() == WebIDBKey::NumberType ? key.number() : 0;
61 date_ = key.type() == WebIDBKey::DateType ? key.date() : 0;
62 }
63
64 IndexedDBKey::operator WebIDBKey() const {
65 switch (type_) {
66 case WebIDBKey::ArrayType:
67 return WebIDBKey::createArray(array_);
68 case WebIDBKey::StringType:
69 return WebIDBKey::createString(string_);
70 case WebIDBKey::DateType:
71 return WebIDBKey::createDate(date_);
72 case WebIDBKey::NumberType:
73 return WebIDBKey::createNumber(number_);
74 case WebIDBKey::InvalidType:
75 return WebIDBKey::createInvalid();
76 }
77 NOTREACHED();
78 return WebIDBKey::createInvalid();
79 }
OLDNEW
« no previous file with comments | « content/common/indexed_db_key.h ('k') | content/common/indexed_db_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698