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

Side by Side Diff: content/common/indexed_db/proxy_webidbdatabase_impl.cc

Issue 10533057: IPC plumbing for IndexedDB to snapshot metadata to the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplified naming on WK side Created 8 years, 6 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
« no previous file with comments | « content/common/indexed_db/proxy_webidbdatabase_impl.h ('k') | no next file » | 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) 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/proxy_webidbdatabase_impl.h" 5 #include "content/common/indexed_db/proxy_webidbdatabase_impl.h"
6 6
7 #include "content/common/child_thread.h" 7 #include "content/common/child_thread.h"
8 #include "content/common/indexed_db/indexed_db_messages.h" 8 #include "content/common/indexed_db/indexed_db_messages.h"
9 #include "content/common/indexed_db/indexed_db_dispatcher.h" 9 #include "content/common/indexed_db/indexed_db_dispatcher.h"
10 #include "content/common/indexed_db/proxy_webidbobjectstore_impl.h" 10 #include "content/common/indexed_db/proxy_webidbobjectstore_impl.h"
11 #include "content/common/indexed_db/proxy_webidbtransaction_impl.h" 11 #include "content/common/indexed_db/proxy_webidbtransaction_impl.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
15 #include "webkit/glue/worker_task_runner.h" 16 #include "webkit/glue/worker_task_runner.h"
16 17
17 using WebKit::WebDOMStringList; 18 using WebKit::WebDOMStringList;
18 using WebKit::WebExceptionCode; 19 using WebKit::WebExceptionCode;
19 using WebKit::WebFrame; 20 using WebKit::WebFrame;
20 using WebKit::WebIDBCallbacks; 21 using WebKit::WebIDBCallbacks;
21 using WebKit::WebIDBDatabaseCallbacks; 22 using WebKit::WebIDBDatabaseCallbacks;
23 using WebKit::WebIDBMetadata;
22 using WebKit::WebIDBKeyPath; 24 using WebKit::WebIDBKeyPath;
23 using WebKit::WebIDBTransaction; 25 using WebKit::WebIDBTransaction;
24 using WebKit::WebString; 26 using WebKit::WebString;
25 using WebKit::WebVector; 27 using WebKit::WebVector;
26 using webkit_glue::WorkerTaskRunner; 28 using webkit_glue::WorkerTaskRunner;
27 29
28 RendererWebIDBDatabaseImpl::RendererWebIDBDatabaseImpl(int32 idb_database_id) 30 RendererWebIDBDatabaseImpl::RendererWebIDBDatabaseImpl(int32 idb_database_id)
29 : idb_database_id_(idb_database_id) { 31 : idb_database_id_(idb_database_id) {
30 } 32 }
31 33
32 RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() { 34 RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() {
33 // It's not possible for there to be pending callbacks that address this 35 // It's not possible for there to be pending callbacks that address this
34 // object since inside WebKit, they hold a reference to the object which owns 36 // object since inside WebKit, they hold a reference to the object which owns
35 // this object. But, if that ever changed, then we'd need to invalidate 37 // this object. But, if that ever changed, then we'd need to invalidate
36 // any such pointers. 38 // any such pointers.
37 IndexedDBDispatcher::Send(new IndexedDBHostMsg_DatabaseDestroyed( 39 IndexedDBDispatcher::Send(new IndexedDBHostMsg_DatabaseDestroyed(
38 idb_database_id_)); 40 idb_database_id_));
39 } 41 }
40 42
43 WebIDBMetadata RendererWebIDBDatabaseImpl::metadata() const {
44 IndexedDBDatabaseMetadata idb_metadata;
45 IndexedDBDispatcher::Send(
46 new IndexedDBHostMsg_DatabaseMetadata(idb_database_id_, &idb_metadata));
47
48 WebIDBMetadata web_metadata;
49 web_metadata.name = idb_metadata.name;
50 web_metadata.version = idb_metadata.version;
51 web_metadata.objectStores = WebVector<WebIDBMetadata::ObjectStore>(
52 idb_metadata.object_stores.size());
53
54 for (size_t i = 0; i < idb_metadata.object_stores.size(); ++i) {
55 const IndexedDBObjectStoreMetadata& idb_store_metadata =
56 idb_metadata.object_stores[i];
57 WebIDBMetadata::ObjectStore& web_store_metadata =
58 web_metadata.objectStores[i];
59
60 web_store_metadata.name = idb_store_metadata.name;
61 web_store_metadata.keyPath = idb_store_metadata.keyPath;
62 web_store_metadata.autoIncrement = idb_store_metadata.autoIncrement;
63 web_store_metadata.indexes = WebVector<WebIDBMetadata::Index>(
64 idb_store_metadata.indexes.size());
65
66 for (size_t j = 0; j < idb_store_metadata.indexes.size(); ++j) {
67 const IndexedDBIndexMetadata& idb_index_metadata =
68 idb_store_metadata.indexes[j];
69 WebIDBMetadata::Index& web_index_metadata =
70 web_store_metadata.indexes[j];
71
72 web_index_metadata.name = idb_index_metadata.name;
73 web_index_metadata.keyPath = idb_index_metadata.keyPath;
74 web_index_metadata.unique = idb_index_metadata.unique;
75 web_index_metadata.multiEntry = idb_index_metadata.multiEntry;
76 }
77 }
78
79 return web_metadata;
80 }
81
41 WebString RendererWebIDBDatabaseImpl::name() const { 82 WebString RendererWebIDBDatabaseImpl::name() const {
42 string16 result; 83 string16 result;
43 IndexedDBDispatcher::Send( 84 IndexedDBDispatcher::Send(
44 new IndexedDBHostMsg_DatabaseName(idb_database_id_, &result)); 85 new IndexedDBHostMsg_DatabaseName(idb_database_id_, &result));
45 return result; 86 return result;
46 } 87 }
47 88
48 WebString RendererWebIDBDatabaseImpl::version() const { 89 WebString RendererWebIDBDatabaseImpl::version() const {
49 string16 result; 90 string16 result;
50 IndexedDBDispatcher::Send( 91 IndexedDBDispatcher::Send(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 IndexedDBDispatcher::ThreadSpecificInstance(); 170 IndexedDBDispatcher::ThreadSpecificInstance();
130 dispatcher->RequestIDBDatabaseClose(idb_database_id_); 171 dispatcher->RequestIDBDatabaseClose(idb_database_id_);
131 } 172 }
132 173
133 void RendererWebIDBDatabaseImpl::open(WebIDBDatabaseCallbacks* callbacks) { 174 void RendererWebIDBDatabaseImpl::open(WebIDBDatabaseCallbacks* callbacks) {
134 IndexedDBDispatcher* dispatcher = 175 IndexedDBDispatcher* dispatcher =
135 IndexedDBDispatcher::ThreadSpecificInstance(); 176 IndexedDBDispatcher::ThreadSpecificInstance();
136 DCHECK(dispatcher); 177 DCHECK(dispatcher);
137 dispatcher->RequestIDBDatabaseOpen(callbacks, idb_database_id_); 178 dispatcher->RequestIDBDatabaseOpen(callbacks, idb_database_id_);
138 } 179 }
OLDNEW
« no previous file with comments | « content/common/indexed_db/proxy_webidbdatabase_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698