forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing the file naming scheme. Creating a directory for each origin,
and naming files according to the row ID of the respective DB in the tracker database. Also, fixing a bug: caching the renderer process handle in DatabaseDispatcherHost after it was set in ResourceMessageFilter. TEST=none BUG=none Review URL: http://codereview.chromium.org/385051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31874 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
dumi@chromium.org
committed
Nov 13, 2009
1 parent
dad1e3b
commit 3c5ed2c
Showing
16 changed files
with
283 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) 2009 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "webkit/database/database_util.h" | ||
|
||
#include "base/string_util.h" | ||
#include "webkit/database/database_tracker.h" | ||
#include "webkit/database/vfs_backend.h" | ||
|
||
namespace webkit_database { | ||
|
||
bool DatabaseUtil::CrackVfsFilePath(const string16& vfs_file_path, | ||
string16* origin_identifier, | ||
string16* database_name, | ||
string16* sqlite_suffix) { | ||
// 'vfs_file_path' is of the form <origin_identifier>/<db_name>#<suffix>. | ||
// <suffix> is optional. | ||
DCHECK(!vfs_file_path.empty()); | ||
size_t first_slash_index = vfs_file_path.find('/'); | ||
size_t last_pound_index = vfs_file_path.rfind('#'); | ||
// '/' and '#' must be present in the string. Also, the string cannot start | ||
// with a '/' (origin_identifier cannot be empty) and '/' must come before '#' | ||
if ((first_slash_index == string16::npos) || | ||
(last_pound_index == string16::npos) || | ||
(first_slash_index == 0) || | ||
(first_slash_index > last_pound_index)) { | ||
return false; | ||
} | ||
|
||
*origin_identifier = vfs_file_path.substr(0, first_slash_index); | ||
*database_name = vfs_file_path.substr( | ||
first_slash_index + 1, last_pound_index - first_slash_index - 1); | ||
*sqlite_suffix = vfs_file_path.substr( | ||
last_pound_index + 1, vfs_file_path.length() - last_pound_index - 1); | ||
return true; | ||
} | ||
|
||
FilePath DatabaseUtil::GetFullFilePathForVfsFile( | ||
DatabaseTracker* db_tracker, const string16& vfs_file_path) { | ||
string16 origin_identifier; | ||
string16 database_name; | ||
string16 sqlite_suffix; | ||
if (!CrackVfsFilePath(vfs_file_path, &origin_identifier, | ||
&database_name, &sqlite_suffix)) { | ||
return FilePath(); // invalid vfs_file_name | ||
} | ||
|
||
FilePath full_path = db_tracker->GetFullDBFilePath( | ||
origin_identifier, database_name); | ||
if (!full_path.empty() && !sqlite_suffix.empty()) { | ||
full_path = FilePath::FromWStringHack( | ||
full_path.ToWStringHack() + UTF16ToWide(sqlite_suffix)); | ||
} | ||
return full_path; | ||
} | ||
|
||
} // namespace webkit_database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2009 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef WEBKIT_DATABASE_DATABASE_UTIL_H_ | ||
#define WEBKIT_DATABASE_DATABASE_UTIL_H_ | ||
|
||
#include "base/file_path.h" | ||
#include "base/string16.h" | ||
|
||
namespace webkit_database { | ||
|
||
class DatabaseTracker; | ||
|
||
class DatabaseUtil { | ||
public: | ||
static bool CrackVfsFilePath(const string16& vfs_file_path, | ||
string16* origin_identifier, | ||
string16* database_name, | ||
string16* sqlite_suffix); | ||
static FilePath GetFullFilePathForVfsFile(DatabaseTracker* db_tracker, | ||
const string16& vfs_file_path); | ||
|
||
}; | ||
|
||
} // namespace webkit_database | ||
|
||
#endif // WEBKIT_DATABASE_DATABASE_UTIL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2009 The Chromium Authos. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/string_util.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
#include "webkit/database/database_util.h" | ||
|
||
using webkit_database::DatabaseUtil; | ||
|
||
static void TestVfsFilePath(bool expected_result, | ||
const char* vfs_file_path, | ||
const char* expected_origin_identifier = "", | ||
const char* expected_database_name = "", | ||
const char* expected_sqlite_suffix = "") { | ||
string16 origin_identifier; | ||
string16 database_name; | ||
string16 sqlite_suffix; | ||
EXPECT_EQ(expected_result, | ||
DatabaseUtil::CrackVfsFilePath(ASCIIToUTF16(vfs_file_path), | ||
&origin_identifier, | ||
&database_name, | ||
&sqlite_suffix)); | ||
EXPECT_EQ(ASCIIToUTF16(expected_origin_identifier), origin_identifier); | ||
EXPECT_EQ(ASCIIToUTF16(expected_database_name), database_name); | ||
EXPECT_EQ(ASCIIToUTF16(expected_sqlite_suffix), sqlite_suffix); | ||
} | ||
|
||
namespace webkit_database { | ||
|
||
// Test DatabaseUtil::CrackVfsFilePath on various inputs. | ||
TEST(DatabaseUtilTest, CrackVfsFilePathTest) { | ||
TestVfsFilePath(true, "origin/#", "origin", "", ""); | ||
TestVfsFilePath(true, "origin/#suffix", "origin", "", "suffix"); | ||
TestVfsFilePath(true, "origin/db_name#", "origin", "db_name", ""); | ||
TestVfsFilePath(true, "origin/db_name#suffix", "origin", "db_name", "suffix"); | ||
TestVfsFilePath(false, "origindb_name#"); | ||
TestVfsFilePath(false, "origindb_name#suffix"); | ||
TestVfsFilePath(false, "origin/db_name"); | ||
TestVfsFilePath(false, "origin#db_name/suffix"); | ||
TestVfsFilePath(false, "/db_name#"); | ||
TestVfsFilePath(false, "/db_name#suffix"); | ||
} | ||
|
||
} // namespace webkit_database |
Oops, something went wrong.