| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #include "config.h" | |
| 32 #include "WebDatabase.h" | |
| 33 | |
| 34 #include "Database.h" | |
| 35 #include "DatabaseThread.h" | |
| 36 #include "Document.h" | |
| 37 #include "KURL.h" | |
| 38 #include "SecurityOrigin.h" | |
| 39 #include "WebDatabaseObserver.h" | |
| 40 #include "WebString.h" | |
| 41 #include <wtf/PassRefPtr.h> | |
| 42 #include <wtf/RefPtr.h> | |
| 43 | |
| 44 using namespace WebCore; | |
| 45 | |
| 46 namespace WebKit { | |
| 47 | |
| 48 static WebDatabaseObserver* databaseObserver = 0; | |
| 49 | |
| 50 class WebDatabasePrivate : public Database { | |
| 51 }; | |
| 52 | |
| 53 void WebDatabase::reset() | |
| 54 { | |
| 55 assign(0); | |
| 56 } | |
| 57 | |
| 58 void WebDatabase::assign(const WebDatabase& other) | |
| 59 { | |
| 60 WebDatabasePrivate* d = const_cast<WebDatabasePrivate*>(other.m_private); | |
| 61 if (d) | |
| 62 d->ref(); | |
| 63 assign(d); | |
| 64 } | |
| 65 | |
| 66 WebString WebDatabase::name() const | |
| 67 { | |
| 68 if (m_private) | |
| 69 return m_private->stringIdentifier(); | |
| 70 | |
| 71 return WebString::fromUTF8("null"); | |
| 72 } | |
| 73 | |
| 74 WebString WebDatabase::displayName() const | |
| 75 { | |
| 76 // FIXME: add the Database::displayName() method. | |
| 77 // if (m_private) | |
| 78 // return m_private->displayName(); | |
| 79 | |
| 80 return WebString::fromUTF8("null"); | |
| 81 } | |
| 82 | |
| 83 unsigned long WebDatabase::estimatedSize() const | |
| 84 { | |
| 85 // FIXME: add the Database::estimatedSize() method. | |
| 86 // if (m_private) | |
| 87 // return m_private->estimatedSize(); | |
| 88 | |
| 89 return -1; | |
| 90 } | |
| 91 | |
| 92 WebSecurityOrigin WebDatabase::securityOrigin() const | |
| 93 { | |
| 94 // FIXME: add the Database::threadSafeSecurityOrigin() method. | |
| 95 // if (m_private) | |
| 96 // return WebSecurityOrigin(m_private->threadSafeSecurityOrigin()); | |
| 97 | |
| 98 return WebSecurityOrigin(); | |
| 99 } | |
| 100 | |
| 101 void WebDatabase::setObserver(WebDatabaseObserver* observer) | |
| 102 { | |
| 103 databaseObserver = observer; | |
| 104 } | |
| 105 | |
| 106 WebDatabaseObserver* WebDatabase::observer() | |
| 107 { | |
| 108 return databaseObserver; | |
| 109 } | |
| 110 | |
| 111 void WebDatabase::updateDatabaseSize( | |
| 112 const WebString& originIdentifier, const WebString& databaseName, | |
| 113 unsigned long long databaseSize, unsigned long long spaceAvailable) | |
| 114 { | |
| 115 // FIXME: add the QuotaTracker class. | |
| 116 // WebCore::QuotaTracker::instance().updateDatabaseSize( | |
| 117 // originIdentifier, databaseName, databaseSize, spaceAvailable); | |
| 118 } | |
| 119 | |
| 120 WebDatabase::WebDatabase(const WTF::PassRefPtr<Database>& database) | |
| 121 : m_private(static_cast<WebDatabasePrivate*>(database.releaseRef())) | |
| 122 { | |
| 123 } | |
| 124 | |
| 125 WebDatabase& WebDatabase::operator=(const WTF::PassRefPtr<Database>& database) | |
| 126 { | |
| 127 assign(static_cast<WebDatabasePrivate*>(database.releaseRef())); | |
| 128 return *this; | |
| 129 } | |
| 130 | |
| 131 WebDatabase::operator WTF::PassRefPtr<Database>() const | |
| 132 { | |
| 133 return PassRefPtr<Database>(const_cast<WebDatabasePrivate*>(m_private)); | |
| 134 } | |
| 135 | |
| 136 void WebDatabase::assign(WebDatabasePrivate* d) | |
| 137 { | |
| 138 // d is already ref'd for us by the caller | |
| 139 if (m_private) | |
| 140 m_private->deref(); | |
| 141 m_private = d; | |
| 142 } | |
| 143 | |
| 144 } // namespace WebKit | |
| OLD | NEW |