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

Side by Side Diff: webkit/database/database_tracker.cc

Issue 437025: Merge 32883 - Increasing the default DB quota for extensions from 5MB to 50MB... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/249/src/
Patch Set: Created 11 years 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 | « no previous file | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "webkit/database/database_tracker.h" 5 #include "webkit/database/database_tracker.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/sql/connection.h" 9 #include "app/sql/connection.h"
10 #include "app/sql/meta_table.h" 10 #include "app/sql/meta_table.h"
11 #include "app/sql/statement.h" 11 #include "app/sql/statement.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "webkit/database/databases_table.h" 16 #include "webkit/database/databases_table.h"
17 17
18 namespace webkit_database { 18 namespace webkit_database {
19 19
20 const FilePath::CharType kDatabaseDirectoryName[] = 20 const FilePath::CharType kDatabaseDirectoryName[] =
21 FILE_PATH_LITERAL("databases"); 21 FILE_PATH_LITERAL("databases");
22 const FilePath::CharType kTrackerDatabaseFileName[] = 22 const FilePath::CharType kTrackerDatabaseFileName[] =
23 FILE_PATH_LITERAL("Databases.db"); 23 FILE_PATH_LITERAL("Databases.db");
24 const int kCurrentVersion = 1; 24 const int kCurrentVersion = 1;
25 const int kCompatibleVersion = 1; 25 const int kCompatibleVersion = 1;
26 const int64 kDefaultQuota = 5 * 1024 * 1024; 26 const int64 kDefaultQuota = 5 * 1024 * 1024;
27 const int64 kDefaultExtensionQuota = 50 * 1024 * 1024;
28 const char* kExtensionOriginIdentifierPrefix = "chrome-extension_";
27 29
28 DatabaseTracker::DatabaseTracker(const FilePath& profile_path) 30 DatabaseTracker::DatabaseTracker(const FilePath& profile_path)
29 : initialized_(false), 31 : initialized_(false),
30 db_dir_(profile_path.Append(FilePath(kDatabaseDirectoryName))), 32 db_dir_(profile_path.Append(FilePath(kDatabaseDirectoryName))),
31 db_(new sql::Connection()), 33 db_(new sql::Connection()),
32 databases_table_(NULL), 34 databases_table_(NULL),
33 meta_table_(NULL) { 35 meta_table_(NULL) {
34 } 36 }
35 37
36 DatabaseTracker::~DatabaseTracker() { 38 DatabaseTracker::~DatabaseTracker() {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 223 }
222 224
223 int64 DatabaseTracker::GetOriginUsage(const string16& origin_identifier) { 225 int64 DatabaseTracker::GetOriginUsage(const string16& origin_identifier) {
224 CachedOriginInfo* origin_info = GetCachedOriginInfo(origin_identifier); 226 CachedOriginInfo* origin_info = GetCachedOriginInfo(origin_identifier);
225 if (!origin_info) 227 if (!origin_info)
226 return kint64max; 228 return kint64max;
227 return origin_info->TotalSize(); 229 return origin_info->TotalSize();
228 } 230 }
229 231
230 int64 DatabaseTracker::GetOriginQuota( 232 int64 DatabaseTracker::GetOriginQuota(
231 const string16& /*origin_identifier*/) const { 233 const string16& origin_identifier) const {
234 if (StartsWith(origin_identifier,
235 ASCIIToUTF16(kExtensionOriginIdentifierPrefix), true)) {
236 return kDefaultExtensionQuota;
237 }
238
232 return kDefaultQuota; 239 return kDefaultQuota;
233 } 240 }
234 241
235 int64 DatabaseTracker::GetOriginSpaceAvailable( 242 int64 DatabaseTracker::GetOriginSpaceAvailable(
236 const string16& origin_identifier) { 243 const string16& origin_identifier) {
237 int64 space_available = GetOriginQuota(origin_identifier) - 244 int64 space_available = GetOriginQuota(origin_identifier) -
238 GetOriginUsage(origin_identifier); 245 GetOriginUsage(origin_identifier);
239 return (space_available < 0 ? 0 : space_available); 246 return (space_available < 0 ? 0 : space_available);
240 } 247 }
241 248
242 } // namespace webkit_database 249 } // namespace webkit_database
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698