| 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/render_messages.h" |
| 8 #include "chrome/renderer/render_thread.h" | 8 #include "chrome/renderer/render_thread.h" |
| 9 #include "chrome/renderer/indexed_db_dispatcher.h" | 9 #include "chrome/renderer/indexed_db_dispatcher.h" |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
| 11 | 11 |
| 12 using WebKit::WebDOMStringList; | 12 using WebKit::WebDOMStringList; |
| 13 using WebKit::WebFrame; | 13 using WebKit::WebFrame; |
| 14 using WebKit::WebIDBCallbacks; | 14 using WebKit::WebIDBCallbacks; |
| 15 using WebKit::WebString; | 15 using WebKit::WebString; |
| 16 using WebKit::WebVector; | 16 using WebKit::WebVector; |
| 17 | 17 |
| 18 RendererWebIDBDatabaseImpl::RendererWebIDBDatabaseImpl(int32 idb_database_id) | 18 RendererWebIDBDatabaseImpl::RendererWebIDBDatabaseImpl(int32 idb_database_id) |
| 19 : idb_database_id_(idb_database_id) { | 19 : idb_database_id_(idb_database_id) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() { | 22 RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() { |
| 23 // TODO(jorlow): Is it possible for this to be destroyed but still have | 23 // TODO(jorlow): Is it possible for this to be destroyed but still have |
| 24 // pending callbacks? If so, fix! | 24 // pending callbacks? If so, fix! |
| 25 RenderThread::current()->Send(new ViewHostMsg_IDBDatabaseDestroyed( | 25 RenderThread::current()->Send(new ViewHostMsg_IDBDatabaseDestroyed( |
| 26 idb_database_id_)); | 26 idb_database_id_)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 WebString RendererWebIDBDatabaseImpl::name() { | 29 WebString RendererWebIDBDatabaseImpl::name() const { |
| 30 string16 result; | 30 string16 result; |
| 31 RenderThread::current()->Send( | 31 RenderThread::current()->Send( |
| 32 new ViewHostMsg_IDBDatabaseName(idb_database_id_, &result)); | 32 new ViewHostMsg_IDBDatabaseName(idb_database_id_, &result)); |
| 33 return result; | 33 return result; |
| 34 } | 34 } |
| 35 | 35 |
| 36 WebString RendererWebIDBDatabaseImpl::description() { | 36 WebString RendererWebIDBDatabaseImpl::description() const { |
| 37 string16 result; | 37 string16 result; |
| 38 RenderThread::current()->Send( | 38 RenderThread::current()->Send( |
| 39 new ViewHostMsg_IDBDatabaseDescription(idb_database_id_, &result)); | 39 new ViewHostMsg_IDBDatabaseDescription(idb_database_id_, &result)); |
| 40 return result; | 40 return result; |
| 41 } | 41 } |
| 42 | 42 |
| 43 WebString RendererWebIDBDatabaseImpl::version() { | 43 WebString RendererWebIDBDatabaseImpl::version() const { |
| 44 string16 result; | 44 string16 result; |
| 45 RenderThread::current()->Send( | 45 RenderThread::current()->Send( |
| 46 new ViewHostMsg_IDBDatabaseVersion(idb_database_id_, &result)); | 46 new ViewHostMsg_IDBDatabaseVersion(idb_database_id_, &result)); |
| 47 return result; | 47 return result; |
| 48 } | 48 } |
| 49 | 49 |
| 50 WebDOMStringList RendererWebIDBDatabaseImpl::objectStores() { | 50 WebDOMStringList RendererWebIDBDatabaseImpl::objectStores() const { |
| 51 std::vector<string16> result; | 51 std::vector<string16> result; |
| 52 RenderThread::current()->Send( | 52 RenderThread::current()->Send( |
| 53 new ViewHostMsg_IDBDatabaseObjectStores(idb_database_id_, &result)); | 53 new ViewHostMsg_IDBDatabaseObjectStores(idb_database_id_, &result)); |
| 54 WebDOMStringList webResult; | 54 WebDOMStringList webResult; |
| 55 for (std::vector<string16>::const_iterator it = result.begin(); | 55 for (std::vector<string16>::const_iterator it = result.begin(); |
| 56 it != result.end(); ++it) { | 56 it != result.end(); ++it) { |
| 57 webResult.append(*it); | 57 webResult.append(*it); |
| 58 } | 58 } |
| 59 return webResult; | 59 return webResult; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void RendererWebIDBDatabaseImpl::createObjectStore( | 62 void RendererWebIDBDatabaseImpl::createObjectStore( |
| 63 const WebString& name, const WebString& key_path, bool auto_increment, | 63 const WebString& name, const WebString& key_path, bool auto_increment, |
| 64 WebIDBCallbacks* callbacks) { | 64 WebIDBCallbacks* callbacks) { |
| 65 IndexedDBDispatcher* dispatcher = | 65 IndexedDBDispatcher* dispatcher = |
| 66 RenderThread::current()->indexed_db_dispatcher(); | 66 RenderThread::current()->indexed_db_dispatcher(); |
| 67 dispatcher->RequestIDBDatabaseCreateObjectStore( | 67 dispatcher->RequestIDBDatabaseCreateObjectStore( |
| 68 name, key_path, auto_increment, callbacks, idb_database_id_); | 68 name, key_path, auto_increment, callbacks, idb_database_id_); |
| 69 } | 69 } |
| OLD | NEW |