OLD | NEW |
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/renderer/renderer_webidbdatabase_impl.h" | 5 #include "chrome/renderer/renderer_webidbdatabase_impl.h" |
6 | 6 |
7 #include "chrome/common/render_messages.h" | 7 #include "chrome/common/indexed_db_messages.h" |
8 #include "chrome/common/render_messages_params.h" | |
9 #include "chrome/renderer/render_thread.h" | 8 #include "chrome/renderer/render_thread.h" |
10 #include "chrome/renderer/indexed_db_dispatcher.h" | 9 #include "chrome/renderer/indexed_db_dispatcher.h" |
11 #include "chrome/renderer/renderer_webidbobjectstore_impl.h" | 10 #include "chrome/renderer/renderer_webidbobjectstore_impl.h" |
12 #include "chrome/renderer/renderer_webidbtransaction_impl.h" | 11 #include "chrome/renderer/renderer_webidbtransaction_impl.h" |
13 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
| 13 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" |
14 | 14 |
15 using WebKit::WebDOMStringList; | 15 using WebKit::WebDOMStringList; |
16 using WebKit::WebExceptionCode; | 16 using WebKit::WebExceptionCode; |
17 using WebKit::WebFrame; | 17 using WebKit::WebFrame; |
18 using WebKit::WebIDBCallbacks; | 18 using WebKit::WebIDBCallbacks; |
19 using WebKit::WebIDBTransaction; | 19 using WebKit::WebIDBTransaction; |
20 using WebKit::WebString; | 20 using WebKit::WebString; |
21 using WebKit::WebVector; | 21 using WebKit::WebVector; |
22 | 22 |
23 RendererWebIDBDatabaseImpl::RendererWebIDBDatabaseImpl(int32 idb_database_id) | 23 RendererWebIDBDatabaseImpl::RendererWebIDBDatabaseImpl(int32 idb_database_id) |
24 : idb_database_id_(idb_database_id) { | 24 : idb_database_id_(idb_database_id) { |
25 } | 25 } |
26 | 26 |
27 RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() { | 27 RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() { |
28 // TODO(jorlow): Is it possible for this to be destroyed but still have | 28 // TODO(jorlow): Is it possible for this to be destroyed but still have |
29 // pending callbacks? If so, fix! | 29 // pending callbacks? If so, fix! |
30 RenderThread::current()->Send(new ViewHostMsg_IDBDatabaseDestroyed( | 30 RenderThread::current()->Send(new IndexedDBHostMsg_DatabaseDestroyed( |
31 idb_database_id_)); | 31 idb_database_id_)); |
32 } | 32 } |
33 | 33 |
34 WebString RendererWebIDBDatabaseImpl::name() const { | 34 WebString RendererWebIDBDatabaseImpl::name() const { |
35 string16 result; | 35 string16 result; |
36 RenderThread::current()->Send( | 36 RenderThread::current()->Send( |
37 new ViewHostMsg_IDBDatabaseName(idb_database_id_, &result)); | 37 new IndexedDBHostMsg_DatabaseName(idb_database_id_, &result)); |
38 return result; | 38 return result; |
39 } | 39 } |
40 | 40 |
41 WebString RendererWebIDBDatabaseImpl::version() const { | 41 WebString RendererWebIDBDatabaseImpl::version() const { |
42 string16 result; | 42 string16 result; |
43 RenderThread::current()->Send( | 43 RenderThread::current()->Send( |
44 new ViewHostMsg_IDBDatabaseVersion(idb_database_id_, &result)); | 44 new IndexedDBHostMsg_DatabaseVersion(idb_database_id_, &result)); |
45 return result; | 45 return result; |
46 } | 46 } |
47 | 47 |
48 WebDOMStringList RendererWebIDBDatabaseImpl::objectStoreNames() const { | 48 WebDOMStringList RendererWebIDBDatabaseImpl::objectStoreNames() const { |
49 std::vector<string16> result; | 49 std::vector<string16> result; |
50 RenderThread::current()->Send( | 50 RenderThread::current()->Send( |
51 new ViewHostMsg_IDBDatabaseObjectStoreNames(idb_database_id_, &result)); | 51 new IndexedDBHostMsg_DatabaseObjectStoreNames(idb_database_id_, &result)); |
52 WebDOMStringList webResult; | 52 WebDOMStringList webResult; |
53 for (std::vector<string16>::const_iterator it = result.begin(); | 53 for (std::vector<string16>::const_iterator it = result.begin(); |
54 it != result.end(); ++it) { | 54 it != result.end(); ++it) { |
55 webResult.append(*it); | 55 webResult.append(*it); |
56 } | 56 } |
57 return webResult; | 57 return webResult; |
58 } | 58 } |
59 | 59 |
60 WebKit::WebIDBObjectStore* RendererWebIDBDatabaseImpl::createObjectStore( | 60 WebKit::WebIDBObjectStore* RendererWebIDBDatabaseImpl::createObjectStore( |
61 const WebKit::WebString& name, | 61 const WebKit::WebString& name, |
62 const WebKit::WebString& key_path, | 62 const WebKit::WebString& key_path, |
63 bool auto_increment, | 63 bool auto_increment, |
64 const WebKit::WebIDBTransaction& transaction, | 64 const WebKit::WebIDBTransaction& transaction, |
65 WebExceptionCode& ec) { | 65 WebExceptionCode& ec) { |
66 ViewHostMsg_IDBDatabaseCreateObjectStore_Params params; | 66 IndexedDBHostMsg_DatabaseCreateObjectStore_Params params; |
67 params.name_ = name; | 67 params.name = name; |
68 params.key_path_ = key_path; | 68 params.key_path = key_path; |
69 params.auto_increment_ = auto_increment; | 69 params.auto_increment = auto_increment; |
70 params.transaction_id_ = IndexedDBDispatcher::TransactionId(transaction); | 70 params.transaction_id = IndexedDBDispatcher::TransactionId(transaction); |
71 params.idb_database_id_ = idb_database_id_; | 71 params.idb_database_id = idb_database_id_; |
72 | 72 |
73 int object_store; | 73 int object_store; |
74 RenderThread::current()->Send( | 74 RenderThread::current()->Send( |
75 new ViewHostMsg_IDBDatabaseCreateObjectStore(params, &object_store, &ec)); | 75 new IndexedDBHostMsg_DatabaseCreateObjectStore(params, &object_store, &ec)
); |
76 if (!object_store) | 76 if (!object_store) |
77 return NULL; | 77 return NULL; |
78 return new RendererWebIDBObjectStoreImpl(object_store); | 78 return new RendererWebIDBObjectStoreImpl(object_store); |
79 } | 79 } |
80 | 80 |
81 void RendererWebIDBDatabaseImpl::deleteObjectStore( | 81 void RendererWebIDBDatabaseImpl::deleteObjectStore( |
82 const WebString& name, | 82 const WebString& name, |
83 const WebIDBTransaction& transaction, | 83 const WebIDBTransaction& transaction, |
84 WebExceptionCode& ec) { | 84 WebExceptionCode& ec) { |
85 RenderThread::current()->Send( | 85 RenderThread::current()->Send( |
86 new ViewHostMsg_IDBDatabaseDeleteObjectStore( | 86 new IndexedDBHostMsg_DatabaseDeleteObjectStore( |
87 idb_database_id_, name, | 87 idb_database_id_, name, |
88 IndexedDBDispatcher::TransactionId(transaction), &ec)); | 88 IndexedDBDispatcher::TransactionId(transaction), &ec)); |
89 } | 89 } |
90 | 90 |
91 void RendererWebIDBDatabaseImpl::setVersion( | 91 void RendererWebIDBDatabaseImpl::setVersion( |
92 const WebString& version, | 92 const WebString& version, |
93 WebIDBCallbacks* callbacks, | 93 WebIDBCallbacks* callbacks, |
94 WebExceptionCode& ec) { | 94 WebExceptionCode& ec) { |
95 IndexedDBDispatcher* dispatcher = | 95 IndexedDBDispatcher* dispatcher = |
96 RenderThread::current()->indexed_db_dispatcher(); | 96 RenderThread::current()->indexed_db_dispatcher(); |
97 dispatcher->RequestIDBDatabaseSetVersion( | 97 dispatcher->RequestIDBDatabaseSetVersion( |
98 version, callbacks, idb_database_id_, &ec); | 98 version, callbacks, idb_database_id_, &ec); |
99 } | 99 } |
100 | 100 |
101 WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::transaction( | 101 WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::transaction( |
102 const WebDOMStringList& names, | 102 const WebDOMStringList& names, |
103 unsigned short mode, | 103 unsigned short mode, |
104 unsigned long timeout, | 104 unsigned long timeout, |
105 WebExceptionCode& ec) { | 105 WebExceptionCode& ec) { |
106 std::vector<string16> object_stores; | 106 std::vector<string16> object_stores; |
107 object_stores.reserve(names.length()); | 107 object_stores.reserve(names.length()); |
108 for (unsigned int i = 0; i < names.length(); ++i) | 108 for (unsigned int i = 0; i < names.length(); ++i) |
109 object_stores.push_back(names.item(i)); | 109 object_stores.push_back(names.item(i)); |
110 | 110 |
111 int transaction_id; | 111 int transaction_id; |
112 RenderThread::current()->Send( | 112 RenderThread::current()->Send( |
113 new ViewHostMsg_IDBDatabaseTransaction( | 113 new IndexedDBHostMsg_DatabaseTransaction( |
114 idb_database_id_, object_stores, mode, | 114 idb_database_id_, object_stores, mode, |
115 timeout, &transaction_id, &ec)); | 115 timeout, &transaction_id, &ec)); |
116 if (!transaction_id) | 116 if (!transaction_id) |
117 return NULL; | 117 return NULL; |
118 return new RendererWebIDBTransactionImpl(transaction_id); | 118 return new RendererWebIDBTransactionImpl(transaction_id); |
119 } | 119 } |
OLD | NEW |