OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DATABASE_SYSTEM_H_ | 5 #ifndef WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DATABASE_SYSTEM_H_ |
6 #define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DATABASE_SYSTEM_H_ | 6 #define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DATABASE_SYSTEM_H_ |
7 | 7 |
8 #include "base/file_path.h" | |
9 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
| 9 #include "base/ref_counted.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| 11 #include "base/string16.h" |
| 12 #include "third_party/WebKit/WebKit/chromium/public/WebDatabaseObserver.h" |
| 13 #include "webkit/database/database_tracker.h" |
11 | 14 |
12 class SimpleDatabaseSystem { | 15 class SimpleDatabaseSystem : public webkit_database::DatabaseTracker::Observer, |
| 16 public WebKit::WebDatabaseObserver { |
13 public: | 17 public: |
14 static SimpleDatabaseSystem* GetInstance(); | 18 static SimpleDatabaseSystem* GetInstance(); |
15 SimpleDatabaseSystem(); | 19 SimpleDatabaseSystem(); |
16 ~SimpleDatabaseSystem(); | 20 ~SimpleDatabaseSystem(); |
17 | 21 |
18 base::PlatformFile OpenFile( | 22 // VFS functions |
19 const FilePath& file_name, int desired_flags, | 23 base::PlatformFile OpenFile(const string16& vfs_file_name, |
20 base::PlatformFile* dir_handle); | 24 int desired_flags, |
21 int DeleteFile(const FilePath& file_name, bool sync_dir); | 25 base::PlatformFile* dir_handle); |
22 long GetFileAttributes(const FilePath& file_name); | 26 int DeleteFile(const string16& vfs_file_name, bool sync_dir); |
23 long long GetFileSize(const FilePath& file_name); | 27 long GetFileAttributes(const string16& vfs_file_name); |
| 28 long long GetFileSize(const string16& vfs_file_name); |
| 29 |
| 30 // database tracker functions |
| 31 void DatabaseOpened(const string16& origin_identifier, |
| 32 const string16& database_name, |
| 33 const string16& description, |
| 34 int64 estimated_size); |
| 35 void DatabaseModified(const string16& origin_identifier, |
| 36 const string16& database_name); |
| 37 void DatabaseClosed(const string16& origin_identifier, |
| 38 const string16& database_name); |
| 39 |
| 40 // DatabaseTracker::Observer implementation |
| 41 virtual void OnDatabaseSizeChanged(const string16& origin_identifier, |
| 42 const string16& database_name, |
| 43 int64 database_size, |
| 44 int64 space_available); |
| 45 |
| 46 // WebDatabaseObserver implementation |
| 47 virtual void databaseOpened(const WebKit::WebDatabase& database); |
| 48 virtual void databaseModified(const WebKit::WebDatabase& database); |
| 49 virtual void databaseClosed(const WebKit::WebDatabase& database); |
| 50 |
24 void ClearAllDatabases(); | 51 void ClearAllDatabases(); |
25 | 52 |
26 private: | 53 private: |
27 FilePath GetDBDir(); | |
28 FilePath GetDBFileFullPath(const FilePath& file_name); | |
29 | |
30 static SimpleDatabaseSystem* instance_; | 54 static SimpleDatabaseSystem* instance_; |
31 | 55 |
32 ScopedTempDir temp_dir_; | 56 ScopedTempDir temp_dir_; |
33 | 57 |
34 // HACK: see OpenFile's implementation | 58 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; |
35 base::PlatformFile hack_main_db_handle_; | |
36 }; | 59 }; |
37 | 60 |
38 #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DATABASE_SYSTEM_H_ | 61 #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DATABASE_SYSTEM_H_ |
OLD | NEW |