1 /* 2 * Copyright (C) 2006 Apple Computer, 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 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #include "config.h" 27 #include "IconDatabase.h" 28 29 #if !ENABLE(ICONDATABASE) 30 31 #include "PlatformString.h" 32 #include "SharedBuffer.h" 33 #include <wtf/StdLibExtras.h> 34 35 namespace WebCore { 36 37 static IconDatabase* sharedIconDatabase = 0; 38 39 // This version number is in the DB and marks the current generation of the schema 40 // Theoretically once the switch is flipped this should never change 41 // Currently, an out-of-date schema causes the DB to be wiped and reset. This isn't 42 // so bad during development but in the future, we would need to write a conversion 43 // function to advance older released schemas to "current" 44 const int currentDatabaseVersion = 5; 45 46 // Icons expire once a day 47 const int iconExpirationTime = 60*60*24; 48 // Absent icons are rechecked once a week 49 const int missingIconExpirationTime = 60*60*24*7; 50 51 const int updateTimerDelay = 5; 52 53 String IconDatabase::defaultDatabaseFilename() 54 { 55 DEFINE_STATIC_LOCAL(String, defaultDatabaseFilename, ("Icons.db")); 56 return defaultDatabaseFilename.threadsafeCopy(); 57 } 58 59 IconDatabase* iconDatabase() 60 { 61 if (!sharedIconDatabase) 62 sharedIconDatabase = new IconDatabase; 63 return sharedIconDatabase; 64 } 65 66 IconDatabase::IconDatabase() 67 { 68 } 69 70 bool IconDatabase::open(const String& /*databasePath*/) 71 { 72 return false; 73 } 74 75 bool IconDatabase::isOpen() const 76 { 77 return false; 78 } 79 80 void IconDatabase::close() 81 { 82 } 83 84 String IconDatabase::databasePath() const 85 { 86 return String(); 87 } 88 89 void IconDatabase::removeAllIcons() 90 { 91 } 92 93 void IconDatabase::setPrivateBrowsingEnabled(bool /*flag*/) 94 { 95 } 96 97 bool IconDatabase::isPrivateBrowsingEnabled() const 98 { 99 return false; 100 } 101 102 void IconDatabase::readIconForPageURLFromDisk(const String&) 103 { 104 105 } 106 107 Image* IconDatabase::iconForPageURL(const String& /*pageURL*/, const IntSize& size) 108 { 109 return defaultIcon(size); 110 } 111 112 113 IconLoadDecision IconDatabase::loadDecisionForIconURL(const String&, DocumentLoader*) 114 { 115 return IconLoadNo; 116 } 117 118 bool IconDatabase::iconDataKnownForIconURL(const String&) 119 { 120 return false; 121 } 122 123 String IconDatabase::iconURLForPageURL(const String& /*pageURL*/) 124 { 125 return String(); 126 } 127 128 Image* IconDatabase::defaultIcon(const IntSize& /*size*/) 129 { 130 return 0; 131 } 132 133 void IconDatabase::retainIconForPageURL(const String& /*pageURL*/) 134 { 135 } 136 137 void IconDatabase::releaseIconForPageURL(const String& /*pageURL*/) 138 { 139 } 140 141 void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> /*data*/, const String& /*iconURL*/) 142 { 143 } 144 145 void IconDatabase::setIconURLForPageURL(const String& /*iconURL*/, const String& /*pageURL*/) 146 { 147 } 148 149 void IconDatabase::setEnabled(bool /*enabled*/) 150 { 151 } 152 153 bool IconDatabase::isEnabled() const 154 { 155 return false; 156 } 157 158 IconDatabase::~IconDatabase() 159 { 160 ASSERT_NOT_REACHED(); 161 } 162 163 void IconDatabase::checkIntegrityBeforeOpening() 164 { 165 } 166 167 void IconDatabase::delayDatabaseCleanup() 168 { 169 } 170 171 void IconDatabase::allowDatabaseCleanup() 172 { 173 } 174 175 size_t IconDatabase::pageURLMappingCount() 176 { 177 return 0; 178 } 179 180 size_t IconDatabase::retainedPageURLCount() 181 { 182 return 0; 183 } 184 185 size_t IconDatabase::iconRecordCount() 186 { 187 return 0; 188 } 189 190 size_t IconDatabase::iconRecordCountWithData() 191 { 192 return 0; 193 } 194 195 void IconDatabase::setClient(IconDatabaseClient*) 196 { 197 } 198 199 // ************************ 200 // *** Sync Thread Only *** 201 // ************************ 202 203 void IconDatabase::importIconURLForPageURL(const String&, const String&) 204 { 205 } 206 207 void IconDatabase::importIconDataForIconURL(PassRefPtr<SharedBuffer>, const String&) 208 { 209 } 210 211 bool IconDatabase::shouldStopThreadActivity() const 212 { 213 return true; 214 } 215 216 } // namespace WebCore 217 218 #endif // !ENABLE(ICONDATABASE) 219