| Index: webkit/database/database_tracker.h
|
| ===================================================================
|
| --- webkit/database/database_tracker.h (revision 49482)
|
| +++ webkit/database/database_tracker.h (working copy)
|
| @@ -10,6 +10,7 @@
|
|
|
| #include "base/file_path.h"
|
| #include "base/observer_list.h"
|
| +#include "base/platform_file.h"
|
| #include "base/ref_counted.h"
|
| #include "base/scoped_ptr.h"
|
| #include "base/string16.h"
|
| @@ -100,7 +101,7 @@
|
| virtual ~Observer() {}
|
| };
|
|
|
| - explicit DatabaseTracker(const FilePath& profile_path);
|
| + DatabaseTracker(const FilePath& profile_path, bool is_incognito);
|
|
|
| void DatabaseOpened(const string16& origin_identifier,
|
| const string16& database_name,
|
| @@ -156,6 +157,18 @@
|
| int DeleteDataForOrigin(const string16& origin_identifier,
|
| net::CompletionCallback* callback);
|
|
|
| + bool IsIncognitoProfile() const { return is_incognito_; }
|
| +
|
| + void GetIncognitoFileHandle(const string16& vfs_file_path,
|
| + base::PlatformFile* file_handle) const;
|
| + void SaveIncognitoFileHandle(const string16& vfs_file_path,
|
| + const base::PlatformFile& file_handle);
|
| + bool CloseIncognitoFileHandle(const string16& vfs_file_path);
|
| + bool HasSavedIncognitoFileHandle(const string16& vfs_file_path) const;
|
| +
|
| + // Deletes the directory that stores all DBs in incognito mode, if it exists.
|
| + void DeleteIncognitoDBDirectory();
|
| +
|
| static void ClearLocalState(const FilePath& profile_path);
|
|
|
| private:
|
| @@ -164,6 +177,8 @@
|
|
|
| typedef std::map<string16, std::set<string16> > DatabaseSet;
|
| typedef std::map<net::CompletionCallback*, DatabaseSet> PendingCompletionMap;
|
| + typedef std::map<string16, base::PlatformFile> FileHandlesMap;
|
| + typedef std::map<string16, string16> OriginDirectoriesMap;
|
|
|
| class CachedOriginInfo : public OriginInfo {
|
| public:
|
| @@ -216,8 +231,13 @@
|
| void ScheduleDatabasesForDeletion(const DatabaseSet& databases,
|
| net::CompletionCallback* callback);
|
|
|
| + // Returns the directory where all DB files for the given origin are stored.
|
| + string16 GetOriginDirectory(const string16& origin_identifier);
|
| +
|
| bool is_initialized_;
|
| const bool is_incognito_;
|
| + bool shutting_down_;
|
| + const FilePath profile_path_;
|
| const FilePath db_dir_;
|
| scoped_ptr<sql::Connection> db_;
|
| scoped_ptr<DatabasesTable> databases_table_;
|
| @@ -238,8 +258,21 @@
|
| // to quota_table_ every time an extention is loaded.
|
| std::map<string16, int64> in_memory_quotas_;
|
|
|
| - FRIEND_TEST(DatabaseTrackerTest, DatabaseTracker);
|
| - FRIEND_TEST(DatabaseTrackerTest, NoInitIncognito);
|
| + // When in incognito mode, store a DELETE_ON_CLOSE handle to each
|
| + // main DB and journal file that was accessed. When the incognito profile
|
| + // goes away (or when the browser crashes), all these handles will be
|
| + // closed, and the files will be deleted.
|
| + FileHandlesMap incognito_file_handles_;
|
| +
|
| + // In a non-incognito profile, all DBs in an origin are stored in a directory
|
| + // named after the origin. In an incognito profile though, we do not want the
|
| + // directory structure to reveal the origins visited by the user (in case the
|
| + // browser process crashes and those directories are not deleted). So we use
|
| + // this map to assign directory names that do not reveal this information.
|
| + OriginDirectoriesMap incognito_origin_directories_;
|
| + int incognito_origin_directories_generator_;
|
| +
|
| + FRIEND_TEST(DatabaseTracker, TestHelper);
|
| };
|
|
|
| } // namespace webkit_database
|
|
|